From: "David Hartley" Subject: Re: (3D) - Rotating a point about an axis Date: Fri, 14 Jan 2000 20:34:13 -0000 Newsgroups: sci.math Summary: [missing] Hi If I understand your problem correctly you want to rotate a point (a,b,c) about an axis that passes through the point (d,e,f) and the origin, by an angle g? If this is the case it can be done really easily using a 3x3 rotation matrix, ie the 9 element matrix you mention with elements similar to [cos(g) -sin(g) 0 sin(g) cos(g) 0 0 0 0]. Any rotation matrix, when applied to a point written as a vector ie (a,b,c), rotates that point about a particular axis in space that passes through the origin by a particular angle. To form the rotation matrix all you have to do is determine the direction of the axis of rotation and the angle of rotation. You already have the angle (g) so you just need to find the axis. The axis of rotation in your case is very simple, it is just the position vector of the point (d,e,f) divided by its magnitude, ie a unit vector in the direction of the point (d,e,f). You can calculate this axis if you wish by taking the scalar product of (d,e,f) with itself (Look for this in any elementary maths book if you need to). This is nice when it comes to programming it. The rotation matrix is then formed by using whats known as Rodrigues' equation which is R=I+sin(g)*u+(1-cos(g))*u*u where R is the rotation matrix you want, I is the 3x3 identity matrix [1,0,0 0,1,0 0,0,1] g is your angle of rotation, and u is the axis of rotation written as a skew symmetric matrix. Don't worry, this is simply of the form u=[0,-z,y z,0,-x -y,x,0] where x is the x-component of the axis of rotation, y is the y-component and z is the z-component. Voila!! You have your rotation matrix. All you need to do now is premultiply your vector (a,b,c) by it and you can find the position your rotated point. There is one thing you should be aware of. A rotation matrix only works if you are rotating your point about an axis that passes through the origin. It won't work if your axis doesn't pass through the origin. In those cases you have to translate the origin to a point on the axis of rotation, then rotate the point, and finally translate the origin back again. This is more complicated but I can show if you want. Given a rotation matrix I can also extract the associated angle and axis of rotation if you need it (ie the inverse process to what is described above). Hope this helps David