Originally Posted by Darkness
Two assumptions you have to make:
The axis you are rotating about is unit length and its tail is centered at the origin. The vector you are rotating is not necessarily unit length and is also centered at the origin.
Rotating a vector centered at the origin about some arbitrary direction is the same as rotating a point about some arbtirary direction.
Rotating a point about some arbitrary direction is the same as plotting a polar coordinate about some arbitrary direction.
In general, when you plot a polar coordinate, you must have an orthogonal basis. An orthogonal basis is describe by two vectors P and Q which are perpendicular to each other. P and Q lie on the same plane, and the direction you are rotating about is the normal to this plane. P is sort of like your local 'x' axis, and Q is sort of like your local 'y' axis. To rephrase, P and Q are perpendicular to each other, and also are perpendicular to the direction you are rotating about. The general equation for plotting the polar coordinate (which, should be familiar to you otherwise you may need to study up on your math before doing anything more complex) is:
RotatedPoint = P cos (theta) + Q sin (theta)
The original vector you are rotating is vector W. Vector W has components parallel (in the same direction as) the normal and perpendicular to the normal (remember, the normal is the direction you are rotating W about). The problem is, P and Q must both be perpendicular to the normal. This poses a problem, because vector W has components parallel (in the same direction as) the normal. So, you decompose the vector W into components parallel and perpendicular to the normal, then you plus them into the equation above. Then, to complete it, you just add the parallel component back in (it never would have changed during the rotation).
Vector Parallel = Normal * (W dot Normal) //this bad boy doesn't change
Vector Perpendicular = W - Parallel
Vector P = Perpendicular //This is sort of like the local 'x' axis
EDIT: I had to change the order of this
Vector Q = CrossProduct ( Normal, Perpendicular) //This is sort of like the local 'y' axis
Vector Rotated = (P * cos(theta) + Q * sin(theta) ) + Parallel
It's hard to understand, especially if you don't have an inherent understanding of vector projections.
Also note, this is extremely confusing stuff and you likely won't understand it until you ask me questions. So, ask me questions, even if you think they are stupid questions or whatever.