• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Apr 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import numpy as np
2. import matplotlib.pyplot as plt
3.
4. o1_parent = np.concatenate([[0], np.arange(0,4),
5.     [0], np.arange(5,8),
6.     [0], np.arange(9,12),
7.     [0], np.arange(13,16),
8.     [0], np.arange(17,20)])
9. w_pos = [1,1,1]
10. t_len = 1 # per segment
11. i_len = 1.5
12. m_len = 1.6
13. r_len = 1.4
14. l_len = 0.8
15. t_theta = 3*np.pi/4.
16. i_theta = 5*np.pi/8.
17. m_theta = np.pi/2.
18. r_theta = 3*np.pi/8.
19. l_theta = np.pi/4.
20. jitter_theta = np.pi/12.
21. t_pos_0 = [w_pos[0]+t_len*np.sin(t_theta),w_pos[1]+t_len*np.cos(t_theta),w_pos[2]]
22. t_pos_1 = [t_pos_0[0]+t_len*np.sin(t_theta+jitter_theta),t_pos_0[1]+t_len*np.cos(t_theta+jitter_theta),w_pos[2]]
23. t_pos_2 = [t_pos_1[0]+t_len*np.sin(t_theta),t_pos_1[1]+t_len*np.cos(t_theta),w_pos[2]]
24. t_pos_3 = [t_pos_2[0]+t_len*np.sin(t_theta-jitter_theta),t_pos_2[1]+t_len*np.cos(t_theta-jitter_theta),w_pos[2]]
25. i_pos_0 = [w_pos[0]+i_len*np.sin(i_theta),w_pos[1]+i_len*np.cos(i_theta),w_pos[2]]
26. i_pos_1 = [i_pos_0[0]+i_len*np.sin(i_theta+jitter_theta),i_pos_0[1]+i_len*np.cos(i_theta+jitter_theta),w_pos[2]]
27. i_pos_2 = [i_pos_1[0]+i_len*np.sin(i_theta),i_pos_1[1]+i_len*np.cos(i_theta),w_pos[2]]
28. i_pos_3 = [i_pos_2[0]+i_len*np.sin(i_theta-jitter_theta),i_pos_2[1]+i_len*np.cos(i_theta-jitter_theta),w_pos[2]]
29. m_pos_0 = [w_pos[0]+m_len*np.sin(m_theta),w_pos[1]+m_len*np.cos(m_theta),w_pos[2]]
30. m_pos_1 = [m_pos_0[0]+m_len*np.sin(m_theta+jitter_theta),m_pos_0[1]+m_len*np.cos(m_theta+jitter_theta),w_pos[2]]
31. m_pos_2 = [m_pos_1[0]+m_len*np.sin(m_theta),m_pos_1[1]+m_len*np.cos(m_theta),w_pos[2]]
32. m_pos_3 = [m_pos_2[0]+m_len*np.sin(m_theta-jitter_theta),m_pos_2[1]+m_len*np.cos(m_theta-jitter_theta),w_pos[2]]
33. r_pos_0 = [w_pos[0]+r_len*np.sin(r_theta),w_pos[1]+r_len*np.cos(r_theta),w_pos[2]]
34. r_pos_1 = [r_pos_0[0]+r_len*np.sin(r_theta+jitter_theta),r_pos_0[1]+r_len*np.cos(r_theta+jitter_theta),w_pos[2]]
35. r_pos_2 = [r_pos_1[0]+r_len*np.sin(r_theta),r_pos_1[1]+r_len*np.cos(r_theta),w_pos[2]]
36. r_pos_3 = [r_pos_2[0]+r_len*np.sin(r_theta-jitter_theta),r_pos_2[1]+r_len*np.cos(r_theta-jitter_theta),w_pos[2]]
37. l_pos_0 = [w_pos[0]+l_len*np.sin(l_theta),w_pos[1]+l_len*np.cos(l_theta),w_pos[2]]
38. l_pos_1 = [l_pos_0[0]+l_len*np.sin(l_theta+jitter_theta),l_pos_0[1]+l_len*np.cos(l_theta+jitter_theta),w_pos[2]]
39. l_pos_2 = [l_pos_1[0]+l_len*np.sin(l_theta),l_pos_1[1]+l_len*np.cos(l_theta),w_pos[2]]
40. l_pos_3 = [l_pos_2[0]+l_len*np.sin(l_theta-jitter_theta),l_pos_2[1]+l_len*np.cos(l_theta-jitter_theta),w_pos[2]]
41. t_pos_array = np.vstack([t_pos_0, t_pos_1, t_pos_2, t_pos_3])
42. i_pos_array = np.vstack([i_pos_0, i_pos_1, i_pos_2, i_pos_3])
43. m_pos_array = np.vstack([m_pos_0, m_pos_1, m_pos_2, m_pos_3])
44. r_pos_array = np.vstack([r_pos_0, r_pos_1, r_pos_2, r_pos_3])
45. l_pos_array = np.vstack([l_pos_0, l_pos_1, l_pos_2, l_pos_3])
46. pred_3D = np.vstack([w_pos, t_pos_array, i_pos_array, m_pos_array, r_pos_array, l_pos_array]).T
47.
48. plt.ion()
49. from mpl_toolkits.mplot3d import Axes3D
50. fig = plt.figure()
51. ax = fig.gca(projection='3d')
52. for segment in range(pred_3D.shape[1]):
53.     ax.plot([pred_3D[0,segment], pred_3D[0,o1_parent[segment]]],
54.         [pred_3D[1,segment], pred_3D[1,o1_parent[segment]]],
55.         [pred_3D[2,segment], pred_3D[2,o1_parent[segment]]])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?