# 681 - Introduction to Computer Graphics Computer Animation Algorithms and Techniques Technical Background Rick Parent Computer Animation Spaces and Transformations Left-handed v. right handed Homogeneous coordinates: 4x4 transformation matrix (TM) Concatenating TMs Basic transformations (TMs) Display pipeline Rick Parent x y z 1 Computer Animation

Displa y Object space to world space (TM) Pipelin World Space Data e World space to eye space (TM) Object Space Data Eye Space Data Image space to display space (TM) Perspective (TM) Clipping Perspective Divide Image Space Data Display Space Data Rick Parent Computer Animation Representing an orientation Example: fixed angles - rotate around global axes

Y Orientation: X P ' Rz () R y ( ) Rx ( ) P Z Rick Parent Computer Animation Working with fixed angles and Rotation Matrices (RMs) Orthonormalizing a RM Y Extracing fixed angles from an orientation

Z Extracing fixed angles from a RM Y X X Z Rick Parent Making a RM from fixed angles Making a RM from transformed unit coordinate system (TUCS) Computer Animation Transformations in pipeline object -> world: often rigid transforms world -> eye: rigid transforms perspective matrix: uses 4th component of homo. coords perspective divide image -> screen: 2D map to screen coordinates Clipping: procedure that considers view frustum

Rick Parent Computer Animation Error considerations Accumulated round-off error - transform data: transform world data by delta RM update RM by delta RM; apply to object data update angle; form RM; apply to object data orthonormalization rotation matrix: orthogonal, unit-length columns iterate update by taking cross product of 2 vectors scale to unit length considerations of scale miles-to-inches can exeed single precision arithmetic Rick Parent Computer Animation Orientation Representation Rotation matrix Fixed angles: rotate about global coordinate system Euler angles: rotate about local coordinate system Axis-angle: arbitrary axis and angle Quaternions: mathematically handy axis-angle 4-tuple

Exponential map: 3-tuple version of quaternions Rick Parent Computer Animation Transformation Matrix a e i m Rick Parent b f j n c g k o

d h l p Computer Animation Transformation Matrix a e i 0 Rick Parent b f j 0 c tx g ty

k tz 0 1 Computer Animation Rotation Matrices 0 0 1 0 cos sin 0 sin cos 0 0 0 0 0 0 1 cos

0 sin 0 0 0 0 1 0 sin 1 0 0 cos 0 0 cos sin sin cos 0 0 0

0 Rick Parent 0 0 1 0 0 0 0 1 Computer Animation Y Fixed Angles X Z

P' Rz () R y ( ) Rx ( ) P Fixed order: e.g., x, y, z; also could be x, y, x Global axes Rick Parent Computer Animation Gimbal Lock 0 0 0 Fixed angle: e.g., x, y, z 0 90 0 Y Y X

X Z Rick Parent Z Computer Animation Gimbal Lock 0 Fixed order of rotations: x, y, z 90 0 What do these epsilon rotations do? Y 0 90 0 90 0

0 X 0 90 0 Z Rick Parent Computer Animation Gimbal Lock 0 90 0 90 0 90 Y Y

X X Z Z Interpolating FA representations does not produce intuitive rotation because of gimbal lock Rick Parent Computer Animation Euler Angles Y X Prescribed order: e.g., x, y, z or x, y, x

Rotate around (rotated) local axes Z Note: fixed angles are same as Euler angles in reverse order and vice versa Rick Parent P' Rx ( ) R y ( ) Rz () P Computer Animation Axis-Angle A x Y Q A

y X z Z Rotate about given axis Eulers Rotation Theorem OpenGL Fairly easy to interpolate between orientations Difficult to concatenate rotations Rick Parent Computer Animation Axis-angle to rotation matrix Y Q A X Z

Rick Parent Concantenate the following: Rotate A around z to x-z plane Rotate A around y to x-axis Rotate theta around x Undo rotation around y-axis Undo rotation around z-axis Computer Animation Axis-angle to rotation matrix ax ax A a a y x az ax 0 * A a z ay Rot( Rick Parent

x y ax a y ayay az a y az 0 ax z ) ax az a y az a z az ay ax 0 Y A Q

P X P Z A cos( )( I A ) sin( ) A* Computer Animation Quaternion Rot A Y cos sin( ) * A 2 2

Q A X Same as axis-angle, but different form Still rotate about given axis Mathematically convenient form s q Rick Parent v Z Note: in this form v is a scaled version of the given axis of rotation, A Computer Animation Quaternion Arithmetic Addition s1 s2

v1 v2 s1 v1 s2 v2 Multiplication q1q2 s1s2 v1 v2 Inner Product Length Rick Parent s2 v1 s1v2 v1 v2 q1 q2 s1s2 v1 v2 q q q Computer Animation Quaternion Arithmetic Inverse 1 q 1

q 2 s qq 1 q 1q 1 pq Unit quaternion Rick Parent 1 1 v 0 q p q 0 0

1 q q Computer Animation Quaternion Represention Vector Transform Rick Parent 0 v v' Rot q (v) qvq 1 Computer Animation Quaternion Geometric Operations Rot q (v) Rot q (v)

Rotq (v) Rot kq (v) v Rotq ( Rot p (v)) Rotqp (v) 1 1 v Rotq 1 ( Rotq (v)) q (qvq )q v Rick Parent Computer Animation Unit Quaternion Conversions Rot s x z y 1 2 y 2 2 z 2 2 xy 2sz 2 xz 2 sy

2 2 2 xy 2 sz 1 2x 2z 2 yz 2sx 2 2 2 xz 2sy 2 yz 2 sx 1 2 x 2 y Axis-Angle

Rick Parent 2 cos 1 ( s ) ( x, y, z ) v / v Computer Animation Quaternions Avoid gimbal lock Easy to rotate a point Easy to convert to a rotation matrix Easy to concatenate quaternion multiply Easy to interpolate interpolate 4-tuples How about smoothly (in both space and time) interpolate? Rick Parent Computer Animation