Sorry, can't find the original thread, but I thought I could help.

> > What is the matrix form of rotation about a vector ?

Firstly, let's understand that to rotate about a vector, you are actually

rotating along the surface of the plane perpendicular to that vector. And

you are implicitly rotating about the origin. The vector can only specify

direction, not position. If you wish to rotate about any arbitrary point,

obviously you need to transform before and after the rotation about the

origin. But in any case this problem is : Rotate about the origin

within the plane perpendicular to (x,y,z). I'm assuming that the point is

actually within that plane. If it's not, then you should find the

simultaneous equation of the plane and the point's projection onto that

plane, to make it so.

Quote:> > For example, I would like to rotate A degree about vector (x,y,z) , what

> > is the matrix to do this ?

> > I do know the matrix form for rotate about x, y or z axis, but I

> > had done my best to think and find the above one, and failed. I think it

> > will not be too difficult. Please help.

There is a matrix to do this, and I don't have it to hand. But it is

derived from the common-sense method -

The vector defines the normal to a plane. You are rotating on the surface

of that plane. So you should transform your point from normal coordinates

into coordinates which transform the (x,y,z) plane into the xy plane (ie

z=0).

Now you have a new two-dimensional coordinate system where the z-axis is

perpendicular to the plane about which you rotate. Note that the

z-dimension of your point must be zero (remember your point is on the

plane about which you are rotating - and if it's not then you need to

handle it separately, or else do the transform outside the rotate as I

suggested.

You then rotate about the z-axis using the conventional 2x2 matrix, then

transform the x and y coordinates back to the original coordinate system

again. Separately, transform your z-coordinate back into normal

coordinates if your point wasn't on the original plane.

I don't know how to optimize this, but I'm sure it would be delightful

fun. When you transform the points, you would shear rather than

calculate the plane equation. All of your calculations would be linear

except for one trig look-up (for the rotation matrix)

This would work in all cases except where the vector about which you want

to rotate is in the xy plane (ie the point is on the z-axis). In that

case, you would map the point onto the yz plane instead.

This sounds rather complex to me, but it's an exercise in visualisation.

Anytime you need to do tricky rotations, just transform until your

coordinate system is much simpler, then rotate, then transform back.

OpenGL would be able to do all of this automatically, of course, with a

series of modelview calls, so you don't need to know the actual matrix

formula - or you can do it yourself on paper if you can understand this

rant.

Richard.