Visualizing Quaternions

Similar documents
Visualizing Quaternions

Part II: OUTLINE. Visualizing Quaternions. Part II: Visualizing Quaternion Geometry. The Spherical Projection Trick: Visualizing unit vectors.

Quaternions and Rotations

CS 445 / 645 Introduction to Computer Graphics. Lecture 21 Representing Rotations

Quaternions and Rotations

12.1 Quaternions and Rotations

Orientation & Quaternions

Quaternions and Rotations

Motivation. Parametric Curves (later Surfaces) Outline. Tangents, Normals, Binormals. Arclength. Advanced Computer Graphics (Fall 2010)

Quaternions and Rotations

Jorg s Graphics Lecture Notes Coordinate Spaces 1

CS354 Computer Graphics Rotations and Quaternions

Visual Recognition: Image Formation

3D Game Engine Programming. Understanding Quaternions. Helping you build your dream game engine. Posted on June 25, 2012 by Jeremiah van Oosten

Aalto CS-C3100 Computer Graphics, Fall 2016

Animation. Keyframe animation. CS4620/5620: Lecture 30. Rigid motion: the simplest deformation. Controlling shape for animation

VISUALIZING QUATERNIONS

Animation. CS 4620 Lecture 32. Cornell CS4620 Fall Kavita Bala

Animation Curves and Splines 2

3D Transformations and Complex Representations. Computer Graphics CMU /15-662, Fall 2016

3D Rotations and Complex Representations. Computer Graphics CMU /15-662, Fall 2017

CS612 - Algorithms in Bioinformatics

Rotations in 3D Graphics and the Gimbal Lock

Quaternions and Exponentials

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Transformations: 2D Transforms

Computer Animation II

Quaternions & Rotation in 3D Space

Animating orientation. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

Fundamentals of Computer Animation

Computer Animation Fundamentals. Animation Methods Keyframing Interpolation Kinematics Inverse Kinematics

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6

Analysis of Euler Angles in a Simple Two-Axis Gimbals Set

Applications of Dual Quaternions in Three Dimensional Transformation and Interpolation

Kinematic Synthesis. October 6, 2015 Mark Plecnik

3D Rotation: more than just a hobby

CS 475 / CS 675 Computer Graphics. Lecture 16 : Interpolation for Animation

Rotation and Orientation: Fundamentals. Perelyaev Sergei VARNA, 2011

Lecture Note 3: Rotational Motion

Rotation parameters for model building and stable parameter inversion in orthorhombic media Cintia Lapilli* and Paul J. Fowler, WesternGeco.

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

Computer Animation. Rick Parent

3D Kinematics. Consists of two parts

Curve Subdivision in SE(2)

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z

Rotation with Quaternions

Inertial Measurement Units II!

Introduction to quaternions. Mathematics. Operations

COMPUTER ANIMATION 3 KEYFRAME ANIMATION, RIGGING, SKINNING AND CHARACTER ANIMATION. Rémi Ronfard, Animation, M2R MOSIG

COMPUTER AIDED ENGINEERING DESIGN (BFF2612)

Inverse Kinematics Programming Assignment

Space Curves of Constant Curvature *

Autonomous Navigation for Flying Robots

CMSC 425: Lecture 6 Affine Transformations and Rotations

Transformations Week 9, Lecture 18

MOTION OF A LINE SEGMENT WHOSE ENDPOINT PATHS HAVE EQUAL ARC LENGTH. Anton GFRERRER 1 1 University of Technology, Graz, Austria

A Practical Parameterization of 2 and 3 Degree of Freedom Rotations

a a= a a =a a 1 =1 Division turned out to be equivalent to multiplication: a b= a b =a 1 b

QUATERNIONS AND ROTATIONS

Tentti/Exam Midterm 2/Välikoe 2, December

Polar Coordinates

2D and 3D Transformations AUI Course Denbigh Starkey

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6. ) is graphed below:

5/27/12. Objectives. Plane Curves and Parametric Equations. Sketch the graph of a curve given by a set of parametric equations.

3D Transformations. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 11

Spline Curves. Spline Curves. Prof. Dr. Hans Hagen Algorithmic Geometry WS 2013/2014 1

Double Integrals, Iterated Integrals, Cross-sections

In this course we will need a set of techniques to represent curves and surfaces in 2-d and 3-d. Some reasons for this include

Background for Surface Integration

Last week. Machiraju/Zhang/Möller/Fuhrmann

CURVES OF CONSTANT WIDTH AND THEIR SHADOWS. Have you ever wondered why a manhole cover is in the shape of a circle? This

Fundamentals of 3D. Lecture 3: Debriefing: Lecture 2 Rigid transformations Quaternions Iterative Closest Point (+Kd-trees)

Rotational Joint Limits in Quaternion Space. Gino van den Bergen Dtecta

Kinematical Animation.

3D Transformations World Window to Viewport Transformation Week 2, Lecture 4

Interpolating/approximating pp gcurves

Reading. Topics in Articulated Animation. Character Representation. Animation. q i. t 1 t 2. Articulated models: Character Models are rich, complex

Graphics and Interaction Transformation geometry and homogeneous coordinates

Animation. CS 4620 Lecture 33. Cornell CS4620 Fall Kavita Bala

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Rotations for N-Dimensional Graphics

Configuration Space. Chapter 2

Quaternion to Euler Angle Conversion for Arbitrary Rotation Sequence Using Geometric Methods

Quaternions & Octonions Made Easy. A Series Illustrating Innovative Forms of the Organization & Exposition of Mathematics by Walter Gottschalk

Quaternions and Dual Coupled Orthogonal Rotations in Four-Space

CS 130 Final. Fall 2015

COMP 558 lecture 19 Nov. 17, 2010

Applications of Triple Integrals

AQA GCSE Further Maths Topic Areas

Game Engineering: 2D

Animation. Animation

Kinematics of Wheeled Robots

MTRX4700 Experimental Robotics

+ i a y )( cosφ + isinφ) ( ) + i( a x. cosφ a y. = a x

Computer Graphics / Animation

Parametric curves. Reading. Curves before computers. Mathematical curve representation. CSE 457 Winter Required:

Sung-Eui Yoon ( 윤성의 )

2D/3D Geometric Transformations and Scene Graphs

Animation. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 4/23/07 1

Know it. Control points. B Spline surfaces. Implicit surfaces

Transcription:

Visualizing Quaternions Andrew J. Hanson Computer Science Department Indiana University Siggraph 25 Tutorial

OUTLINE I: (45min) Twisting Belts, Rolling Balls, and Locking Gimbals: Explaining Rotation Sequences with Quaternions II: (45 min) Quaternion Fields: Curves, Surfaces, and Volumes 2

Part I Twisting Belts, Rolling Balls, and Locking Gimbals Explaining Rotation Sequences with Quaternions 3

Where Did Quaternions Come From?... from the discovery of Complex Numbers: z = x + iy Complex numbers = realization that z 2 + = cannot be solved unless you have an imaginary number with i 2 =. Euler s formula: e iθ = cos θ + i sin θ allows you to do most of 2D geometry. 4

Hamilton The first to ask If you can do 2D geometry with complex numbers, how might you do 3D geometry? was William Rowan Hamilton, circa 84. Sir William Rowan Hamilton 4 August 85 2 September 865 5

Hamilton s epiphany: 6 October 843 An electric circuit seemed to close; and a spark flashed forth... Nor could I resist the impulse unphilosophical as it may have been to cut with a knife on a stone of Brougham Bridge, as we passed it, the fundamental formula with the symbols, i, j, k; namely, i 2 = j 2 = k 2 = ijk = which contains the Solution of the Problem... 6

...at the site of Hamilton s carving The plaque on Broome Bridge in Dublin, Ireland, commemorating the legendary location where Hamilton conceived of the idea of quaternions. (Hamilton apparently misspelled it as Brougham Bridge in his letter.) 7

The Belt Trick Quaternion Geometry in our daily lives Two people hold ends of a belt. Twist the belt either 36 degrees or 72 degrees. Rule: Move belt ends any way you like but do not change orientation of either end. Try to straighten out the belt. 8

36 Degree Belt 36 twist: stays twisted, can change DIRECTION! 9

72 Degree Belt 72 twist: CAN FLATTEN OUT WHOLE BELT!

Rolling Ball Puzzle. Put a ball on a flat table. 2. Place hand flat on top of the ball 3. Make circular rubbing motion, as though polishing the tabletop. 4. Watch a point on the equator of the ball. 5. small clockwise circles equator goes counterclockwise 6. small counterclockwise circles equator goes clockwise

Rolling Ball Scenario Point of Contact motion in plane y axis rotation x axis rotation 2

Gimbal Lock Gimbal Lock occurs when a mechanical or computer system experiences an anomaly due to an (x, y, z)-based orientation control sequence. Mechanical systems cannot avoid all possible gimbal lock situations. Computer orientation interpolation systems can avoid gimbal-lock-related glitches by using quaternion interpolation. 3

Gimbal Lock Apollo Systems Red-painted area = Danger of real Gimbal Lock 4

Mechanical Gimbal Lock: Using x, y, z axes to encode orientation gives singular situations. 5

2D Rotations 2D rotations complex numbers. Why? e iθ (x + iy) = ( x + iy ) x = x cos θ y sin θ y = x sin θ + y cos θ Complex numbers are a subspace of quaternions so exploit 2D rotations to introduce us to quaternions and their geometric meaning. 6

Frames in 2D The tangent and normal to 2D curve move continuously along the curve: N^ T^ θ 7

Frames in 2D The tangent and normal to 2D curve move continuously along the curve: N^ T^ θ 8

Frames in 2D The tangent and normal to 2D curve move continuously along the curve: N^ T^ θ 9

Frame Matrix in 2D This motion is described at each point (or time) by the matrix: R 2 (θ) = [ ˆT ˆN ] = cos θ sin θ sin θ cos θ. 2

The Belt Trick Says: There is a Problem...at least in 3D How do you get cos θ to know about 72 degrees? 2

The Belt Trick Says: There is a Problem...at least in 3D How do you get cos θ to know about 72 degrees? Hmmmmm. cos(θ/2) knows about 72 degrees, right? 22

Half-Angle Transform: A Fix for the Problem? Let a = cos(θ/2), b = sin(θ/2), (i.e., cos θ = a 2 b 2, sin θ = 2ab), and parameterize 2D rotations as: R 2 (a, b) = a2 b 2 2ab 2ab a 2 b 2. where orthonormality implies (a 2 + b 2 ) 2 = which reduces back to a 2 + b 2 =. 23

Frame Evolution in 2D Examine time-evolution of 2D frame (on our way to 3D): First in θ(t) coordinates: [ ˆT ˆN ] = cos θ sin θ sin θ cos θ. Differentiate to find frame equations: ˆT(t) = +κ ˆN ˆN(t) = κˆt, where κ(t) = dθ/dt is the curvature. 24

Frame Evolution in (a, b): The basis (ˆT, ˆN) is nasty Four equations with Three constraints from orthonormality, but just One true degree of freedom. Major Simplification occurs in (a, b) coordinates!! ˆT = 2 aȧ bḃ aḃ + bȧ = 2 a b b a ȧ ḃ 25

Frame Evolution in (a, b): But this formula for ˆT is just κ ˆN, where κ ˆN = κ 2ab a 2 b 2 = κ a b b a b a or κ ˆN = κ a b b a a b 26

2D Quaternion Frames! Rearranging terms, both ˆT and ˆN eqns reduce to ȧ ḃ = 2 κ +κ a b This is the square root of frame equations. 27

2D Quaternions... So one equation in the two quaternion variables (a, b) with the constraint a 2 +b 2 = contains both the frame equations ˆT = +κ ˆN ˆN = κˆt this is much better for computer implementation, etc. 28

Rotation as Complex Multiplication If we let (a + ib) = exp (i θ/2) we see that rotation is complex multiplication! Quaternion Frames in 2D are just complex numbers, with Evolution Eqns = derivative of exp (i θ/2)! 29

Rotation with no matrices! Due to an extremely deep reason in Clifford Algebras, a + ib = e iθ/2 represents rotations more nicely than the matrices R(θ). (a + ib )(a + ib) = e i(θ +θ)/2 = A + ib where if we want the matrix, we write: R(θ )R(θ)=R(θ + θ)= A2 B 2 2AB 2AB A 2 B 2 3

The Algebra of 2D Rotations The algebra corresponding to 2D rotations is easy: just complex multiplication!! (a, b ) (a, b) = (a + ib )(a + ib) = a a b b + i(a b + ab ) = (a a b b, a b + ab ) = (A, B) 2D Rotations are just complex multiplication, and take you around the unit circle! 3

Quaternion Frames In 3D, repeat our trick: take square root of the frame, but now use quaternions: Write down the 3D frame. Write as double-valued quadratic form. Rewrite frame evolution equations linearly in the new variables. 32

The Geometry of 3D Rotations We begin with a basic fact: Euler theorem: every 3D frame can be written as a spinning by θ about a fixed axis ˆn, the eigenvector of the rotation matrix: n ^ θ 33

Quaternion Frames... The Matrix R 3 (θ, ˆn) giving 3D rotation by θ about axis ˆn is : c + (n ) 2 ( c) n n 2 ( c) sn 3 n 3 n ( c) + sn 2 n n 2 ( c) + sn 3 c + (n 2 ) 2 ( c) n 3 n 2 ( c) sn n n 3 ( c) sn 2 n 2 n 3 ( c) + sn c + (n 3 ) 2 ( c) where c = cos θ, s = sin θ, and ˆn ˆn =. 34

Can we find a 72-degree form? Remember 2D: a 2 + b 2 = then substitute c = (a 2 + b 2 ) (a 2 b 2 ) = 2b 2 to find the remarkable expression for R(θ, ˆn): a 2 b 2 + (n ) 2 (2b 2 ) 2b 2 n n 2 2abn 3 2b 2 n 3 n + 2abn 2 2b 2 n n 2 + 2abn 3 a 2 b 2 + (n 2 ) 2 (2b 2 ) 2b 2 n 2 n 3 2abn 2b 2 n 3 n 2abn 2 2b 2 n 2 n 3 + 2abn a 2 b 2 + (n 3 ) 2 (2b 2 ) 35

Rotations and Quadratic Polynomials Remember (n ) 2 + (n 2 ) 2 + (n 3 ) 2 = and a 2 + b 2 = ; letting q = a = cos(θ/2) q = bˆn = ˆn sin(θ/2) We find a matrix R 3 (q) q 2 + q2 q2 2 q2 3 2q q 2 2q q 3 2q q 3 + 2q q 2 2q q 2 + 2q q 3 q 2 q2 + q2 2 q2 3 2q 2 q 3 2q q 2q q 3 2q q 2 2q 2 q 3 + 2q q q 2 q2 q2 2 + q2 3 36

Quaternions and Rotations... HOW does q = (q, q) represent rotations? LOOK at R 3 (θ, ˆn)? = R 3 (q, q, q 2, q 3 ) THEN we can verify that choosing q(θ, ˆn) = (cos θ 2, ˆn sin θ 2 ) makes the R 3 equation an IDENTITY. 37

Quaternions and Rotations... WHAT happens if you do TWO rotations? EXAMINE the action of two rotations R(q )R(q) = R(Q) EXPRESS in quadratic forms in q and LOOK FOR an analog of complex multiplication: 38

Quaternions and Rotations... RESULT: the following multiplication rule q q = Q yields exactly the correct 3 3 rotation matrix R(Q): Q = [ q q ] Q = [ q q ] Q 2 = [ q q ] 2 Q 3 = [ q q ] 3 = q q q q q 2 q 2 q 3 q 3 q q + q q + q 2 q 3 q 3 q 2 q q 2 + q 2 q + q 3 q q q 3 q q 3 + q 3 q + q q 2 q 2 q This is Quaternion Multiplication. 39

Algebra of Quaternions = 3D Rotations! 2D rotation matrices are represented by complex multiplication 3D rotation matrices are represented by quaternion multiplication 4

Algebraic 2D/3D Rotations Therefore in 3D, the 2D complex multiplication (a, b ) (a, b) = (a a b b, a b + ab ) is replaced by 4D quaternion multiplication: q q = (q q q q q 2q 2 q 3q 3, q q + q q + q 2 q 3 q 3 q 2, q q 2 + q 2q + q 3q q q 3, q q 3 + q 3 q + q q 2 q 2 q ) 4

Algebra of Quaternions... The is easier to remember by dividing it into the scalar piece q and the vector piece q: q q = (q q q q, q q + q q + q q) 42

Now we can SEE quaternions! Since (q ) 2 + q q = then q = q q Plot just the 3D vector: q = (q x, q y, q z ) q is KNOWN! Can also use any other triple: the fourth component is dependent. DEMO 43

36 Belt Trick in Quaternion Form - - - - - - 44

72 Belt Trick in Quaternion Form - - - - - - 45

Rolling Ball in Quaternion Form - - qy - - qx qz qz - - - - - - - - qx q q vector-only plot. (q, q x, q z ) plot 46

Gimbal Lock in Quaternion Form Quaternion Plot of the remaining orientation degrees of freedom of R(θ, ˆx) R(φ, ŷ) R(ψ, ẑ) at φ = and φ = π/6 47

Gimbal Lock in Quaternion Form, contd Choosing φ and plotting the remaining orientation degrees in the rotation sequence R(θ, ˆx) R(φ, ŷ) R(ψ, ẑ), we see degrees of freedom decrease from TWO to ONE as φ π/2 48

Quaternion Interpolations Shoemake (Siggraph 85) proposed using quaternions 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 quaternions 49

Interpolating on Spheres General quaternion spherical interpolation employs the SLERP, a constant angular velocity transition between two directions, ˆq and ˆq 2 : ˆq 2 (t) = Slerp(ˆq, ˆq 2, t) = ˆq sin(( t)θ) sin(θ) + ˆq 2 sin(tθ) sin(θ) where cos θ = ˆq ˆq 2. 5

Plane Interpolations In Euclidean space, these three basic cubic splines look like this: 2 2 2.5.5.5 - - - - - - - - - - - - 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. 5

Spherical Interpolations - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bezier Catmull-Rom Uniform B 52

Quaternion Interpolations - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bezier Catmull-Rom Uniform B 53

Exp Form of Quaternion Rotations In Hamilton s notation, we can generalize the 2D equation Just set a + ib = e iθ/2 q = (q, q, q 2, q 3 ) = q + iq + jq 2 + kq 3 = e (I ˆnθ/2) with q = cos(θ/2) and q = ˆn sin(θ/2) and I = (i, j, k), with i 2 = j 2 = k 2 =, and i j = k (cyclic), 54

Key to Quaternion Intuition Fundamental Intuition: We know q = cos(θ/2), q = ˆn sin(θ/2) We also know that any coordinate frame M can be written as M = R(θ, ˆn). Therefore q points exactly along the axis we have to rotate around to go from identity I to M, and the length of q tells us how much to rotate. 55

Summarize Quaternion Properties Unit four-vector. Take q = (q, q, q 2, q 3 ) = (q, q) to obey constraint q q =. Multiplication rule. The quaternion product q and p is q p = (q p q p, q p + p q + q p), or, alternatively, [q p] [q p] [q p] 2 [q p] 3 = q p q p q 2 p 2 q 3 p 3 q p + q p + q 2 p 3 q 3 p 2 q p 2 + q 2 p + q 3 p q p 3 q p 3 + q 3 p + q p 2 q 2 p 56

Quaternion Summary... Rotation Correspondence. The unit quaternions q and q correspond to a single 3D rotation R 3 : q 2 + q2 q2 2 q2 3 2q q 2 2q q 3 2q q 3 + 2q q 2 2q q 2 + 2q q 3 q 2 q2 + q2 2 q2 3 2q 2 q 3 2q q 2q q 3 2q q 2 2q 2 q 3 + 2q q q 2 q2 q2 2 + q2 3 If q = (cos θ 2, ˆn sin θ 2 ), with ˆn a unit 3-vector, ˆn ˆn =. Then R(θ, ˆn) is usual 3D rotation by θ in the plane to ˆn. 57

SUMMARY Quaternions represent 3D frames Quaternion multiplication represents 3D rotation Quaternions are ]fboxpoints on a hypersphere Quaternions paths can be visualized with 3D display Belt Trick, Rolling Ball, and Gimbal Lock can be understood as Quaternion Paths. 58