Révision | 377b57d9391bb098633c0661d001ff71b98f593e (tree) |
---|---|
l'heure | 2012-10-06 00:24:54 |
Auteur | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
Now the code plots the random unit vectors on a sphere.
I also have to be careful about how to import and call the points3D module
from mlab. The syntax to import and call it has slightly changed wrt to my
older scripts with mayavi2.
@@ -5,6 +5,8 @@ | ||
5 | 5 | import sys |
6 | 6 | import string |
7 | 7 | import scipy.linalg as sl |
8 | +from mayavi import mlab | |
9 | + | |
8 | 10 | |
9 | 11 | def random_rot(): |
10 | 12 | theta=s.arccos(1.-2.*s.random.uniform(0.,1.,1)[0])-s.pi/2. |
@@ -57,7 +59,9 @@ | ||
57 | 59 | |
58 | 60 | ############################################################# |
59 | 61 | |
60 | -N_rot=100 | |
62 | +N_rot=4000 | |
63 | + | |
64 | +visualisation=1 | |
61 | 65 | |
62 | 66 | ini_cluster=s.arange(3).reshape((1,3))*1. |
63 | 67 |
@@ -83,6 +87,21 @@ | ||
83 | 87 | |
84 | 88 | n.savetxt("rotated_vectors.dat", rot_vec) |
85 | 89 | |
86 | -#To do: visualize, as a 3D scatterplot in Mayavi, the points on a sphere. | |
90 | +if (visualisation==1): | |
91 | + | |
92 | + | |
93 | + x=rot_vec[:,0] | |
94 | + y=rot_vec[:,1] | |
95 | + z=rot_vec[:,2] | |
96 | + | |
97 | + mlab.clf() | |
98 | + pts=mlab.points3d(x, y, z,color=(0,0,1), scale_factor=.02) | |
99 | + pts2=mlab.points3d(0, 0, 0,color=(1,0,0), scale_factor=2.,\ | |
100 | + resolution=40) | |
101 | + mlab.draw() | |
102 | + mlab.show() | |
103 | + | |
104 | + | |
105 | + | |
87 | 106 | |
88 | 107 | print "So far so good" |