07.01.2013 Views

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Quaternions and spatial rotation 134<br />

Are quaternions handed?<br />

Note that quaternions, like the rotations or other linear transforms, are not "handed" (as in left-handed vs<br />

right-handed). Handedness of a coordinate system comes from the interpretation of the numbers in physical space.<br />

No matter what the handedness convention, rotating the X vector 90 degrees around the Z vector will yield the Y<br />

vector — the mathematics and numbers are the same.<br />

Alternatively, if the quaternion or direction cosine matrix is interpreted as a rotation from one frame to another, then<br />

it must be either left-handed or right-handed. For example, in the above example rotating the X vector 90 degrees<br />

around the Z vector yields the Y vector only if you use the right hand rule. If you use a left hand rule, the result<br />

would be along the negative Y vector. Transformations from quaternion to direction cosine matrix often do not<br />

specify whether the input quaternion should be left handed or right handed. It is possible to determine the<br />

handedness of the algorithm by constructing a simple quaternion from a vector and an angle and assuming right<br />

handedness to begin with. For example, [0.7071, 0, 0, 0.7071 has the axis of rotation along the z-axis, and a rotation<br />

angle of 90 degrees. Pass this quaternion into the quaternion to matrix algorithm. If the end result is as shown below<br />

and you wish to interpret the matrix as right-handed, then the algorithm is expecting a right-handed quaternion. If the<br />

end result is the transpose and you still want to interpret the result as a right-handed matrix, then you must feed the<br />

algorithm left-handed quaternions. To convert between left and right-handed quaternions simply negate the vector<br />

part of the quaternion.<br />

Quaternions and other representations of rotations<br />

Qualitative description of the advantages of quaternions<br />

The representation of a rotation as a quaternion (4 numbers) is more compact than the representation as an<br />

orthogonal matrix (9 numbers). Furthermore, for a given axis and angle, one can easily construct the corresponding<br />

quaternion, and conversely, for a given quaternion one can easily read off the axis and the angle. Both of these are<br />

much harder with matrices or Euler angles.<br />

In computer games and other applications, one is often interested in “smooth rotations”, meaning that the scene<br />

should slowly rotate and not in a single step. This can be accomplished by choosing a curve such as the spherical<br />

linear interpolation in the quaternions, with one endpoint being the identity transformation 1 (or some other initial<br />

rotation) and the other being the intended final rotation. This is more problematic with other representations of<br />

rotations.<br />

When composing several rotations on a computer, rounding errors necessarily accumulate. A quaternion that’s<br />

slightly off still represents a rotation after being normalised— a matrix that’s slightly off may not be orthogonal<br />

anymore and is harder to convert back to a proper orthogonal matrix.<br />

Quaternions also avoid a phenomenon called gimbal lock which can result when, for example in pitch/yaw/roll<br />

rotational systems, the pitch is rotated 90° up or down, so that yaw and roll then correspond to the same motion, and<br />

a degree of freedom of rotation is lost. In a gimbal-based aerospace inertial navigation system, for instance, this<br />

could have disastrous results if the aircraft is in a steep dive or ascent.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!