Eric Weeks - personal pages - software

# Software for doing simple rotations of 3-D data

weeks@physics.emory.edu

This is a very simplistic way to rotate data in 3-D.

To use the software, you can either specify the filename or pipe the data into the program:

cat datafile | rotate > datafile.rot

or

rotate datafile > datafile.rot

The program does a rotation theta around the Y-axis, then a rotate phi around the (current) X-axis, finally a rotation eta around the (current) Z-axis. The origin is taken to be the center of the data, although this can be changed with the -C option. By default, the output also contains data points which are a large rectangular box drawn around the data. This can be turned off with the -B option.

Command line options:

-h : a help message listing these options
-t # : change theta (degrees)
-p # : change phi (degrees)
-r # : change eta (degrees)
-C : do NOT rotate around the center of mass
-B : do NOT draw a box around the data
-s # : change the spacing of box points

To make this picture, I typed:

rotate -s 60 -t 15 -p 40 sphere.dat | sort -n +2 -3 | psdraw -zOc0.1 -X -1.5 1.5 -1.5 1.5 -Z 0 0 255 > sphere.ps

To make the file sphere.dat, I used a gawk script:

gawk 'BEGIN { for (t=0;t<180;t++) { theta = t/180*3.14159; for (p=0;p<360;p+=30) { phi = p/180*3.14159; print sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta); } } for (t=0;t<180;t+=30) { theta = t/180*3.14159; for (p=0;p<360;p++) { phi = p/180*3.14159; print sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta); } } }' > sphere.dat