Eric Weeks - personal pages - software

Software for doing simple rotations of 3-D data

[home] [research]
[software] [pics]
[misc/links] [about me]

weeks@physics.emory.edu

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

Click here to download software. To compile, use "cc -o rotate rotate.c -lm".

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

If you have questions, please send me email (email address below)

The graph was made with a program I wrote, psdraw. This program is public domain. The program makes PostScript output which I then converted to GIF.

Some links...


Current address:
Eric R. Weeks
weeks@physics.emory.edu
Department of Physics
Emory University
Atlanta, GA 30322-2430