文章来源:https://www.toymoban.com/news/detail-701453.html
import sympy as sy
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
a,b1,b2,b3,b4,theta,c,d,alpha,delta,fi=sy.symbols("a,b1,b2,b3,b4,theta,c,d,alpha,delta,fi")
ka=-2*c*(d*sy.sin(alpha)+a*sy.sin(fi))
kb=2*c*(d*sy.cos(alpha)-a*sy.cos(fi))
kc=a**2-b1**2+c**2+d**2-2*a*d*sy.cos(alpha+fi)
pu=2*sy.atan((ka+sy.sqrt(ka**2+kb**2-kc**2))/(kb-kc))
lamda=sy.atan(2*(-d*sy.sin(alpha)+c*sy.sin(pu)-a*sy.sin(fi))/(d*sy.cos(alpha)+c*sy.cos(pu)-a*sy.cos(fi)))
Ex=c*sy.cos(pu)+b2*sy.cos(lamda)
Ey=c*sy.sin(pu)+b2*sy.sin(lamda)
k1=-(1+sy.tan(delta)*sy.tan(lamda))/(sy.tan(lamda)-sy.tan(delta))
k2=((1+sy.tan(delta)*sy.tan(lamda))*Ex+(sy.tan(lamda)-sy.tan(delta))*Ey)/(sy.tan(lamda)-sy.tan(delta))
Hx=(Ex+(Ey-k2)*k1+sy.sqrt((Ex+(Ey-k2)*k1)**2-(1+k1**2)*(Ex**2+(Ey-k2)**2-b3**2)))/(1+k1**2)
Hy=k1*Hx+k2
Fx=(Ex-Hx)*sy.cos(-theta)-(Ey-Hy)*sy.sin(-theta)+Hx
Fy=(Ex-Hx)*sy.sin(-theta)+(Ey-Hy)*sy.cos(-theta)+Hy
gama=sy.atan(-(Fx-Hx)/(Fy-Hy))
Gx=sy.Piecewise((Fx-b4*sy.cos(gama), (0< gama) & (gama < sy.pi/2)),(Fx-b4*sy.cos(gama+sy.pi), (-sy.pi/2< gama) & (gama < 0)))
Gy=sy.Piecewise((Fy-b4*sy.sin(gama), (0< gama) & (gama < sy.pi/2)),(Fy-b4*sy.sin(gama+sy.pi), (-sy.pi/2< gama) & (gama < 0)))
# Gx=Fx-b4*sy.cos(gama)
# Gy=Fy-b4*sy.sin(gama)
Ax=-d*sy.cos(alpha)
Ay=d*sy.sin(alpha)
Bx=Ax+a*sy.cos(fi)
By=Ay+a*sy.sin(fi)
Cx=c*sy.cos(pu)
Cy=c*sy.sin(pu)
bL=sy.atan((Ey-Hy)/(Ex-Hx))+sy.pi
bR=sy.atan((Fy-Hy)/(Fx-Hx))
bl=sy.lambdify(fi,bL.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
br=sy.lambdify(fi,bR.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
a1x=sy.lambdify(fi,Ax.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
a1y=sy.lambdify(fi,Ay.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
bx=sy.lambdify(fi,Bx.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
by=sy.lambdify(fi,By.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
cx=sy.lambdify(fi,Cx.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
cy=sy.lambdify(fi,Cy.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
ex=sy.lambdify(fi,Ex.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
ey=sy.lambdify(fi,Ey.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
hx=sy.lambdify(fi,Hx.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
hy=sy.lambdify(fi,Hy.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
fx=sy.lambdify(fi,Fx.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
fy=sy.lambdify(fi,Fy.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
gx=sy.lambdify(fi,Gx.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
gy=sy.lambdify(fi,Gy.subs({a:100.233,b1:278.577,b2:57.352,b3:231.824,b4:165.944,theta:147.866*sy.pi/180,c:189.602,d:330,
alpha:46.385*sy.pi/180,delta:103.038*sy.pi/180}),modules='numpy')
fig,ax = plt.subplots()
plt.rcParams['xtick.direction'] = 'in' # 将x周的刻度线方向设置向内
plt.rcParams['ytick.direction'] = 'in' # 将y轴的刻度方向设置向内
plt.rcParams['axes.unicode_minus']=False
# plt.rcParams['font.family'] = ["Times New Roman"] # 字体设置为Times NewRoman
plt.rcParams['font.sans-serif'] = ['SimHei']
clist = ['blue', 'red', 'green', 'black', 'darkgreen', 'lime', 'gold', 'purple', 'green', 'cyan', 'salmon', 'grey',
'mediumvioletred', 'darkkhaki', 'gray', 'darkcyan', 'violet', 'powderblue']
markerlst = ['o', '*', 'x', '>', '<', '^', 'D', 'd', '1', '2', '3', '4', 'o', '*', 'x', '>', '<', '^', 'D', 'd',
'1', '2', '3', '4', 'o', '*', 'x', '>', '<', '^', 'D', 'd', '1', '2', '3', '4']
linestylelst = ['-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--',
'-.', ':', '-', '--', '-.', ':']
def draw_frame(i):
xd=0
yd=0
xa1=a1x(i)
ya1=a1y(i)
xb=bx(i)
yb=by(i)
xc=cx(i)
yc=cy(i)
xe=ex(i)
ye=ey(i)
xh=hx(i)
yh=hy(i)
xf=fx(i)
yf=fy(i)
xg=gx(i)
yg=gy(i)
lr=bl(i)
rr=br(i)
ax.clear()
ax.plot([xd, xa1], [yd, ya1], c=clist[0])
ax.plot([xa1,xb],[ya1,yb],c=clist[1])
ax.plot([xc, xb], [yc, yb], c=clist[2])
ax.plot([xc, xd], [yc, yd], c=clist[3])
ax.plot([xc, xe], [yc, ye], c=clist[4])
th = np.linspace(rr, lr, num=100)
x = xh + 231.824 * np.cos(th)
y = yh + 231.824 * np.sin(th)
plt.plot(x, y, c=clist[5])
ax.plot([xf, xg], [yf, yg], c=clist[6])
ax.axis('equal')
ax.set_xlim(xmin=-500,xmax=800)
ax.set_ylim(ymin=-500, ymax=500)
plt.tight_layout()
anim=FuncAnimation(fig,draw_frame,frames=360,interval=100)
anim.save("d4.gif",writer='pillow')
文章来源地址https://www.toymoban.com/news/detail-701453.html
到了这里,关于揉面四杆搅拌机构的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!