Fundamentals of Computer Animation Orientation and Rotation
Motivation Finding the most natural and compact way to present rotation and orientations Orientation interpolation which result in a natural motion A closed mathematical form that deals with rotation and orientations (expansion for the complex numbers)
Rotation Matrix A general rotation can be represented by a single 3x3 matrix –Length Preserving (Isometric) –Reflection Preserving –Orthonormal
Fixed Angle Representation Angles used to rotate about fixed axes Orientations are specified by a set of 3 ordered parameters that represent 3 ordered rotations about fixed axes, ie. first about x, then y, then z Many possible orderings, don’t have to use all 3 axes, but can’t do the same axis back to back
Fixed Angle Representation A rotation of 10,45, 90 would be written as –Rz(90) Ry(45), Rx(10) since we want to first rotate about x, y, z. It would be applied then to the point P…. RzRyRx P Problem occurs when two of the axes of rotation line up on top of each other. This is called “Gimbal Lock”
Gimbal Lock A 90 degree rotation about the y axis essentially makes the first axis of rotation align with the third. Incremental changes in x,z produce the same results – you’ve lost a degree of freedom
Gimbal Lock Phenomenon of two rotational axis of an object pointing in the same direction. Simply put, it means your object won't rotate how you think it ought to rotate.
Euler Angles A general rotation is a combination of three elementary rotations: around the x-axis (x-roll), around the y-axis (y-roll) and around the z-axis (z- roll).
Euler Angles
Euler Angles and Rotation Matrices
Gimbal Lock (again!) Rotation by 90 o causes a loss of a degree of freedom x y z 11 y z 11 /2 11 x’ y z 33 11 xx
Gimbal Lock Phenomenon of two rotational axis of an object pointing in the same direction. Simply put, it means your object won't rotate how you think it ought to rotate.
Euler angles interpolation z x y π x-roll π y z x y z x z-roll π z x y π z x y π y-roll π R(0,0,0),…,R( t,0,0),…,R( ,0,0) t [0,1] R(0,0,0),…,R(0, t, t),…,R(0, , )
Euler Angles Interpolation Unnatural movement !
Goal Find a parameterization in which –a simple steady rotation exists between two key orientations –moves are independent of the choice of the coordinate system
Angular displacement ( ,n) defines an angular displacement of about an axis n
Angle and Axis Any orientation can be represented by a 4-tuple –angle, vector(x,y,z) where the angle is the amount to rotate by and the vector is the axis to rotate about Can interpolate the angle and axis separately No gimbal lock problems! But, can’t efficiently compose rotations…must convert to matrices first!
Quaternions ? Extend the concept of rotation in 3D to 4D. Avoids the problem of "gimbal-lock" and allows for the implementation of smooth and continuous rotation. In effect, they may be considered to add a additional rotation angle to spherical coordinates ie. Longitude, Latitude and Rotation angles A Quaternion is defined using four floating point values |x y z w|. These are calculated from the combination of the three coordinates of the rotation axis and the rotation angle.
How do quaternions relate to 3D animation? Solution to "Gimbal lock" Instead of rotating an object through a series of successive rotations, a quaternion allows the programmer to rotate an object through a single arbitary rotation axis. Because the rotation axis is specifed as a unit direction vector, it may be calculated through vector mathematics or from spherical coordinates ie (longitude/latitude). Quaternions interpolation : smooth and predictable rotation effects.
Quaternion to Rotation Matrix
Quaternions Definition Extension of complex numbers 4-tuple of real numbers –s,x,y,z or [s,v] –s is a scalar –v is a vector Same information as axis/angle but in a different form Can be viewed as an original orientation ora rotation to apply to an object
Quaternions Math
The conjugate and magnitude are similar to complex numbers Quaternions properties Quaternions are non commutative q 1 = (s 1,v 1 ) q 2 = (s 2,v 2 ) q 1 *q 2 = (s 1 s 2 – v 1. v 2, s 1 v 2 + s 2 v 1 + v 1 x v 2 ) inverse: unit quaternion:
Quaternion Rotation To rotate a vector, v using quaternion math –represent the vector as [0,v] –represent the rotation as a quaternion, q
Quaternions as Rotations Rotation of P=(0,r) about the unit vector n by an angle θ using the unit quaternion q=(s,v) but q=(cos ½ θ, sin ½ θ n) where |n|=1
Quaternions as Rotations Concatenating rotations – rotate using q 1 and then using q 2 is like rotation using q 2 *q 1
Rotations in Reality It’s easiest to express rotations in Euler angles or Axis/angle We can convert to/from any of these representations Choose the best representation for the task –input:Euler angles –interpolation: quaternions –composing rotations: quaternions, orientation matrix