Section 2
week of September 7
-
Three Dimensional Rotation Matrices
-
Rotation Matrices are orthogonal, so RRT= I, and we decide
that det(R)=+1.
-
We can think of a rotation in many ways:
-
VRML uses rotation by so many radians around an axis (Q:Which direction
is positive. A: Use right hand rule)
-
Euler angles express rotations in terms of rotations around the X, Y,
and
Z axes.
-
The rotation matrix itself.
-
There are some tricks for converting between these:
-
Axis-Angle (a,q) to rotation matrix:
R
= I cos q + (ax) sin q
+ aaT (1 - cos q)
-
Try a=(1/sqrt(3))*(1,1,1) and q=2p/3
to get :
0 0 1
1 0 0
0 1 0
-
Rotation Matrix to Axis-Angle: R-RT= 2(ax) sin q
-
Try to recover a=(1/sqrt(3))*(1,1,1) and q=2p/3
from R.
-
Height Fields (Elevation Grids)
-
Very cool, but only one height for each coord in 2d.
-
Matlab Example
Get on a machine with matlab. Type matlab at the command
line to start. the following commands will give you the heights for
a bumpy mesh as in the professor's example.
>> [X,Y] = meshgrid([-5:5],[-5:5]);
>> Z=sin(14*X+2)+sin(14*Y);
>> fid = fopen('heights.txt','w');
>> fprintf(fid,'%6.3f, ',Z);
heights.txt will contain the height values separated by comma's (plus
an extra comma at the end of the file, you should erase this one).
There will be 11x11 = 121 values in this example. You would insert
these values into the an ElevationGrid node in the height field.
If you need help with Matlab there is a help command. Functions like
rand
are useful, as is surf which can let you preview your surface in
matlab (you have to be on an terminal with the display set correctly, etc.).
-
Sweeps (Extrusions)
-
How the cross section is placed angled at the joints is a little interesting...
Look at the VRML 2.0 node spec linked from the home pages.
aberg@cs.berkeley.edu