270 likes | 479 Views
ORIENTATION. Interpolating rotations is difficult. Use Quaternions. Object Representation. Define object in world space Object space data Scale Rotation Translation. Desired operations Interpolation between transformations Concatenation of one transformation after another.
E N D
ORIENTATION Interpolating rotations is difficult Use Quaternions
Object Representation • Define object in world space • Object space data • Scale • Rotation • Translation Desired operations Interpolation between transformations Concatenation of one transformation after another Handle scale, rotation, translation, independently Rotation deserves special attention!
Repeated Rotations: Error Management Task: Rotate an object some Dq every frame Issue: Avoiding accumulated roundoff error
<= repeat <= repeat <= repeat Repeated Rotations: Error Management Method 1 M = create_rotation_matrix(Dq) Object = apply M to Object Method 2 D = create_rotation_matrix(Dq) M create_rotation_matrix(q) M = D M Object = apply M to object Method 3 q = q + Dq M = create_rotation_matrix(q) Object = apply M to object
Orientation Representation orientation
O1 O 1.5 O2 Interpolation
O1 O2 Concatenation
Orientation Representation Rotation Matrix Fixed Angles Euler Angles Axis-Angle Quaternion
c a b 0 d e f 0 g h i 0 0 0 0 1 Rotation Matrices 9 values but 3 degrees of freedom Euler’s rotation theorem: An arbitrary rotation may be described by only three parameters.
0 -1 0 0 0 0 1 0 1 0 0 0 -1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 ?? Rotation Matrices Can’t interpolate rotation matrices -90o z-axis 90o z-axis
Y X Z Fixed Angles 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. E.g., (qz, qy, qx) Q = Rx(qx). Ry(qy). Rz(qz). P
Y Y Z Z X X Fixed Angles Using order z-y-x Orientation represented by (0,90,0) Original orientation Note: left-hand coordinate system
Y Z X Fixed Angles Using order z-y-x Y Z X (45,90,0) Original
Y Z X Gimbal Lock Using order z-y-x From (0,90,0), how can the object change its orientation? What do these do? a) (e,90,0) b) (0,90+e,0) c) (0,90,e)
Y Y Is same as X-axis rotation Z Z X X (0,90,0) (0,90,45) Fixed Angles (0,90,0) (-45,90,0) Changing Z-axis parameter
Fixed Angle Interpolation (0,90,0) to (90,0,90) (0,0,0) (0,90,0) (90,0,90)
Y y Z z x X Euler Angles Ordered triple of rotations about local axes, As with fixed angles, 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.
Y y Z z x X Euler Angles Use (z,y,x) Show that Euler angle ordering is equivalent to reverse ordering in fixed angles …and so has the same problems
Axis-Angle Rotate object by q around A (Ax,Ay,Az,q) A q Y Z X Euler’s rotation theorem: An arbitrary rotation may be described by only three parameters. ?
Axis-Angle Interpolation 1. Interpolate axis from A1 to A2 Rotate axis about A1 x A2 to get A A1 q1 A Y q A2 A1 x A2 2. Interpolate angle from q1 to q2 to get q q2 Z X 3. Rotate object by q around A
Quaternions Has the same information as axis-angle but in a more computational-friendly form q =[s,v] =[s,x,y,z] A q (cos(q/2),sin(q/2)*A)
Quaternions Basic math operations
Quaternions - rotate a point v = (x,y,z) => [0,v]
Composite transformations Rotation by p then by q is the same as rotation by qp (where qp is quaternion q multiplied by quaternion p)
Quaternion Rotation q Unit quaternion => ||q||
Quaternion Interpolation Fixed angles (90,0,90) (0,90,0) quaternions [0.5,0.5,0.5,0.5] [0.7,0.0,0.7,0.0]
Quaternion Interpolation Linearly interpolating fixed angles from (0,90,0) to (90,0,90) Interpolating quaternions from (0.5,0.0,1.0,0.0) to (0.5,0.5,0.5,0.5) using sphereical linear interpolation