CS 445/645 Fall 2001Parameterizing RotationsRepresenting 3 Rotational DOFsRotation MatrixEuler AnglesSlide 6Gimbal LockSlide 8InterpolationSlide 10Axis-angle NotationSlide 12Axis-angle RotationSlide 14Slide 15Slide 16Slide 17QuaternionSlide 19Slide 20Quaternion ExampleQuaternion InterpolationSlide 23Quaternion CodeRepresentations of CurvesSpecifying CurvesParametric CurvesCubic PolynomialsSlide 29Piecewise Curve SegmentsContinuity of CurvesParametric Cubic CurvesParametric Cubic SplinesCoefficientsSlide 35Slide 36Hermite Cubic SplinesAssignment 4, part 2ReflectionsSlide 40Using Quaternions in Assignment 4 part 2CS 445/645Fall 2001Parameterized Rotations & CurvesParameterizing Rotations•Straightforward in 2D–A scalar, , represents rotation in plane•More complicated in 3D–Three scalars are required to define orientation–Note that three scalars are also required to define position–Objects free to translate and tumble in 3D have 6 degrees of freedom (DOF)Representing 3 Rotational DOFs•3x3 Matrix (9 DOFs)–Rows of matrix define orthogonal axes•Euler Angles (3 DOFs)–Rot x + Rot y + Rot z•Axis-angle (4 DOFs)–Axis of rotation + Rotation amount•Quaternion (4 DOFs)–4 dimensional complex numbersRotation Matrix•9 DOFs must reduce to 3•Rows must be unit length (-3 DOFs)•Rows must be orthogonal (-3 DOFs)•Drifting matrices is very bad–Numerical errors results when trying to gradually rotate matrix by adding derivatives–Resulting matrix may scale / shear–Gram-Schmidt algorithm will re-orthogonalize your matrix•Difficult to interpolate between matricesEuler Angles•(x, y, z) = RzRyRx–Rotate x degrees about x-axis–Rotate y degrees about y-axis–Rotate z degrees about z-axis•Axis order is not defined–(y, z, x), (x, z, y), (z, y, x)… are all legal–Pick oneEuler Angles•Rotations not uniquely defined–ex: (z, x, y) = (90, 45, 45) = (45, 0, -45)takes positive x-axis to (1, 1, 1)–cartesian coordinates are independent of one another, but Euler angles are not•Gimbal Lock–Term derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyroGimbal LockGimbal Lock•Occurs when two axes are aligned•Second and third rotations have effect of transforming earlier rotations–ex: Rot x, Rot y, Rot z•If Rot y = 90 degrees, Rot z == -Rot xInterpolation•Interpolation between two Euler angles is not unique•ex: (x, y, z) rotation–(0, 0, 0) to (180, 0, 0) vs. (0, 0, 0) to (0, 180, 180)–Interpolation about different axes are not independentInterpolationAxis-angle Notation•Define an axis of rotation (x, y, z) and a rotation about that axis, R(, n)•4 degrees of freedom specify 3 rotational degrees of freedom because axis of rotation is constrained to be a unit vectorAxis-angle NotationrRrnrpar = (n.r) nrperp = r – (n.r) nV = n x (r – (n.r) n) = n x rRr = Rrpar + Rrperp= Rrpar + (cos ) rperp + (sin ) V=(n.r) n + cos (r – (n.r)n) + (sin ) n x r= (cos )r + (1 – cos ) n (n.r) + (sin ) n x rAxis-angle Rotationrr’nGiven r – Vector in space to rotate n – Axis in space about which to rotate – The amount about n to rotateSolve r’ – The rotated vectorAxis-angle Rotation•Step 1–Compute rk an extended version of the rotation axis, n–rk = (n ¢ r) rrr’rkAxis-angle Rotation•Compute r? •r? = r – (n ¢ r) nrr’r?Axis-angle Rotation•Compute v, a vector perpendicular to rk and r?•v = rk £ r? •Use v and r? and to compute r’vcos() r? + sin() vr?Axis-angle Notation•No easy way to determine how to concatenate many axis-angle rotations that result in final desired axis-angle rotation•No simple way to interpolate rotationsQuaternion•Remember complex numbers: a + ib–Where i2 = -1•Invented by Sir William Hamilton (1843)–Remember Hamiltonian path from Discrete II?•Quaternion:–Q = a + bi + cj + dk•Where i2 = j2 = k2 = -1 and ij = k and ji = -k–Represented as: q = (s, v) = s + vxi + vyj + vzkQuaternion•Let q1 = (s1, v1) and q2 = (s2, v2)–q1q2 = (s1s2 – v1.v2, s1v2 + s2v1 + v1 x v2)–Conjugate = q1’ = (s, -v)–q1q1’ = s2 + |v|2 = |q|2 = magnitude•If q has unit magnitude–q’ = q-1 (conjugate = inverse)–Define a pure quaternion: p = (0, r), r = unit vector–Rotating p by q•(0, cos2r + (1 – cos2) n (n.r) + sin2 n.r)Quaternion•Continue to represent quaternion as a 4 DOF vector (as in axis-angle)•But use quaternion algebra:–(cos (/2), sin(/2) nx, sin(/2) ny, sin(/2) nz)•Quaternion easily converted into rotation matrix•The product of two unit quaternions is a unit quaternionQuaternion Example•X-roll of –(cos (/2), sin ( /2) (1, 0, 0)) = (0, (1, 0, 0))•Y-roll 0f –(0, (0, 1, 0))•Z-roll of –(0, (0, 0, 1))•Ry () followed by Rz ()–(0, (0, 1, 0) times (0, (0, 0, 1)) = (0, (0, 1, 0) x (0, 0, 1) = (0, (1, 0, 0))Quaternion Interpolation•Biggest advantage of quaternions–Interpolation–Cannot linearly interpolate between two quaternions because it would speed up in middle–Instead, Spherical Linear Interpolation, slerp()–Used by modern video games for third-person perspective–Why?Quaternion Interpolation•Quaternion (white) vs. Euler (black) interpolation•Left images are linear interpolation•Right images are cubic interpolationQuaternion Code•http://www.gamasutra.com/features/programming/19980703/quaternions_01.htm–Registration required•Camera control code–http://www.xmission.com/~nate/smooth.html•File, gltb.c•gltbMatrix and gltbMotionRepresentations of Curves•Problems with series of points used to model a curve–Piecewise linear - Does not accurately model a smooth line–It’s tedious–Expensive to manipulate curve because all points must be repositioned•Instead, model curve as piecewise-polynomial–x = x(t), y = y(t), z = z(t) •where x(), y(), z() are polynomialsSpecifying Curves•Control Points–A set of points that influence the curve’s shape•Knots–Control points that lie on the curve•Interpolating Splines–Curves that pass through the control points (knots)•Approximating Splines–Control points merely influence shapeParametric Curves•Very flexible representation•They are not required to be functions–They can be multivalued with respect to any dimension•Decouples dimension of object from dimension of
View Full Document