Rendering Pipeline real camera photo Photographic Photography: Another look at rotation scene (captures processing print light) processing Quaternions camera Computer 3D tone synthetic model Graphics: models image reproduction (focuses simulated lighting) Coordinate Transformations Coordinate Transformation How to specify placement of individual Transformation Matrix objects into a scene x m m m m x � � � � � � w 11 12 13 14 o Two coordinate systems � � � � � � y m m m m y w 21 22 23 24 o � � � � � � Object coordinate system = � z m m m m z � � � � � � World coordinate system w 31 32 33 34 o � � � � � � m m m m 1 1 � � � � � � 41 42 43 44 { { 1 4 4 4 4 2 4 4 4 4 3 world object transforma tion Coordinate Transformation Problem in animation Rotation Transformation is a function of time May need to interpolate cos sin 0 0 1 0 0 0 � � � � � � � How to represent a given orientation � � � � sin cos 0 0 0 cos sin 0 � � � � � � � R ( ) � � R ( ) � = � = z x 0 0 1 0 0 sin cos 0 � � � � � � � � � � 0 0 0 1 0 0 0 1 � � � � cos 0 sin 0 � � � � � � 0 1 0 0 R ( ) � � � = y sin 0 cos 0 � � � � � � � 0 0 0 1 � � 1
6. Straight ahead action and Pose-to-pose The idea behind keyframing action The two main approaches to hand drawn Animator provides position/orientation animation. at key points in time Straight ahead action System calculates position/orientation “the animator works straight ahead from his first drawing in the scene.” for frames between keys using Pose-to-pose (keyframing) interpolation. the animator plans his actions, figures out just what drawings will be needed to animate the business, makes the drawings concentrating on the poses, ... and then draws the inbetweens.” Link Transformation matrix Transformation matrix translation Can we use as a standard for x m m m m x � � � � � � 11 12 13 14 w o interpolation? � � � � � � y m m m m y Can we interpolate transformation w 21 22 23 24 o � � � � � � = � matrices, element by element, to get z m m m m z � � � � � � 31 32 33 34 w o orientation between keys? � � � � � � 1 m m m m 1 � � � � � � { 41 42 43 44 { 1 4 4 4 4 2 4 4 4 4 3 world object transforma tion rotation Transformation matrix Rotation matrix Can we use as a standard for Rotation matrix factoids: interpolation? Rotation matrices are orthogonal Survey says: NO M -1 = M T MM T = I Interpolated values may not be valid det (M) = 1 transformation matrix When interpolating, resulting matrices Note: problem is with rotation, not translation may not have these properties 2
Transformation matrix Fixed Angle / Euler angles Consider the following Angles used to rotate around fixed axes Fixed order of rotation is implied 0 0 1 0 0 1 0 0 0 � � � � � � � E.g. x-y-z (First x, then y, then z) � � � � � � 0 1 0 0 1 0 0 1 0 Any ordering will do as long as you’re consistent. � � � � � � 1 0 0 1 0 0 0 0 0 � � � � � � � � � � � � � Given by a triplet Start with 90 End with -90 Interpolated E.g. (10, 45, 90) degree y-axis degree y-axis matrix halfway How many degrees of freedom now? rotation rotation Coordinate Transformation Euler Angles Beware: Transformation is not communitive Fixed angle situation where angles of rotation are the x, y, z axis with respect Order of Fixed Angles is important to the object coordinate system. R T S R R S R T � � � � � � � y x y x Fixed Angle / Euler angles Fixed Angle / Euler angles Can we use as a standard for Can we use as a standard for interpolation? interpolation? Survey says: NO Interpolated values are indeed valid, however… Let’s go to the video tape. Interpolated values may seem unnatural Plus….the dreaded gimbal lock! 3
Fixed Angle / Euler angles Fixed Angle / Euler Angle This is a gimble Gimbal lock Gimbal lock is the phenomenon of Used for aircraft two rotational axis of an object navigation pointing in the same direction. Easily achieved by rotating about an axis Gimble lock was almost 90 degrees a deadly problem in Loss of one degree of freedom Apollo 11. (link) Link Angle / Axis Angle / Axis Euler’s Rotation Theorem Interpolating One orientation can be derived from From (A 1 , θ 1 ) to (A 2 , θ 2 ) another by a single rotation about an axis. Intermediate axis can be determined by Define an orientation by a 4-tuple rotating from one axis to the next. Intermediate angle can be simply (x, y, z, θ ) - rotate θ around the axis interpolated. (x,y,z) Angle / Axis Angle / Axis 1. Interpolate axis Problem with angle/axis Α 1 from A1 to A2 Rotate θ 1 axis about A1 x A2 to Α Interpolates fine but… get A Y θ Can’t concatenate rotations. A1 x A2 2. Interpolate angle from θ 2 θ 1 to θ 2 to get θ To fix this…enter the Quaternion. Z X 3. Rotate object by θ around A 4
Quaternions Quaternions Similar idea to axis/angle Technically, a quaternion is a 3D extension of complex numbers. Define an orientation by a 4-tuple q = w + xi + yj + zk [w, x, y, z] Where w, x, y, and z are all real numbers. Or by a pair And i = j = k = sqrt (-1) [w, v] where w is a scalar and v is a 3d There is an algebra built around this vector. definition. Quaternion math Quaternion math Quaternion multiplication Given 2 quaternions (q 1 * q 2 ) = [w 1 w 2 - v 1 ⋅ v 2, w 1 v 2 + w 2 w 1 + v 1 × v 2 ] q 1 =[w 1 , x 1 , y 1 , z 1 ] = [w 1 , v 1 ] q 2 =[w 2 , x 2 , y 2 , z 2 ] = [w 2 , v 2 ] (q 1 * q 2 ).w = (w 1 w 2 - x 1 x 2 - y 1 y 2 - z 1 z 2 ) Quaternion addition: (q 1 * q 2 ).x = (w 1 x 2 + x 1 w 2 + y 1 z 2 - z 1 y 2 ) (q 1 * q 2 ).y = (w 1 y 2 - x 1 z 2 + y 1 w 2 + z 1 x 2 ) q 1 + q 2 = [w 1 +w 2 , v 1 +v 2 ] (q 1 * q 2 ).z = (w 1 z 2 + x 1 y 2 - y 1 x 2 + z 1 w 2 ) q 1 + q 2 = [w 1 +w 2 , x 1 + x 2 , y 1 + y 2 , z 1 + z 2 ] Note: quaternion multiplication is not commutative. Quaternion math Quaternions and rotation. Magnitide of a quaternion Quaternions essentially encodes the info of an axis/angle rotation ||q 1 || = sqrt (w 1 2 + x 1 2 + y 1 2 + z 1 2 ) Yes, you can (and should) normalize quaternions. R θ , (x,y,z) = [ cos( θ /2), sin ( θ /2) • (x, y, z) ] q [ 1 0 0 0 ] q Identity properties = s v [ ] − 1 q − = 2 q qq 1 1 0 0 0 − [ ] = 5
Quaternions Quaternions To interpolate quaternions A series of rotations can be accomplished by using quaternion Interpolate each element one at a time multiplication Sort of…. More on this when we talk about Rotation by p then by q is the same as interpolation next time rotation by qp Questions. Rotation Quaternions During rendering of a scene, API or Conversions: Quaternion -> Rotation Matrix render will need the 3x3 rotation q = [w, x, y, z] , q normalized portion of the transformation matrix. 1 � 2 y 2 � 2 z 2 � � 2 xy � 2 wz 2 xz + 2 wy � � 1 � 2 x 2 � 2 z 2 Thankfully, there are conversions to and 2 xy + 2 wz 2 yz � 2 wx � � 1 � 2 x 2 � 2 y 2 from quaternions to rotation matrix. � � 2 xz � 2 wy 2 yz + 2 wx � � Quaternions Quaternions Conversions: Rotation Matrix -> Quaternion Other conversions m m m m To/from Euler angles � � m 11 + m 22 + m 33 + 1 11 12 13 14 w = � � 2 m m m m See Shoemake paper on READING LIST � 21 22 23 24 � m m m m m 11 + 1 � 2 w 2 � � 31 32 33 34 x = � � m m m m 2 � � 1 4 41 4 4 4 42 2 4 43 4 4 4 44 3 transforma tion m 22 + 1 � 2 w 2 Questions? y = 2 m 33 + 1 � 2 w 2 z = 2 6
Question Degree of Freedom problem Given an object to be placed / oriented in a 3 objects scene 1 minute animation How does one specify this placement / orientation for each frame 30 frames / second Use translation (x,y,z) and quaternion [w, x, y, z] 30 frames x 60 seconds = 1800 frames How many “parameters” are required? Must define position and orientation of each 7 (7 degrees of freedom/object) = 21 degrees Each controllable parameter is a degree of of freedom freedom 1800 frames x 21 dof = 37800 values Animation Next time Next time “There is no particular mystery in animation…it’s really very simple, and Interpolation schemes like anything that is simple, It is about Assignment #2 the hardest thing in the world to do” Class Web Site: http://www.cs.rit.edu/~jmg/animation -- Bill Tytla, Disney Animator, 1937 Any questions? 7
Recommend
More recommend