Quaternions and Rotations

Similar documents
Quaternions and Rotations

Quaternions and Rotations

Quaternions and Rotations

12.1 Quaternions and Rotations

CS770/870 Spring 2017 Quaternions

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

Quaternions & Rotation in 3D Space

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

CS354 Computer Graphics Rotations and Quaternions

Rotation and Orientation: Fundamentals. Perelyaev Sergei VARNA, 2011

3D Kinematics. Consists of two parts

Visualizing Quaternions

ME 597: AUTONOMOUS MOBILE ROBOTICS SECTION 2 COORDINATE TRANSFORMS. Prof. Steven Waslander

Lecture Note 3: Rotational Motion

Orientation & Quaternions

CS612 - Algorithms in Bioinformatics

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

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

Introduction to quaternions. Mathematics. Operations

Visual Recognition: Image Formation

Fundamentals of Computer Animation

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

3D Rotation: more than just a hobby

Transformations Week 9, Lecture 18

Inertial Measurement Units II!

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

Computer Animation II

3D Transformations. CS 4620 Lecture 10. Cornell CS4620 Fall 2014 Lecture Steve Marschner (with previous instructors James/Bala)

Transformation. Jane Li Assistant Professor Mechanical Engineering & Robotics Engineering

Animation Curves and Splines 2

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

Animation and Quaternions

CS184: Using Quaternions to Represent Rotation

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

Quaternions and Euler Angles

Quaternion properties: addition. Introduction to quaternions. Quaternion properties: multiplication. Derivation of multiplication

Applications of Dual Quaternions in Three Dimensional Transformation and Interpolation

Autonomous Navigation for Flying Robots

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

Aalto CS-C3100 Computer Graphics, Fall 2016

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

CMSC 425: Lecture 6 Affine Transformations and Rotations

Rotation with Quaternions

Quaternions and Exponentials

Quaternion Rotations AUI Course Denbigh Starkey

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

Computer Animation Fundamentals. Animation Methods Keyframing Interpolation Kinematics Inverse Kinematics

1 Historical Notes. Kinematics 5: Quaternions

Jorg s Graphics Lecture Notes Coordinate Spaces 1

Rotations in 3D Graphics and the Gimbal Lock

Fundamentals of Computer Animation

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

IMAGE-BASED RENDERING AND ANIMATION

Transformations: 2D Transforms

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

Chapter 3 : Computer Animation

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

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

Rotations (and other transformations) Rotation as rotation matrix. Storage. Apply to vector matrix vector multiply (15 flops)

Lecture «Robot Dynamics»: Kinematics 2

3.3 Interpolation of rotations represented by quaternions

Transformations. CSCI 420 Computer Graphics Lecture 4

Animations. Hakan Bilen University of Edinburgh. Computer Graphics Fall Some slides are courtesy of Steve Marschner and Kavita Bala

Quaternions. Mike Bailey. A Useful Concept: Spherical Linear Interpolation. sin(1 t) sin t

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

Lab 2A Finding Position and Interpolation with Quaternions

Geometric Transformations

Lecture 22 of 41. Animation 2 of 3: Rotations, Quaternions Dynamics & Kinematics

Lecture 22 of 41. Animation 2 of 3: Rotations, Quaternions Dynamics & Kinematics

Splines & Quaternions (splines.txt) by Jochen Wilhelmy a.k.a. digisnap

Quaternions: From Classical Mechanics to Computer Graphics, and Beyond

Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

Visualizing Quaternions

Comparison of practically applicable mathematical descriptions of orientation and rotation in the three-dimensional Euclidean space

Animation. Traditional Animation Keyframe Animation. Interpolating Rotation Forward/Inverse Kinematics

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

Kinematics and Orientations

CS5620 Intro to Computer Graphics

Kinematical Animation.

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

Mathematics for real-time graphics

EEE 187: Robotics Summary 2

Orientation. Orientation 10/28/15

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

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

Advanced Computer Graphics Transformations. Matthias Teschner

Transformations. CSCI 420 Computer Graphics Lecture 5

Transformations. OpenGL Transformations. 4x4 Model-view Matrix (this lecture) OpenGL Transformation Matrices. 4x4 Projection Matrix (next lecture)

Animation. Animation

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

MTRX4700 Experimental Robotics

VISUALIZING QUATERNIONS

Introduction to Robotics

Transformations. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

A Detailed Look into Forward and Inverse Kinematics

Kinematic Synthesis. October 6, 2015 Mark Plecnik

PSE Game Physics. Session (3) Springs, Ropes, Linear Momentum and Rotations. Oliver Meister, Roland Wittmann

METR 4202: Advanced Control & Robotics

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

Transcription:

CSCI 520 Computer Animation and Simulation Quaternions and Rotations Jernej Barbic University of Southern California 1

Rotations Very important in computer animation and robotics Joint angles, rigid body orientations, camera parameters 2D or 3D 2

Rotations in Three Dimensions Orthogonal matrices: RR T = R T R = I det(r) = 1 3

Representing Rotations in 3D Rotations in 3D have essentially three parameters Axis + angle (2 DOFs + 1DOFs) How to represent the axis? Longitude / lattitude have singularities 3x3 matrix 9 entries (redundant) 4

Representing Rotations in 3D Euler angles roll, pitch, yaw no redundancy (good) gimbal lock singularities Quaternions generally considered the best representation Source: Wikipedia redundant (4 values), but only by one DOF (not severe) stable interpolations of rotations possible 5

Euler Angles 1. Yaw rotate around y-axis 2. Pitch rotate around (rotated) x-axis 3. Roll rotate around (rotated) y-axis Source: Wikipedia 6

Gimbal Lock When all three gimbals are lined up (in the same plane), the system can only move in two dimensions from this configuration, not three, and is in gimbal lock. Source: Wikipedia 7

Gimbal Lock When all three gimbals are lined up (in the same plane), the system can only move in two dimensions from this configuration, not three, and is in gimbal lock. Source: Wikipedia 8

Choice of rotation axis sequence for Euler Angles 12 choices: XYX, XYZ, XZX, XZY, YXY, YXZ, YZX, YZY, ZXY, ZXZ, ZYX, ZYZ Each choice can use static axes, or rotated axes, so we have a total of 24 Euler Angle versions! 9

Example: XYZ Euler Angles First rotate around X by angle θ 1, then around Y by angle θ 2, then around Z by angle θ 3. Used in CMU Motion Capture Database AMC files Rotation matrix is: R = $ cos(" 3 ) #sin(" 3 ) 0' $ cos(" 2 ) 0 #sin(" 2 )' $ 1 0 0 ' & )& )& ) & sin(" 3 ) cos(" 3 ) 0) & 0 1 0 )& 0 cos(" 1 ) #sin(" 1 )) %& 0 0 1( )%& sin(" 2 ) 0 cos(" 2 ) () %& 0 sin(" 1 ) cos(" 1 ) () 10

Outline Rotations Quaternions Quaternion Interpolation 11

Quaternions Generalization of complex numbers Three imaginary numbers: i, j, k i 2 = -1, j 2 = -1, k 2 = -1, ij = k, jk = i, ki = j, ji = -k, kj = -i, ik = -j q = s + x i + y j + z k, s,x,y,z are scalars 12

Quaternions Invented by Hamilton in 1843 in Dublin, Ireland Here as he walked by on the 16th of October 1843 Sir William Rowan Hamilton in a flash of genius discovered the fundamental formula for quaternion multiplication i 2 = j 2 = k 2 = i j k = 1 & cut it on a stone of this bridge. Source: Wikipedia 13

Quaternions Quaternions are not commutative! q 1 q 2 q 2 q 1 However, the following hold: (q 1 q 2 ) q 3 = q 1 (q 2 q 3 ) (q 1 + q 2 ) q 3 = q 1 q 3 + q 2 q 3 q 1 (q 2 + q 3 ) = q 1 q 2 + q 1 q 3 α (q 1 + q 2 ) = α q 1 + α q 2 (α is scalar) (αq 1 ) q 2 = α (q 1 q 2 ) = q 1 (αq 2 ) (α is scalar) I.e. all usual manipulations are valid, except cannot reverse multiplication order. 14

Quaternions Exercise: multiply two quaternions (2 - i + j + 3k) (-1 + i + 4j - 2k) =... 15

Quaternion Properties q = s + x i + y j + z k Norm: q 2 = s 2 + x 2 + y 2 + z 2 Conjugate quaternion: q = s - x i - y j - z k Inverse quaternion: q -1 = q / q 2 Unit quaternion: q =1 Inverse of unit quaternion: q -1 = q 16

Quaternions and Rotations Rotations are represented by unit quaternions q = s + x i + y j + z k s 2 + x 2 + y 2 + z 2 = 1 Unit quaternion sphere (unit sphere in 4D) Source: Wolfram Research unit sphere in 4D 17

Rotations to Unit Quaternions Let (unit) rotation axis be [u x, u y, u z ], and angle θ Corresponding quaternion is q = cos(θ/2) + sin(θ/2) u x i + sin(θ/2) u y j + sin(θ/2) u z k Composition of rotations q 1 and q 2 equals q = q 2 q 1 3D rotations do not commute! 18

Unit Quaternions to Rotations Let v be a (3-dim) vector and let q be a unit quaternion Then, the corresponding rotation transforms vector v to q v q -1 (v is a quaternion with scalar part equaling 0, and vector part equaling v) For q = a + b i + c j + d k R = 19

Quaternions Quaternions q and -q give the same rotation! Other than this, the relationship between rotations and quaternions is unique 20

Outline Rotations Quaternions Quaternion Interpolation 21

Quaternion Interpolation Better results than Euler angles A quaternion is a point on the 4-D unit sphere Interpolating rotations corresponds to curves on the 4-D sphere Source: Wolfram Research 22

Spherical Linear interpolation (SLERPing) Interpolate along the great circle on the 4-D unit sphere Move with constant angular velocity along the great circle between the two points Any rotation is given by two quaternions, so there are two SLERP choices; pick the shortest San Francisco to London 23

SLERP u varies from 0 to 1 q m = s m + x m i + y m j + z m k, for m = 1,2 The above formula does not produce a unit quaternion and must be normalized; replace q by q / q 24

Interpolating more than two rotations Simplest approach: connect consecutive quaternions using SLERP Continuous rotations Angular velocity not smooth at the joints 25

Interpolation with smooth velocities Use splines on the unit quaternion sphere Reference: Ken Shoemake in the SIGGRAPH '85 proceedings (Computer Graphics, V. 19, No. 3, P. 245) 26

Four control points Bezier Spline points P1 and P4 are on the curve points P2 and P3 are off the curve; they give curve tangents at beginning and end 27

p(0) = P1, p(1) = P4, p'(0) = 3(P2-P1) p'(1) = 3(P4 - P3) Bezier Spline Convex Hull property: curve contained within the convex hull of control points Scale factor 3 is chosen to make velocity approximately constant 28

The Bezier Spline Formula Bezier basis Bezier control matrix [x,y,z] is point on spline corresponding to u u varies from 0 to 1 P1 = [x 1 y 1 z 1 ] P2 = [x 2 y 2 z 2 ] P3 = [x 3 y 3 z 3 ] P4 = [x 4 y 4 z 4 ] 29

DeCasteljau Construction Efficient algorithm to evaluate Bezier splines. Similar to Horner rule for polynomials. Can be extended to interpolations of 3D rotations. 30

DeCasteljau on Quaternion Sphere Given t, apply DeCasteljau construction: Q 0 = Slerp(P 0,P 1,t) Q 2 = Slerp(P 2,P 3,t) R 1 = Slerp(Q 1,Q 2,t) Q 1 = Slerp(P 1,P 2,t) R 0 = Slerp(Q 0,Q 1,t) P(t)= Slerp(R 0,R 1,t) 31