偏置曲柄滑块机构是一种常见的机械传动机构,由曲柄、偏置滑块和连杆组成。其中,偏置滑块具有急回特性,可以使机构在运动过程中产生快速的反向运动。
偏置曲柄滑块机构中,连杆上的双尖点轨迹指的是连杆在偏置曲柄滑块机构的运动过程中所经过的两个尖点所形成的轨迹。这两个尖点通常位于连杆的两端,分别对应于曲柄与偏置滑块的接触点和偏置滑块与连杆的接触点。
偏置曲柄滑块机构的双尖点轨迹形状与曲柄的摆动角度、偏置滑块的偏置距离以及连杆的长度等因素有关。在实际应用中,通过对双尖点轨迹的分析,可以了解偏置曲柄滑块机构的运动特性,为机构的设计和优化提供参考。
import sympy as sy
a,b,b1,e,fi= sy.symbols('a,b,b1,e,fi')
S3=a*sy.cos(fi)+sy.sqrt(b**2-(a*sy.sin(fi)-e)**2)
theta=sy.atan((a*sy.sin(fi)-e)/(a*sy.cos(fi)-S3))+sy.pi
delta=sy.atan(sy.sqrt(b**2-b1**2)/b1)
xp=a*sy.cos(fi)+b*sy.cos(theta+sy.pi)+b1*sy.cos(theta-delta)
yp=a*sy.sin(fi)+b*sy.sin(theta+sy.pi)+b1*sy.sin(theta-delta)
xp_c=xp.subs({a:0.3/2,b:0.9/2,b1:0.8*0.3/2,e:-0.8*0.3/2})
yp_c=yp.subs({a:0.3/2,b:0.9/2,b1:0.8*0.3/2,e:-0.8*0.3/2})
sy.plot_parametric(xp_c,yp_c,(fi,0,2*sy.pi))
import sympy as sy
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
a,b,b1,e,fi= sy.symbols('a,b,b1,e,fi')
S3=a*sy.cos(fi)+sy.sqrt(b**2-(a*sy.sin(fi)-e)**2)
theta=sy.atan((a*sy.sin(fi)-e)/(a*sy.cos(fi)-S3))+sy.pi
delta=sy.atan(sy.sqrt(b**2-b1**2)/b1)
xp=a*sy.cos(fi)+b*sy.cos(theta+sy.pi)+b1*sy.cos(theta-delta)
yp=a*sy.sin(fi)+b*sy.sin(theta+sy.pi)+b1*sy.sin(theta-delta)
xp_c=xp.subs({a:0.3/2,b:0.9/2,b1:0.8*0.3/2,e:-0.8*0.3/2})
yp_c=yp.subs({a:0.3/2,b:0.9/2,b1:0.8*0.3/2,e:-0.8*0.3/2})
# sy.plot_parametric(xp_c,yp_c,(fi,0,2*sy.pi))
fx = sy.lambdify(fi, xp_c, modules='numpy')
fy = sy.lambdify(fi, yp_c, modules='numpy')
class drawAni():
# func为参数方程
def __init__(self,traceFuncs, para, txtFunc,ts,xlim,ylim,figsize=(16,9),iniFunc=None):
self.funcs = traceFuncs # 画图代码
self.para = para # 画图参数
self.txtFunc = txtFunc
self.fig = plt.figure(figsize=figsize)
ax = self.fig.add_subplot(autoscale_on=False,xlim=xlim,ylim=ylim)
ax.grid()
if iniFunc!=None:initFunc(ax)
self.N = len(para) # 轨迹个数
self.traces = [ax.plot([],[],p['flag'], lw=p['lw'])[0]
for p in para]
self.text = ax.text(0.02,0.85,'',transform=ax.transAxes)
self.initXY(self.N)
self.ts = ts #此为自变量
self.run(ts)
def initXY(self,N):
self.xs = [[] for _ in range(N)]
self.ys = [[] for _ in range(N)]
def animate(self,t):
if(t==self.ts[0]):
self.initXY(self.N)
for i in range(self.N):
x,y = self.funcs[i](t)
if self.para[i]['flush']==False:
self.xs[i].append(x)
self.ys[i].append(y)
self.traces[i].set_data(self.xs[i], self.ys[i])
else:
self.traces[i].set_data(x,y)
self.text.set_text(self.txtFunc(t))
return self.traces+[self.text]
def run(self,ts):
self.ani = animation.FuncAnimation(self.fig, self.animate, ts, interval=5, blit=True)
plt.subplots_adjust(left=0.05, right=0.95, top=0.95, bottom=0.1)
plt.show()
def save(self,saveName):
self.ani.save(saveName,writer='pillow',fps=20)
def traceFunc(fi):
return fx(fi), fy(fi)
def lineFunc(theta):
x,y = traceFunc(theta)
return [0.4,x], [0,y]
def txtFunc(theta):
th = 180*theta/np.pi
x,y = traceFunc(theta)
len = np.sqrt(x**2+y**2)
txt = f'theta={th:.2f}\nlen={len:.2f}'
txt += f'len={len:.2f}'
return txt
xlim,ylim = (0.1,0.7), (-0.01,0.001)
ts = np.linspace(0,6.28,200)
funcs = [lineFunc, traceFunc]
tracePara = [
{'flag':'o-','lw':2, 'flush':False},
{'flag':'-','lw':1, 'flush':False}
]
an = drawAni(funcs, tracePara, txtFunc,ts, xlim, ylim, (12,9))
an.save("test.gif")