Game Development Reference
In-Depth Information
Understanding the camera rotation
To rotate the camera, we need to rotate the up, look, or the right vector. To do this, we
create a matrix describing our rotation and transform the relevant vectors using it.
We will call the rotation around the look vector (or z axis) Roll . The rotation around
the up vector (or y axis) is called Yaw . The rotation around the right vector ( x axis) is
called Pitch . The following is a picture of an aircraft showing Roll , Pitch , and Yaw in
terms of the aircraft's local axes:
Yaw
Roll
Pitch
Most developers use the airplane figure to represent pitch, yaw, and roll, as the terms
are mostly used in flight dynamics.
Using quaternions
We represent our rotations in an orthogonal matrix, whose rows or columns are
orthogonal vectors. We can also represent our 3D rotations using Euler angles.
Euler angles help us define the rotation in the three-dimensional world space using
only three numbers (yaw, roll, and pitch). However, doing the mathematics using
Euler angles results in a problem called gimbal lock when animating objects. So, we
generally use other formats to store object rotations. To understand gimbal lock, let's
look at the preceding image. If the aircraft pitches up 90 degrees, the aircraft and
platform's Yaw axis becomes parallel to the Roll axis, and changes about the yaw can
no longer be compensated for. Well, it is difficult to explain gimbal lock. We would
surely observe one in our game development career if we stick to the matrices to
represent rotations. For instance, when you try to animate the rotation of a player's
arm, you will observe that while incrementing angles along one single plane, the
rotation would stop or start at a different angle at a particular instance. However
for now, we assume that there are gimbal locks. If you want to know more, refer to
http://en.wikipedia.org/wiki/Gimbal_lock .
 
Search WWH ::




Custom Search