A Quaternion consists of four floating-point values that represent a rotation amount. Their primary advantage is that they can calculate smooth rotations with Spherical Linear intERPolation (SLERP). You will need to convert Quaternions into rotation matrices before you can actually rotate a point.
The default constructor, creates a Quaternion with w, x, y and z set to 0.
Copy constructor, creates a Quaternion that's a copy of source.
Returns this Quaternion's conjugate, where x, y and z are all multiplied by -1.
The return value is the quaternion that will rotate this quaternion to quatTwo.
Returns the rotational distance to quatTwo in degrees. quatTwo must be normalized.
Sets this Quaternion to the rotation given by eulerAngles, which should be in degrees.
Sets this Quaternion to the rotation given by yaw, pitch, and roll, which should be in degrees.
Convert this Quaternion into a rotation matrix that we can use to rotate 3D points.
Returns this quaternion's inverse. It's calculated by taking the Quaternion's conjugate and dividing by the normal. Throws an exception if the normal is zero.
Multiplies this Quaternion by second and returns the result. The effect is to rotate this Quaternion by second. This function is non-commutative, so the order of multiplications matter.
Returns the Quaternion's magnitude, which is the square root of the normal. We can use the magnitude to check if the Quaternion needs to be normalized.
Returns the Quaternion's normal, equal to w^2 + x^2 + y^2 + z^2.
Returns the normalized version of this quaternion. After many calculations, Quaternions may eventually need to be normalized due to rounding errors on floating point numbers. You can test if the Quaternion needs normalizing if the magnitude is beyond some threshold away from 1.
Performs Spherical Linear intERPolation (SLERP) between this quaternion and quatTwo. Amount should be a value between zero (returns this quaternion) and 1 (returns quatTwo). If amount were 0.5, slerp would return a Quaternion that's midway between them.
method specifies the type of rotation to produce. It can take one of the following values from the SlerpMethod enumeration:
Q_SHORT We'll use the shortest path. Rotation will be <= 180 degrees. Q_LONG We'll use the longest path. Rotation will be >= 180 degrees. Q_CLOCKWISE The rotation will be clockwise when viewed from above. Q_COUNTER_CLOCKWISE The rotation will be counter-clockwise when viewed from above. Q_USER The quaternions are interpolated exactly as given.
These are the four values making up the Quaternion. They're publicly exposed for convenience.