Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. def angle_to_chord(radius, angle):
  2. return (2 * radius * np.sin((angle / 57.3) / 2))
  3.  
  4. def to_euclid(xyz):
  5. return (np.sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1] + xyz[2]*xyz[2]))
  6.  
  7.  
  8. radius = 2
  9. angle_list = [57, 143, 160]
  10. des_dist_list = [0, 0, 0]
  11. for idx in range(0,len(angle_list)):
  12. des_dist_list[idx] = angle_to_chord(radius, angle_list[idx])
  13.  
  14. act_dist_list = [0, 0, 0]
  15. qc_list = [q1, q2, q3]
  16. err_dist_list = [0, 0, 0]
  17. unit_vector_list = [[0,0,0],[0,0,0],[0,0,0]]
  18.  
  19. for t in time:
  20.  
  21. q1.broadcast_rel_xyz(qt)
  22. q2.broadcast_rel_xyz(qt)
  23. q3.broadcast_rel_xyz(qt)
  24. for idx in range(0,len(qc_list)):
  25. act_dist_list[idx] = to_euclid(qc_list[idx].calc_neighbour_vector(qc_list[(idx + 1) % len(qc_list)]))
  26.  
  27. for idx in range(0, len(qc_list)):
  28. err_dist_list[idx] = act_dist_list[idx] - des_dist_list[idx]
  29.  
  30. for idx in range(0, len(qc_list)):
  31. unit_vector_list[idx][0] = qc_list[idx].calc_neighbour_vector(qc_list[(idx + 1) % len(qc_list)])[0] / act_dist_list[idx]
  32. unit_vector_list[idx][1] = qc_list[idx].calc_neighbour_vector(qc_list[(idx + 1) % len(qc_list)])[1] / act_dist_list[idx]
  33. unit_vector_list[idx][2] = qc_list[idx].calc_neighbour_vector(qc_list[(idx + 1) % len(qc_list)])[2] / act_dist_list[idx]
  34.  
  35. print("Desired: ", des_dist_list)
  36. print("Actual: ", act_dist_list)
  37. print("Errors: ", err_dist_list)
  38. print("unit_vectors: " , unit_vector_list)
  39.  
  40.  
  41.  
  42. #'''
  43. def broadcast_rel_xyz(self, qt):
  44. self.rel_xyz = qt.xyz - self.xyz
  45. return self.rel_xyz
  46. #'''
  47. #'''
  48. def calc_neighbour_vector(self, qx):
  49. self.neighbour_vector = self.rel_xyz - qx.rel_xyz
  50. return self.neighbour_vector
  51. #'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement