Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from matplotlib import pyplot as plt
- import math
- r1 = 90
- r2 = 50
- r3 = 40
- r4 = 8
- fi = 321.057559*math.pi/180
- theta45 = 2*math.pi/3
- theta34max = 0
- theta34min = -7*math.pi/18
- all2 = []
- all3 = []
- all4 = []
- all5 = []
- allrest = []
- alltheta34 = []
- dt = 0.5/865
- allomega2 = []
- allomega3 = []
- allomega4 = []
- allafar2 = []
- allafar3 = []
- allafar4 = []
- allavetheta5 = []
- allsuperavetheta5 = []
- for theta4 in np.arange(math.pi,2*math.pi,math.pi/1800):
- x1 = -r4*math.cos(theta4)
- y1 = -r4*math.sin(theta4)
- x2 = -r1*math.cos(fi)
- y2 = -r1*math.sin(fi)
- AB = ((x2-x1)**2+(y2-y1)**2)**0.5
- if AB > r3 + r2:
- continue
- θAB = math.atan((y1-y2)/(x1-x2))
- θplus1 = math.acos((r2**2+AB**2-r3**2)/(2*r2*AB))
- θplus2 = math.acos((-r2**2+AB**2+r3**2)/(2*r3*AB))
- rest = -(θplus1 + θplus2)
- if AB < r3+r2:
- theta2 = θAB + θplus1
- if theta2 < 0:
- theta2 = 2*math.pi + theta2
- theta3 = theta2 + rest
- if theta3 < 0:
- theta3 = 2*math.pi + theta3
- elif AB == r3+r2:
- theta2 = theta3 = θAB
- if theta2 < 0:
- theta2 = 2*math.pi + theta2
- theta3 = theta2 + rest
- if theta3 < 0:
- theta3 = 2*math.pi + theta3
- theta34 = -abs(theta4 - theta3)
- if theta34 > math.pi:
- theta34 = theta34 - math.pi
- allrest.append(rest)
- alltheta34.append(theta34)
- if theta34 > theta34max or theta34 < theta34min:
- continue
- theta5 = theta4 + theta45
- if theta5 < 0:
- continue
- if theta5 > 2*math.pi:
- theta5 = theta5 - 2*math.pi
- if theta5 > math.pi:
- continue
- all2.append(theta2)
- all3.append(theta3)
- all4.append(theta4)
- all5.append(theta5)
- for i in range(0,len(all2)-1):
- omega2 = (all2[i+1]-all2[i])/dt
- allomega2.append(omega2)
- for j in range(0,len(all3)-1):
- omega3 = (all3[j+1]-all3[j])/dt
- allomega3.append(omega3)
- for k in range(0,len(all4)-1):
- omega4 = (all4[k+1]-all4[k])/dt
- allomega4.append(omega4)
- for i1 in range(0,len(allomega2)-1):
- afar2 = (allomega2[i1+1]-allomega2[i1])/dt
- allafar2.append(afar2)
- for j1 in range(0,len(allomega3)-1):
- afar3 = (allomega3[j1+1]-allomega3[j1])/dt
- allafar3.append(afar3)
- for k1 in range(0,len(allomega4)-1):
- afar4 = (allomega4[k1+1]-allomega4[k1])/dt
- allafar4.append(afar4)
- for c in range(0,len(all5)-1):
- avetheta5 = (all5[c] + all5[c+1])/2
- allavetheta5.append(avetheta5)
- for d in range(0,len(allavetheta5)-1):
- superavetheta5 = (allavetheta5[d] + allavetheta5[d+1])/2
- allsuperavetheta5.append(superavetheta5)
- fig = plt.figure()
- ax1 = fig.add_subplot(111)
- ax1.set_title('θ2-θ5')
- plt.xlabel('θ5')
- plt.ylabel('θ2')
- ax1.scatter(allavetheta5,allomega3,c = 'r',marker = 'o')
- plt.ylim([-4,2])
- plt.legend('x1')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement