PDA

View Full Version : Rotation around arbitrary axis

Lord Chaos
04-27-2000, 01:25 AM
For a rotation around an arbitrary axis (x,y,z), how can I calculate the corresponding rotations around the unit vectors (1,0,0) (0,1,0) and (0,0,1)?

Sjonny
04-27-2000, 01:36 AM
My guess is that you first glTransform to x,y,z and then glRotate(x_angle, 1, 0, 0), glRotate(y_angle, 0, 1, 0) and guess the z http://www.opengl.org/discussion_boards/ubb/wink.gif

Lord Chaos
04-27-2000, 01:41 AM
That didn't help much http://www.opengl.org/discussion_boards/ubb/smile.gif

The thing is, I know the number of radians to rotate around the (x,y,z) axis, and want to know the corresponding number of radians to rotate around the unit axes.

john
04-27-2000, 03:26 PM
yep. opengl specifies rotations about an arbitary axis as quaternions. at least... i think this is right. i'm sure i'll be told if i'm wrong. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

theres a paper in siggraph '86? or newer than that? about using quaternions in animation. basically, tho', the story is you CAN convert a quaternion to euler angles, although it would probably involve converting it to a rotation matrix and then extracting the euler angles out of that.

i can probably go and find it, if you'd like the formulae, and can't find it on the web. it's around here, someplace. http://www.opengl.org/discussion_boards/ubb/wink.gif

cheers,
John

dmy
04-27-2000, 03:32 PM
if you need to have a matrix that rotates about any axis, i'd suggest to use opengl as a matrix library and create the matrix with glRotate()

instead, if you need a "arbitrary to euler" matrix conversion utility function, take a look here:
http://www.flipcode.com/documents/matrfaq.html

Dolo/\/\ightY

Lord Chaos
04-27-2000, 10:24 PM
Thanks, that page was exactly what I was looking for!