Joints =

Rotational DOFs are widely used in character animation

3 translational DOFs

3D orientation 48 rotational DOFs

Each joint can have up to 3 DOFs

1 DOF: knee 2 DOF: wrist 3 DOF: arm

representation of Orientation Translation

+ 1 0 0 Homogeneous coordinates (review) x tx tx x  +   0 1 0    y ty = ty y  z + tz   0 0 1 tz   z  Treat all transformations the same so that they can be easily       combined  1   0 0 0 1   1 

4X4 used to represent translation, scaling, and translation x new point old point a point in the space is represented as  y  p = matrix  z     1  Scaling Rotation

x! 1 0 0 0 x  y!   0 cos θ − sin θ 0   y  ! =  z   0 sin θ cos θ 0   z  X axis 0 0 0       sxx sx x  1   0 0 0 1   1     0 0 0    syy = sy y  szz   0 0 sz 0   z  !       x cos θ 0 sin θ 0 x  1   0 0 0 1   1   y!   0 1 0 0   y  ! =  z   − sin θ 0 cos θ 0   z  Y axis        1   0 0 0 1   1  new point scaling matrix old point x! cos θ − sin θ 0 0 x  y!   sin θ cos θ 0 0   y  ! =  z   0 0 1 0   z  Z axis        1   0 0 0 1   1 

Composite transformations Interpolation

h0 x0 y0 z0 θ0 φ0 σ0

θ1 φ1σ1 A series of transformations on an h1 object can be applied as a series of matrix multiplications In order to “move things”, we need both translation θ2 and rotation

h2 p: position in the global coordinate Interpolation the translation is easy, but what about p x: position in the local coordinate θ3 φ3 rotations? (h3, 0, 0) h3

p = T(x0, y0, z0)R(θ0)R(φ0)R(σ0)T(0, h0, 0)R(θ1)R(φ1)R(σ1)T(0, h1, 0)R(θ2)T(0, h2, 0)R(θ3)R(φ3)x Interpolation of orientation Interpolation of orientation

Example: interpolate linearly from a positive 90 degree rotation How about interpolating each entry of the rotation about y axis to a negative 90 degree rotation about y matrix? 0 0 1 0 0 0 −1 0  0 1 0 0   0 1 0 0   −1 0 0 0   1 0 0 0  The interpolated matrix might no longer be      0 0 0 1   0 0 0 1  orthonormal, leading to nonsense for the in- between rotations Linearly interpolate each 0 0 0 0   component and halfway 0 1 0 0  0 0 0 0    between, you get this...  0 0 0 1 

Other representations Fixed angle

Fixed Angle Angles used to rotate about fixed axes Euler angle Orientations are specified by a set of 3 ordered Axis angle parameters that represent 3 ordered rotations about fixed axes Many possible orderings Exponential map Fixed angle Euler angle

A rotation of 10, 45, 90 would be written as Same as fixed angles, except now the axes move with the object Rz(90)Ry(45)Rx(10) since we first rotate about x, y, and then z axis An Euler angle is a rotation about a single Cartesian We can apply this rotation to a vector v: axis

Rz(90)Ry(45)Rx(10)v Create multi-DOF rotations by concatenating

evaluate each axis independently in a set order

Properties of Euler angle Properties of Euler angle

Euler angle rotations about moving axes written in reverse order are the same as the fixed axis rotations Several tasks are easy to do with Euler angles

joint limits Ex(10)Ey(45)Ez(90) = Rz(90)Ry(45)Rx(10) Euclidean interpolation

But problem of singularities occurs when two axes of rotation line up Lock Gimbal lock

When two rotational axis of an object pointing in the same A Gimbal is a hardware direction, the rotation ends up losing one degree of implementation of Euler angles freedom used for mounting gyroscopes or expensive globes

Gimbal lock is a basic problem with representing 3D rotation using Euler angles or fixed angles

Axis angle Properties of axis angle

Represent orientation as a vector and a scalar

vector is the axis to rotate about Can avoid Gimbal lock. Why? scalar is the angle to rotate by Can interpolate the vector and the scalar separately.

y (A1, !1) How?

z x Axis angle interpolation Properties of axis angle

B = A1 × A2 (A , ) y (A , ! ) 2 !2 1 1 A1 · A2 φ = cos−1 avoid Gimbal lock? !|A1||A2|" interpolate the vector and the scalar separately? z x Ak = RB(kφ)A1 efficiently compose rotations? θk = (1 − k)θ1 + kθ2

quaternion Quaternion math

4 tuple of real numbers: w, x, y, z Unit quaternion |q| = 1

x2 + y2 + z2 + w2 = 1 w x w q =   = scalar Multiplication y ' v ( vector    z  w w w w − v · v   1 2 = 1 2 1 2 ! v1 " ! v2 " ! w1v2 + w2v1 + v1 × v2 " Same information as axis angles but in a different form r q1q2 != q2q1 cos (θ/2) q = θ ! sin (θ/2)r " q1(q2q3) = (q1q2)q3 Quaternion math Quaternion Rotation

y w ∗ w p q∗ = = Conjugate ! v " ! −v " 0 q = p p ∗ ∗ ! " (q ) = q z x

∗ ∗ ∗ (q1q2) = q2q1 cos (θ/2) q∗ If q is a unit quaternion and q = q−1 = ! sin (θ/2)r " Inverse |q|

−1 1 then q q p q results in p rotating about r by θ   −1 0 qq = the unit length quaternion  0     0  proof: see by Shoemaker

Quaternion Rotation Quaternion composition

−1 w 0 w qqpq = ! v " ! p " ! −v " If q 1 and q 2 are unit quaternion w · = p v w − × ! v " ! p p v " the combined rotation of first rotating by q 1 wp · v − v · wp + v · p × v = 0 and then by q 2 is equivalent to = ! w(wp − pv) + (p · v)v + v(wp − p × v) "

q3 = q2 · q1

What about a quaternion product q 1 · q 2 ? Matrix form Quaternion interpolation

θ1 θ1, φ1 θ2 ( ) w (θ2, φ2)  x  q =  y     z  1-angle rotation can be 2-angle rotation can be represented represented by a unit circle by a unit sphere

1 − 2y2 − 2z2 2xy + 2wz 2xz − 2wy 0  2xy − 2wz 1 − 2x2 − 2z2 2yz + 2wx 0  R(q) = 2 2  2xz + 2wy 2yz − 2wx 1 − 2x − 2y 0  Interpolation means moving on n-D sphere    0 0 0 1  Now imagine a 4-D sphere for 3-angle rotation

Quaternion interpolation Quaternion interpolation

Direct linear interpolation does not work Linearly interpolated intermediate points are not Moving between two points on the 4D unit sphere uniformly spaced when projected onto the circle

a unit quaternion at each step - another point on the 4D unit sphere θ move with constant angular velocity along the great circle Spherical linear interpolation (SLERP) between the two points on the 4D unit sphere sin((1 − u)θ) sin(uθ) slerp(q1, q2, u) = q1 + q2 sin θ sin θ

Normalize to regain unit quaternion Quaternion constraints Properties of quaternion

Cone constraint avoid Gimbal lock?

w easily composed?  x  1 − cos θ q = = y2 + z2  y  θ 2    z  interpolate? enforce joint limits?

θ qaxis tan (θ/2) = Twist constraint w

Properties of quaternion Exponential map

avoid Gimbal lock?

easily composed? Represent orientation as a vector

interpolate? direction of the vector is the axis to rotate about magnitude of the vector is the angle to rotate by enforce joint limits? Zero vector represents the identity rotation So what’s bad about Quaternion? Properties of exponential map How to choose a representation?

Choose the best representation for the task No need to re-normalize the parameters input: Euler angles

Fewer DOFs joint limits: Euler angles

Good interpolation behavior interpolation: quaternion or exponential map

Singularities exist but can be avoided compositing: quaternions or orientation matrix rendering: orientation matrix

Summary What’s next?

What is a Gimbal lock?

How does a quaternion rotation avoid Gimbal lock? Physics! How does the interpolation work in each type of rotations?