移动双点输入连杆夹持机构

import sympy as sy
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
a,b,c,d,e,L,F,S=sy.symbols("a,b,c,d,e,L,F,S")
k1=c*(d-a)
k2=-2*S*c
k3=S**2+c**2+(d-a)**2/4-b**2
pu=2*sy.atan((-k1+sy.sqrt(k1**2+k2**2-k3**2))/(k3-k2))
fi=sy.atan((0.5*d-0.5*a+c*sy.sin(pu))/(S-c*sy.cos(pu)))
F23=F*(L*sy.cos(pu)+e*sy.sin(pu))/(c*sy.sin(fi+pu))
F1=2*F23*sy.cos(fi)
Ax=-S
Bx=-S+b*sy.cos(fi)
By=a/2+b*sy.sin(fi)
B1x=-Bx
B1y=d/2-c*sy.sin(pu)
acx=sy.lambdify(S,Ax.subs({a:30,b:80,c:50,d:120,e:20,L:150,F:1200}),modules='numpy')
bx=sy.lambdify(S,Bx.subs({a:30,b:80,c:50,d:120,e:20,L:150,F:1200}),modules='numpy')
by=sy.lambdify(S,By.subs({a:30,b:80,c:50,d:120,e:20,L:150,F:1200}),modules='numpy')
b1x=sy.lambdify(S,B1x.subs({a:30,b:80,c:50,d:120,e:20,L:150,F:1200}),modules='numpy')
b1y=sy.lambdify(S,B1y.subs({a:30,b:80,c:50,d:120,e:20,L:150,F:1200}),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):
    s=50+i
    xa=acx(s)
    ya=15
    xb=bx(s)
    yb=by(s)
    xb1 = b1x(s)
    yb1 = b1y(s)
    xc=0
    yc=60
    ax.clear()
    ax.plot([xa, 0], [0, 0], c=clist[0])
    ax.plot([xa,xb],[ya,yb],c=clist[1])
    ax.plot([xb1, xb], [yb1, yb], c=clist[2])
    ax.plot([xc, xc], [-yc, yc], c=clist[3])
    ax.plot([xa, xa], [-ya, ya], c=clist[4])
    ax.plot([xa, xb], [-ya, -yb], c=clist[5])
    ax.plot([xb1, xb], [-yb1, -yb], c=clist[6])
    ax.axis('equal')
    ax.set_xlim(xmin=-150,xmax=150)
    ax.set_ylim(ymin=-150, ymax=150)
    plt.tight_layout()


anim=FuncAnimation(fig,draw_frame,frames=50,interval=50)
anim.save("d3.gif",writer='pillow')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值