YAHOOOOO - 10 days ago 7

C++ Question

I am writing a 3d vector class for OpenGL. How do I rotate a vector v1 about another vector v2 by an angle A?

Answer

The easiest-to-understand way would be rotating the coordinate axis so that vector v2 aligns with the Z axis, then rotate by A around the Z axis, and rotate back so that the Z axis aligns with v2.

When you have written down the rotation matrices for the three operations, you'll probably notice that you apply three matrices after each other. To reach the same effect, you can multiply the three matrices.