Rotating around an arbitrary vector

I did a seach on this site and couldn’t find any decent information on how to do this. Additionally, I used a couple of search engines to try and find useful sites that could point me in the right direction…

And no luck! Anyone have any pointers or know where I might find out more information on the optimal way to do this?


Don’t know about optimal, but the way I’ve been taught is:

  1. Translate the object so that the rotation axis passes through 0,0,0
  2. Rotate object about the x-axis so that the rotation axis is in the x-z plane.
  3. Rotate object about the y-axis so that the rotation axis goes along the z-axis.
  4. Rotate object by as much as you want around the z-axis.
  5. do the inverse of 3,2 and 1.

you use quaternions to rotate around an arbitary vector…

think about it. glRotate(angle, x, y, z); is EXACTLY that: rotate angle degrees around the vextor x, y, z. you can synth euler angles by doing

glRotate(xrot, 1.0, 0.0, 0.0);
glRotate(yrot, 0.0, 1.0, 0.0);
glRotate(zrot, 0.0, 0.0, 1.0);