Advertisement
yen881215

dynamic newnewnew

Dec 24th, 2019
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.65 KB | None | 0 0
  1. import numpy as np
  2. from matplotlib import pyplot as plt
  3. import math
  4.  
  5.  
  6. r1 = 90
  7. r2 = 50
  8. r3 = 40
  9. r4 = 8
  10. fi = 321.057559*math.pi/180
  11. theta45 = 2*math.pi/3
  12.  
  13. theta34max = 0
  14. theta34min = -7*math.pi/18
  15. all2 = []
  16. all3 = []
  17. all4 = []
  18. all5 = []
  19. allrest = []
  20. alltheta34 = []
  21. dt = 0.5/865
  22. allomega2 = []
  23. allomega3 = []
  24. allomega4 = []
  25. allafar2 = []
  26. allafar3 = []
  27. allafar4 = []
  28. allavetheta5 = []
  29. allsuperavetheta5 = []
  30. for theta4 in np.arange(math.pi,2*math.pi,math.pi/1800):
  31.     x1 = -r4*math.cos(theta4)
  32.     y1 = -r4*math.sin(theta4)
  33.     x2 = -r1*math.cos(fi)
  34.     y2 = -r1*math.sin(fi)
  35.     AB = ((x2-x1)**2+(y2-y1)**2)**0.5
  36.     if AB > r3 + r2:
  37.         continue
  38.     θAB = math.atan((y1-y2)/(x1-x2))
  39.     θplus1 = math.acos((r2**2+AB**2-r3**2)/(2*r2*AB))
  40.     θplus2 = math.acos((-r2**2+AB**2+r3**2)/(2*r3*AB))
  41.     rest = -(θplus1 + θplus2)
  42.    
  43.  
  44.  
  45.     if AB < r3+r2:
  46.         theta2 = θAB + θplus1
  47.         if theta2 < 0:
  48.             theta2 = 2*math.pi + theta2
  49.         theta3 = theta2 + rest
  50.         if theta3 < 0:
  51.             theta3 = 2*math.pi + theta3
  52.        
  53.  
  54.     elif AB == r3+r2:
  55.         theta2 = theta3 = θAB
  56.         if theta2 < 0:
  57.             theta2 = 2*math.pi + theta2
  58.         theta3 = theta2 + rest
  59.         if theta3 < 0:
  60.             theta3 = 2*math.pi + theta3
  61.  
  62.     theta34 = -abs(theta4 - theta3)
  63.     if theta34 > math.pi:
  64.         theta34 = theta34 - math.pi
  65.     allrest.append(rest)
  66.     alltheta34.append(theta34)
  67.     if theta34 > theta34max or theta34 < theta34min:
  68.         continue
  69.    
  70.     theta5 = theta4 + theta45
  71.     if theta5 < 0:
  72.         continue
  73.     if theta5 > 2*math.pi:
  74.         theta5 = theta5 - 2*math.pi
  75.     if theta5 > math.pi:
  76.         continue
  77.  
  78.     all2.append(theta2)
  79.     all3.append(theta3)
  80.     all4.append(theta4)
  81.     all5.append(theta5)
  82.  
  83. for i in range(0,len(all2)-1):
  84.     omega2 = (all2[i+1]-all2[i])/dt
  85.     allomega2.append(omega2)
  86. for j in range(0,len(all3)-1):
  87.     omega3 = (all3[j+1]-all3[j])/dt
  88.     allomega3.append(omega3)
  89. for k in range(0,len(all4)-1):
  90.     omega4 = (all4[k+1]-all4[k])/dt
  91.     allomega4.append(omega4)
  92.  
  93. for i1 in range(0,len(allomega2)-1):
  94.     afar2 = (allomega2[i1+1]-allomega2[i1])/dt
  95.     allafar2.append(afar2)
  96. for j1 in range(0,len(allomega3)-1):
  97.     afar3 = (allomega3[j1+1]-allomega3[j1])/dt
  98.     allafar3.append(afar3)
  99. for k1 in range(0,len(allomega4)-1):
  100.     afar4 = (allomega4[k1+1]-allomega4[k1])/dt
  101.     allafar4.append(afar4)
  102. for c in range(0,len(all5)-1):
  103.     avetheta5 = (all5[c] + all5[c+1])/2
  104.     allavetheta5.append(avetheta5)
  105.  
  106. for d in range(0,len(allavetheta5)-1):
  107.     superavetheta5 = (allavetheta5[d] + allavetheta5[d+1])/2
  108.     allsuperavetheta5.append(superavetheta5)
  109.  
  110.  
  111. fig = plt.figure()
  112. ax1 = fig.add_subplot(111)
  113. ax1.set_title('θ2-θ5')
  114. plt.xlabel('θ5')
  115. plt.ylabel('θ2')
  116. ax1.scatter(allavetheta5,allomega3,c = 'r',marker = 'o')
  117. plt.ylim([-4,2])
  118. plt.legend('x1')
  119. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement