Kyle..
>Anyone have the 4X4 rotation matrix for rotation about an arbitrary axis and
>point, (just the axis if need be).
'Fraid not. In two dimensions you rotate about a point,
3d an axis, in 4d a plane. Here are the matrices for
each plane (6 in all). Im not entirely sure about the
signs on some of the sins, didnt get a chance to check.
Well the worst that will happen is that youll rotate
the wrong way.
The code is formatted for tabstops=2 by the way,
so you may need a bit of :%s/ / /g to make it look right
Steve.
-------------------------------------
double rotxy[] =
{
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, cos(theta), sin(theta), 0,
0, 0, -sin(theta),cos(theta), 0,
0, 0, 0, 0, 1,
};
double rotxz[] =
{
1, 0, 0, 0, 0,
0, cos(theta), 0, sin(theta), 0,
0, 0, 1, 0, 0,
0, -sin(theta),0, cos(theta), 0,
0, 0, 0, 0, 1,
};
double rotxw[] =
{
1, 0, 0, 0, 0,
0, cos(theta), sin(theta), 0, 0,
0, -sin(theta),cos(theta), 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1,
};
double rotyz[] =
{
cos(theta), 0, 0, sin(theta), 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
-sin(theta),0, 0, cos(theta), 0,
0, 0, 0, 0, 1,
};
double rotyw[] =
{
cos(theta), 0, sin(theta), 0, 0,
0, 1, 0, 0, 0,
-sin(theta),0, cos(theta), 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1,
};
double rotzw[] =
{
cos(theta), sin(theta), 0, 0, 0,
-sin(theta),cos(theta), 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1,
};
double identity[] =
{
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1,
};
double x[] =
{
100, 100, 100, 100, 1, //0
400, 100, 100, 100, 1,
100, 400, 100, 100, 1,
400, 400, 100, 100, 1,
100, 100, 400, 100, 1, //4
400, 100, 400, 100, 1,
100, 400, 400, 100, 1,
400, 400, 400, 100, 1,
100, 100, 100, 400, 1, //8
400, 100, 100, 400, 1,
100, 400, 100, 400, 1,
400, 400, 100, 400, 1,
100, 100, 400, 400, 1, //12
400, 100, 400, 400, 1,
100, 400, 400, 400, 1,
400, 400, 400, 400, 1,
};
Are you referring to a true 4D rotation or is your 4x4 matrix
for homogeneous coordinates? If true 4D, then rotation is about
a 2D plane, so you need to specify two linearly independent vectors
and an angle of rotation. Code for building a 3x3 rotation given
a direction and angle and for building a 4x4 rotation given two
linearly independent vectors and angle is
ftp://ftp.cs.unc.edu/pub/users/eberly/misc/rotate.c
Dave Eberly
sas...@unx.sas.com
For an executive summary of higher-dimensional rotations, see a
section of my class handout, in
http://www.ecse.rpi.edu/Courses/S96/35475/ho20/node7.html#SECTION00032000000000000000
------------------------
Wm. Randolph Franklin
w...@ecse.rpi.edu
http://www.ecse.rpi.edu/Homepages/wrf/
+1 (518) 276-6077; Fax: -6261
ECSE Dept., 6026 JEC, Rensselaer Polytechnic Inst, Troy NY, 12180 USA