Visualizing Quaternions Part II: Visualizing Quaternion Geometry Andrew J. Hanson Indiana University Part II: OUTLINE The Spherical Projection Trick: Visualizing unit vectors. Quaternion Frames Quaternion Curves Quaternion Splines The Geometry of Quaternions Recall (a; b) with a + b = is a unit-length complex number or a point on the unit circle S. (a a-b b, a b+ab ) θ + θ (a, b ) (a,b) θ / θ/ (,) The Geometry of Quaternions... Similarly, = ( ; ~) with + ~ = is a unit-length uaternion or a point on the unit 3- sphere S 3. 3 4 The Geometry of Quaternions... Rotations combine by taking the uaternion product of the geometric values of 4D points on S 3 : Visualizing a Quaternion?? Learn how to Visualize a uaternion by starting with a visualization of a point on S, the circle: r =, ( ) * (, ) (,) (unseen) (, ) cos θ θ (seen) ^n sin θ 5 6
Visualizing a Quaternion??... Demo: D Unit Vector Projection Next, visualize a point on S, the ordinary sphere using only the projection ~: r =, ( ), ( ) 7 8 Visualizing a Quaternion??... Demo: 3D Unit Vector Projection Finally, visualize a point on S 3, the uaternion space: DISPLAY only ~, but INFER r =, ( ), ( ), ( 3) 9 Visualize Quaternion Rotations Demo: 4D Unit Vector Projection Each 4D uaternion point = (cos ; ^n sin ) is a frame a33rotation matrix generated by applying R(;^n) to the identity frame. Identity Matrix is the uaternion = (; ; ; ). Visualize using only the VECTOR part ~, so Identity is the zero vector.
Visualize Quaternion Rotations... The uaternion rotation by about ^n: = ( ; ) = (cos(=); ^n sin(=)) represents the matrix R(;^n). Action of rotating Identity by about ^n: (; ; ; ) gives Vector part: ~ ) ^n sin(=) Quaternion Interpretation Rotation axis is Fundamental 3-vector: We know = cos(=); ~ = ^n sin(=) We also know that any coordinate frame M canbewritten as M = R(; ^n). Therefore ~ points exactly along the axis we have to rotate around to go from identity I to M, and the length of ~ tells us how much to rotate. 3 4 Displaying spherical points Displaying a point on a sphere is ambiguous: N Demo: Growing Quaternion = Rotation about Axis ^ = reuired Euler theorem axis. h -h The same horizontal projection is shared by the North vector (h;~) and the South vector (,h;~). S 5 6 Orbit is Front/Back Line D projection of orbit around sphere has two half circles that line up in D, match at two edge points only in 3D. Projective spherical points Polar Projection removes ambiguity, destroys symmetry: Projection Center the North vector (h;~) and the South vector (,h;~) project to different points on the line. 7 8
Displaying S 3 Displaying S 3... A uaternion point can be displayed in Parallel Projection: so = (h;~) lines up with = (,h;~), Polar projection: so only the north pole projects within the unit sphere, and south pole is at of R 3. (a) (b) (c) (a) Usual vector uaternion point. (b) Orbits through northern and southern hemispheres. (c) Polar projection: north pole at origin, south pole at infinity. 9 Quaternion Curves Represent Families of Frames Each orientation is a 4D point on the 3-sphere representing a uaternion. Demo: Simple Quaternion Curves Thus families of frames, which are really rotation matrices, become curves on the 3-sphere. ) treat these curves just like any other curve... Families of Quaternion Frames,... Example: torus knot and its (twice around) uaternion Frenet frame: Families of Quaternion Frames,... Example: Surface describes two-degree-of-freedom joint - y see: Hanson and Ma, Quaternion Frame Approach to Streamline Visualization, IEEE Trans. on Visualiz. and Comp. Graphics,, No., pp. 64 74 (June, 995). 3 - - - z - y - x Remark: Group theory demands that x and y rotations combine to give some z rotation! x - 4 z
Interpolating on Spheres Quaternion Interpolations Shoemake (Siggraph 85) proposed using uaternions instead of Euler angles to get smooth frame interpolations without Gimbal Lock: BEST CHOICE: Animate objects and cameras using rotations represented on S 3 by uaternions N-dimensional spherical interpolation employs the SLERP, a constant angular velocity transition between two directions, ^n and ^n : ^n (t) = Slerp(^n ; ^n ; t) sin((, t)) sin(t) = ^n + ^n sin() sin() where cos = ^n ^n. 5 6 Quaternion Interpolations Many variations have been proposed since then; simplest is Remark on Spherical Interpolation (The SLERP formula is simply the result of applying a Gram- Schmidt decomposition to the two vectors while enforcing unit norm in any dimension.) simply to apply the formula iteratively to give analog of the de Casteljau spline construction: final point 34 34 3 3 3 34 4 7 8 Spline Families Spline Families... Schlag (in Graphics Gems II (99)) gives recursive form for several cubic splines: S(x ; x ; x 3 ; x 4 ; t) = L(L(L(x ; x ; f (t)); L(x ; x 3 ; f 3 (t)); f 3 (t)); L(L(x ; x 3 ; f 3 (t)); L(x 3 ; x 4 ; f 34 (t)); f 34 (t)); f(t)) For Euclidean space, the interpolator is L(a; b; t) = a(, t) + bt while for Spherical space, the interpolator is sin((, t)) L(a; b; t) = a + b sin(t) sin sin where a b = cos. 9 3
Spline Families... Catmull-Rom Spline Families... Bezier f = t + f 3 = t f 34 = t, f 3 = (t+) f 34 = t f = t f = t f 3 = t f 34 = t f 3 = t f 34 = t f = t 3 3 Plane Interpolations Spline Families... Uniform B-spline In Euclidean space, these three basic cubic splines look like this:.5.5.5 f = (t+) 3 f 3 = (t+) 3 f 34 = t 3 f 3 = (t+) f 34 = t f = t 33 - - - - - Bezier Catmull-Rom Uniform B The differences are in the derivatives: Bezier has to start matching all over at every fourth point; Catmull-Rom matches the first derivative; and B-spline is the cadillac, matching all derivatives but no control points. - 34 Spherical Interpolations Quaternion Interpolations - - - - - - - - - - - - - - - - - - Bezier Catmull-Rom Uniform B Bezier Catmull-Rom Uniform B 35 36
Optional: Exponential Quaternion Map Exponential map (Kim, Kim, and Shin; see also Grassia) has these advantages: Demo: Interpolated Keyframe Quaternion Curves 37 Derivative Computation Simpler. Initial velocity conditions work. Derivative Matching Simpler. Easier to match neighboring derivatives. No Renormalization Re d. 4vars, 3DOF) 3 independent vars, constraints automatic. 38 Exponential Quaternion Map... METHOD: use only three vector degrees of freedom ~n = ^n =: exponentiating gives four-component uaternion obeying unit 3-sphere constraint: (~n) = e (I^n =) = (cos(=); ^n sin(=)) Note (Grassia): the uaternion frame evolution euations can be then be written directly in terms of the 3-vector ~n! Exponential Quaternion Map... Then, using logarithms of uaternion control points, e.g., ~n = log =! jj = cos, ( ) jj where ~n is not normalized, we can use splines in the reduced Euclidean 3D space. 39 4 Exponential Quaternion Map... The trick: Wherever you would see x + t(x, x ) in a Euclidean spline, replace (x, x ) by! = log(( ), ) (This is easy: uaternion multiplication gives a new Q = (Q ; Q), and! = log Q is computed as usual.) Exponential Quaternion Map... Then, with! i = log(( i,), i ),let k Y (t) = exp(! i i (t)) i= ) Euclidean spline i (t) methods can be used, and derivative computations are simplified. 4 4
Exponential Quaternion Map... Example of a many-control-point Catmull-Rom spline done using the exponential method: - Even More Quaternion Interpolations... A number of other approaches can be found in the bibliography. Other literature includes: Barr et al. Global optimization emulating vanishing 4th derivative of Euclidean cubic splines, but on uaternion three-sphere. - - Jüttler et al.: Generalized rational splines, including uaternion component as well as a spatial component. 43 44 SUMMARY The Spherical Projection Trick: unit vectors. Visualizing Quaternion Frames: ^n in uaternion tells how to make frame. Quaternion Curves: are like any other curve; spline applications. 45