Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCE 641: Computer Graphics Rotation Representation and Interpolation Jinxiang Chai.

Similar presentations


Presentation on theme: "CSCE 641: Computer Graphics Rotation Representation and Interpolation Jinxiang Chai."— Presentation transcript:

1 CSCE 641: Computer Graphics Rotation Representation and Interpolation Jinxiang Chai

2 Joints and Rotation Rotational dofs are widely used in character animation 3 translation dofs 48 rotational dofs 1 dof: knee2 dof: wrist3 dof: shoulder

3 Orientation is described relative to some reference alignment A rotation changes object from one orientation to another Can represent orientation as a rotation from the reference alignment Orientation vs. Rotation

4 Ideal Orientation Format Represent 3 degrees of freedom with minimum number of values Allow concatenations of rotations Math should be simple and efficient –concatenation –interpolation –rotation

5 Outline Rotation matrix Fixed angle and Euler angle Axis angle Quaternion

6 Matrices as Orientation Matrices just fine, right? No… –9 values to interpolate –don’t interpolate well

7 Representation of orientation Homogeneous coordinates (review): –4X4 matrix used to represent translation, scaling, and rotation –a point in the space is represented as –Treat all transformations the same so that they can be easily combined

8 Rotation New pointsrotation matrix old points

9 Interpolation In order to “move things”, we need both translation and rotation Interpolating the translation is easy, but what about rotations?

10 Interpolation of Orientation How about interpolating each entry of the rotation matrix? The interpolated matrix might no longer be orthonormal, leading to nonsense for the inbetween rotations

11 Interpolation of Orientation Example: interpolate linearly from a positive 90 degree rotation about y axis to a negative 90 degree rotation about y Linearly interpolate each component and halfway between, you get this... Rotate about y-axis with 90 Rotate about y-axis with -90

12 Properties of Rotation Matrix Easily composed? Interpolation? Compact representation?

13 Properties of Rotation Matrix Easily composed? yes Interpolation? Compact representation?

14 Properties of Rotation Matrix Easily composed? yes Interpolation? not good Compact representation?

15 Properties of Rotation Matrix Easily composed? yes Interpolation? not good Compact representation? - 9 parameters (only needs 3 parameters)

16 Outline Rotation matrix Fixed angle and Euler angle Axis angle Quaternion

17 Fixed angles Angles are used to rotate about fixed axes Orientations are specified by a set of 3 ordered parameters that represent 3 ordered rotations about fixed axes Many possible orderings: x-y-z, x-y-x,y-x-z - as long as axis does immediately follow itself such as x-x-y

18 E.g., (  z,  y,  x ) X Z Y Q = R x (  x ). R y (  y ). R z (  z ). P Ordered triple of rotations about global axes, any triple can be used that doesn’t immediately repeat an axis, e.g., x-y-z, is fine, so is x- y-x. But x-x-z is not. Fixed angles

19 Euler Angles vs. Fixed Angles One point of clarification Euler angle - rotates around local axes Fixed angle - rotates around world axes Rotations are reversed - x-y-z Euler angles == z-y-x fixed angles

20 Euler angle Interpolation Interpolating each component separately Might have singularity problem –Halfway between (0, 90, 0) & (90, 45, 90) –Interpolate directly, get (45, 67.5, 45) –Desired result is (90, 22.5, 90) (verify this!)

21 Euler angle concatenation Can't just add or multiply components Best way: –Convert to matrices –Multiply matrices –Extract Euler angles from resulting matrix Not cheap

22 Gimbal lock Euler/fixed angles not well-formed Different values can give same rotation Example with z-y-x fixed angles: –( 90, 90, 90 ) = ( 0, 90, 0 )

23 Gimbal lock Euler/fixed angles not well-formed Different values can give same rotation Example with z-y-x fixed angles: –( 90, 90, 90 ) = ( 0, 90, 0 ) z x y

24 Gimbal lock Euler/fixed angles not well-formed Different values can give same rotation Example with z-y-x fixed angles: –( 90, 90, 90 ) = ( 0, 90, 0 ) z x y z x y (90,0,0)

25 Gimbal lock Euler/fixed angles not well-formed Different values can give same rotation Example with z-y-x fixed angles: –( 90, 90, 90 ) = ( 0, 90, 0 ) z x y z x y z x y (90,0,0)(90,90,0)

26 Gimbal lock Euler/fixed angles not well-formed Different values can give same rotation Example with z-y-x Euler angles: –( 90, 90, 90 ) = ( 0, 90, 0 ) z y x z x y z x y z x y (90,0,0)(90,90,0)(90,90,90)

27 Gimbal lock A Gimbal is a hardware implementation of Euler angles used for mounting gyroscopes or expensive globes Gimbal lock is a basic problem with representing 3D rotation using Euler angles or fixed angles

28 Gimbal lock When two rotational axis of an object pointing in the same direction, the rotation ends up losing one degree of freedom

29 Outline Rotation matrix Fixed angle and Euler angle Axis angle Quaternion

30   (A x,A y,A z,  ) Euler’s rotation theorem: An arbitrary rotation may be described by only three parameters. X Y Z Rotate an object by  around A Axis angle

31 Axis-angle rotation r r’ n Given r – Vector in space to rotate n – Unit-length axis in space about which to rotate  – The amount about n to rotate Solve r’ – The rotated vector

32 Axis-angle rotation r r’ r par Compute r par : the projection of r along the n direction r par = (n·r)n

33 Axis-angle rotation r r’ r perp r par Compute r perp : r perp = r-r par

34 Axis-angle rotation r r’ r perp v r par Compute v: a vector perpedicular to r par and r perp : v= r par xr perp

35 Axis-angle rotation r r’ r perp v Use r par, r perp and v, θ to compute the new vector! r par Compute v: a vector perpedicular to r par and r perp : v= r par xr perp

36 Axis-angle rotation r r’ n  r par = (n·r) n r perp = r – (n·r) n V = n x (r – (n·r) n) = n x r r’ = r’ par + r’ perp = r’ par + (cos  ) r perp + (sin  ) V =(n·r) n + cos  (r – (n·r)n) + (sin  ) n x r = (cos  )r + (1 – cos  ) n (n·r) + (sin  ) n x r

37 Axis-angle rotation Can interpolate rotation well

38   1. Interpolate axis from A1 to A2 Rotate axis about A1 x A2 to get A X Y Z   2. Interpolate angle from  1 to  to get  3. Rotate the object by  around A A1 x A2   Axis-angle interpolation

39 Axis-angle rotation Can interpolate rotation well Compact representation Messy to concatenate - might need to convert to matrix form

40 Outline Rotation matrix Fixed angle and Euler angle Axis angle Quaternion

41 Remember complex numbers: a+ib, where i 2 =-1 Quaternions are a non-commutative extension of complex numbers Invented by Sir William Hamilton (1843) Quaternion: - Q = a + bi + cj + dk: where i 2 =j 2 =k 2 =ijk=-1,ij=k,jk=i,ki=j - Represented as: q = (w, v) = w + xi + yj + zk

42 Quaternion 4 tuple of real numbers: w, x, y, z Same information as axis angles but in a more computational-friendly form

43 Quaternion math Unit quaternion Multiplication Associative Non-commutative

44 Quaternion math Conjugate Inverse

45 Quaternion Example let then

46 Quaternion Rotation

47 Quaternion rotation

48 Quaternion Example Rotate a point (1,0,0) about y-axis with -90 degrees z x y (1,0,0) (0,0,1)

49 Quaternion Example Rotate a point (1,0,0) about y-axis with -90 degrees z x y (1,0,0) (0,0,1)

50 Quaternion Example Rotate a point (1,0,0) about y-axis with 90 degrees z x y (1,0,0) (0,0,1) Point (1,0,0)

51 Quaternion Example Rotate a point (1,0,0) about y-axis with 90 degrees z x y (1,0,0) (0,0,1) Point (1,0,0) Quaternion rotation

52 Quaternion Example Rotate a point (1,0,0) about y-axis with 90 degrees z x y (1,0,0) (0,0,1)

53 Quaternion composition Rotation by p then q is the same as rotation by qp

54 Matrix Form For a 3D point (x 0,y 0,z 0 )

55 Quaternion interpolation 1-angle rotation can be represented by a unit circle

56 Quaternion interpolation 1-angle rotation can be represented by a unit circle 2-angle rotation can be represented by a unit sphere

57 Quaternion interpolation Interpolation means moving on n-D sphere Now imagine a 4-D sphere for 3-angle rotation 1-angle rotation can be represented by a unit circle 2-angle rotation can be represented by a unit sphere

58 Quaternion interpolation Moving between two points on the 4D unit Sphere: a unit quaternion at each step - another point on the 4D unit sphere move with constant angular velocity along the great circle between the two points on the 4D unit sphere

59 Quaternion interpolation Direct linear interpolation does not work Linearly interpolated intermediate points are not uniformly spaced when projected onto the circle

60 Quaternion interpolation Spherical linear interpolation (SLERP) Normalize to regain unit quaternion

61 Quaternion interpolation Spherical linear interpolation (SLERP) Normalize to regain unit quaternion

62 Quaternion interpolation Spherical linear interpolation (SLERP) Normalize to regain unit quaternion

63 Quaternions Can interpolate rotation well Compact representation Also easy to concatenate


Download ppt "CSCE 641: Computer Graphics Rotation Representation and Interpolation Jinxiang Chai."

Similar presentations


Ads by Google