Game Development Reference
In-Depth Information
( x , y , z )
( ax + by + cz + tx , dx + ey + fz + ty , gx + hy + iz + tz )
Euler angle rotation suffers from a problem that is commonly called
gimbal lock. This problem arises when one axis is mapped to another by
a rotation. Suppose that the heading rotates through 90°, then the x - and
z -axes become aligned to each other. Now
pitch and bank are occurring along the same
axis. Whenever one rotation results in a map-
ping of one axis to another, one degree of
freedom is lost. To avoid this problem, let's
consider another way of describing rotations
which uses four values.
Angle and axis rotation
The values used are an angle
and a vector A
= [ x , y , z ] T that represents the axis of rotation.
When the orientation of the box is described in
this way the rotation matrix is given by:
Figure 1.6 Angle and
axis rotation.
1 + (- z 2 - y 2 )(1 - cos(
))
- z sin(
) + yx (1 - cos(
))
y sin(
) + zx (1 - cos(
))
R =
z sin() + yx (1 - cos())
1 + (- z 2 - x 2 )(1 - cos())
- x sin() + zy (1 - cos())
1 + (- y 2 - z 2 )(1 - cos())
- y sin() + zx (1 - cos())
x sin() + zy (1 - cos())
We can use this rotation matrix in the same way as described for Euler
angles to map vertices in the object to a 3D world space location.
Quaternion rotation
Yet another way to consider an object's orientation uses quaternions.
Devised by W. R. Hamilton in the eighteenth century, quarternions are
used extensively in games because they provide a quick way to
interpolate between orientations. A quaternion uses four values. One
value is a scalar quantity w , and the remaining three values are combined
into a vector v = ( x , y , z ). When using quaternions for rotations they must
be unit quaternions.
If we have a quaternion q = w + x + y + z = [ w , v ], then:
The norm of a quaternion is N ( q )= w 2 + x 2 + y 2 + z 2
=1
A unit quaternion has N ( q )=1
 
Search Nedrilad ::




Custom Search