Use of included lwjgl Quaternion class

Started by RiverC, May 21, 2013, 15:19:43

Previous topic - Next topic

RiverC

A quick question. I'm looking to use LWJGL's quaternion class as a way to represent the rotation of objects in my world in a better way than the gimbal system (yaw,pitch,roll) but I'm not sure where to start using the class.

For a quaternion (x,y,z,w) x,y,z represent the axis of rotation and w the angle of rotation about that axis. To use the quaternion for math, these values must be normalized; i.e. the whole vector (x,y,z,w) must have a length of 1. To rotate a point p by this quaternion q I do (q*p*q^-1) and series of rotations can be combined by multiplying them together in reverse order. (i.e. if q1 then q2 then q3, the combination quaternion would be q3*q2*q1.)

When I create a lwjgl Quaternion, does it normalize automatically (i.e. can I do (1,0,0,Math.PI/4) for a 90 degree rotation about the x-axis?) does anyone have a link to some sample code of taking an intended rotation or set of rotations and using LWJGL's Quaternion class to translate the points?

Many thanks.