Game Development Reference
In-Depth Information
Euler
Quaternions
(a)
(b)
(c)
(d)
Fig 2.23 Two planes rotated 1°
around each axis every frame. One
uses the Euler angle to calculate the
other quaternions. (a) Planes begin
aligned, (b) planes remain aligned at
first, (c) once the x angle becomes 90
for the Euler plane its rotations go off
course with respect to the quaternion
plane, and (d) even further in the
simulation.
1°. The plane on the left in Figure 2.23 is rotated using Euler angles and the
other uses quaternions. The movement of the quaternion plane is smoother.
Quaternions are used throughout modern game engines, including Unity, as
they do not suffer from gimbal lock.
For Research
Quaternions
If you are interested in the complex inner workings of quaternions,
check out Visualizing Quaternions by Andrew J. Hanson (2006,
ISBN: 978-0120884001).
Although the rotation value for the transform component of GameObjects
appears as Euler x , y , and z values in the inspector, Unity uses quaternions for
storing orientations. The most used quaternion functions are LookRotation() ,
Angle() , and Slerp() .
LookRotation() given a vector will calculate the equivalent quaternion to turn
an object to look alone the original vector. This means this.transform
.rotation = Quaternion.LookRotation(target.position - this
.transform.position) achieves the same result as this.transform
.LookAt(target.transform.position ).
Search Nedrilad ::




Custom Search