Introduction to quaternions

Similar documents
Course 2BA1: Hilary Term 2007 Section 8: Quaternions and Rotations

Why Transforms? Want to animate objects and camera Translations Rotations Shears And more.. Want to be able to use projection transforms

Quaternions. R. J. Renka 11/09/2015. Department of Computer Science & Engineering University of North Texas. R. J.

Lecture 7. Quaternions

EEL6667: Homework #1 Solutions

Quaternions 2 AUI Course Denbigh Starkey

Complex Numbers and Quaternions for Calc III

Understanding Quaternions: Rotations, Reflections, and Perspective Projections. Ron Goldman Department of Computer Science Rice University

Quaternions. Basilio Bona. Semester 1, DAUIN Politecnico di Torino. B. Bona (DAUIN) Quaternions Semester 1, / 40

The VQM-Group and its Applications

Group, Rings, and Fields Rahul Pandharipande. I. Sets Let S be a set. The Cartesian product S S is the set of ordered pairs of elements of S,

Closed-Form Solution Of Absolute Orientation Using Unit Quaternions

sin(α + θ) = sin α cos θ + cos α sin θ cos(α + θ) = cos α cos θ sin α sin θ

Texture, Microstructure & Anisotropy A.D. (Tony) Rollett

Lecture «Robot Dynamics»: Kinematics 2

DUAL SPLIT QUATERNIONS AND SCREW MOTION IN MINKOWSKI 3-SPACE * L. KULA AND Y. YAYLI **

Rotations. sin θ cos θ 0. a a 2

We are already familiar with the concept of a scalar and vector. are unit vectors in the x and y directions respectively with

QUATERNIONS AND ROTATIONS

Physically Based Rendering ( ) Geometry and Transformations

Position and orientation of rigid bodies

Quaternions and their applications

BSc (Hons) in Computer Games Development. vi Calculate the components a, b and c of a non-zero vector that is orthogonal to

= a. a = Let us now study what is a? c ( a A a )

Lecture Notes - Modeling of Mechanical Systems

Unit Generalized Quaternions in Spatial Kinematics

Chapter 2 Math Fundamentals

Interpolation of Transformation

The Matrix Representation of a Three-Dimensional Rotation Revisited

11.1 Three-Dimensional Coordinate System

PHYS 705: Classical Mechanics. Rigid Body Motion Introduction + Math Review

arxiv: v1 [math.ds] 18 Nov 2008

THE COMPLEXITY OF THE QUATERNION PROD- UCT*

Interpolation of Rigid Motions in 3D

Lecture 10: A (Brief) Introduction to Group Theory (See Chapter 3.13 in Boas, 3rd Edition)

Mathematics for Graphics and Vision

Quaternion kinematics for the error-state Kalman filter

The groups SO(3) and SU(2) and their representations

Course MA2C02, Hilary Term 2010 Section 4: Vectors and Quaternions

Kinematics of a UR5. Rasmus Skovgaard Andersen Aalborg University

Mathematical Preliminaries

On complexified quantum mechanics and space-time

GEOMETRY AND VECTORS

Math review. Math review

Rotational motion of a rigid body spinning around a rotational axis ˆn;

ON A NEW SPECIES OF IMAGINARY QUANTITIES CONNECTED WITH A THEORY OF QUATERNIONS. William Rowan Hamilton

Matrix Representation

Matrices and Vectors

Notes on multivariable calculus

Lecture 1.2 Pose in 2D and 3D. Thomas Opsahl

X-MA2C01-1: Partial Worked Solutions

An eightfold path to E 8

Computer Graphics II

Quaternions. Mike Bailey. Computer Graphics Quaternions.pptx

CS 354R: Computer Game Technology

Contravariant and Covariant as Transforms

Subalgebras of the Split Octonions

ECS 178 Course Notes QUATERNIONS

Be fruitful and multiply Genesis 1:28

Assignment 10. Arfken Show that Stirling s formula is an asymptotic expansion. The remainder term is. B 2n 2n(2n 1) x1 2n.

A Primer on Three Vectors

8 Velocity Kinematics

Vectors Coordinate frames 2D implicit curves 2D parametric curves. Graphics 2008/2009, period 1. Lecture 2: vectors, curves, and surfaces

UNIVERSITY OF DUBLIN

NIELINIOWA OPTYKA MOLEKULARNA

Problem Solving 1: Line Integrals and Surface Integrals

Linear Algebra March 16, 2019

Contents. D. R. Wilkins. Copyright c David R. Wilkins

1 Geometry of R Conic Sections Parametric Equations More Parametric Equations Polar Coordinates...

Introduction to Group Theory

Systems of Linear Equations and Matrices

Vector Multiplication. Directional Derivatives and the Gradient

Math 147, Homework 1 Solutions Due: April 10, 2012

REFRESHER. William Stallings

Leandra Vicci. Microelectronic Systems Laboratory. Department of Computer Science. University of North Carolina at Chapel Hill. 27 April 2001.

Curvilinear Coordinates

Lie Algebra of Unit Tangent Bundle in Minkowski 3-Space

Systems of Linear Equations and Matrices

REPRESENTATION OF THE LORENTZ TRANSFORMATIONS IN 6-DIMENSIONAL SPACE-TIME

Tensors, and differential forms - Lecture 2

Directional Derivatives and the Gradient

Chapter 2. Linear Algebra. rather simple and learning them will eventually allow us to explain the strange results of

9 th AAS/AIAA Astrodynamics Specialist Conference Breckenridge, CO February 7 10, 1999

ROTATIONS OF THE RIEMANN SPHERE

Robotics I. February 6, 2014

Principal Rotation Representations of Proper NxN Orthogonal Matrices

A Tutorial on Euler Angles and Quaternions

16.333: Lecture #3. Frame Rotations. Euler Angles. Quaternions

Math 3c Solutions: Exam 1 Fall Graph by eliiminating the parameter; be sure to write the equation you get when you eliminate the parameter.

Crystallographic orienta1on representa1ons

ON QUATERNIONS. William Rowan Hamilton. (Proceedings of the Royal Irish Academy, 3 (1847), pp ) Edited by David R. Wilkins

Ridig Body Motion Homogeneous Transformations

MATH 423 Linear Algebra II Lecture 3: Subspaces of vector spaces. Review of complex numbers. Vector space over a field.

Robotics & Automation. Lecture 03. Representation of SO(3) John T. Wen. September 3, 2008

Math 370 Homework 2, Fall 2009

The Complex Numbers c ). (1.1)

A matrix over a field F is a rectangular array of elements from F. The symbol

Lecture Note 4: General Rigid Body Motion

Position and orientation of rigid bodies

5. Vector Algebra and Spherical Trigonometry (continued)

Transcription:

. Introduction Introduction to uaternions Invented and developed by William Hamilton in 843, uaternions are essentially a generalization of complex numbers to four dimensions (one real dimension, three imaginary). Quaternions have important, desirable properties when used to represent rotations, and, as such, are worthy of study in this course, where rotations between coordinate frames will occupy much of our attention, especially early on. This document gives a brief introduction on uaternions and follows closely the notation in [, which offers a much more exhaustive treatment. 2. Basic definition A uaternion consists of a scalar part s, s R, and a vector part v ( xyz,, ), v R 3. We will use several different forms to denote uaternions. These are given in euations () through (3) below: [ s, v [ s, ( xyz,, ) s+ ix + jy + kz In definition (3) above, the imaginary number i, j and k have the following properties: i 2 j 2 k 2 () (2) (3) (4) ij k (5) ji k From (4) through (6) the following additional properties can be derived: ijk (6) (7) jk i (8) kj ik i j (9) (0) ki j 3. Basic properties () A. Addition Let, and, ' Then, [ s, v [ s, ( x, yz, ), (2) [ s', v' [ s',( x', y', z' ). (3) + ' [ s + s', v+ v' ( s + s' ) + i( x+ x' ) + j( y+ y' ) + k( z + z' ) Clearly, uaternion addition is associative and commutative. (4) B. Multiplication With definitions (2) and (3), the product of two uaternions and ' is given by, - -

' [ ss' v v', v v' + sv' + s'v Euation (5) can be verified by writing, (5) ' [ s, v [ s', v' ( s + ix + jy + kz) ( s' + ix' + jy' + kz' ) expanding the product in euation (6), applying properties (4) through (), and grouping terms accordingly. As a reminder, note that for two vectors a ( a x, a y, a z ) and b ( b x, b y, b z ), the dot and cross products are defined as, (6) a b a x b x + a y b y + a z b z b a (7) a b ( a y b z a z b y, a z b x a x b z, a x b y a y b x ) b a (8) respectively. Note that two purely scalar uaternions, [ s, 0 and [ s', 0, result in a scalar product, while two purely vector uaternions, [ 0, v and [ 0, v', yield both the dot product (albeit negative), and the cross product, [ 0, v [ 0, v' [ v v', v v'. (9) It can be easily verified that multiplication is associative, but not commutative; that is, in general, the order of multiplication does matter. One case of multiplication that is commutative is multiplication of a general uaternion by a scalar uaternion: C. Conjugate [ r, 0 [ s, v [ s, v [ r, 0 [ rs, rv. (20) The conjugate of a uaternion [ s, v is denoted as and is defined as, D. Norm [ s, v. (2) The norm (or length) of a uaternion [as defined in euation (2) is given by, (22) Since, [ s 2 ( v ( ), v ( + sv + s( [ s 2 + v v, 0 euation (22) can be expanded to, (23) Note the similarity of euation (24) to the computation of the length of a vector. A unit uaternion is any uaternion of unit length such that. E. Inversion s 2 + x 2 + y 2 + z 2 The inverse of a uaternion [as defined in euation (2) is given by, 2. (25) This can be easily verified by computing : 2 2 2 [, 0. (26) (24) - 2 -

4. Rotations through uaternions A. Basics Below we will show that every unit uaternion represents a uniue rotation in space. It is easy to show that any unit uaternion can be expressed as, where kˆ ( k x, k y, k z ) denotes an arbitrary unit vector. Such a unit uaternion represents a rotation of θ about the vector kˆ. Now, let p ( p x, p y, p z ) denote the Cartesian coordinates of a point in space. Let us assume that we wish to rotate p by θ about the vector kˆ to. Let, Then, [ cos( θ 2), sin( θ 2) kˆ p [ 0, p, and, (28) [ 0,. (29) p In words, rotation by an angle θ about a unit vector kˆ can be achieved by pre- and post-multiplying the uaternion representation p of the vector p by the uaternion [as given by (27) and its conjugate, respectively. Let us show that euation (30) results in the same rotation matrix R ( θ) as previously derived in class kˆ through an argument of composite rotations (as demonstrated in Mathematica). p (27) (30) (3) [ s, v [ 0, p [ s, v (32) [ v p, v p+ sp [ s, v (33) Now, expression (34) can be significantly simplified. Note that the scalar part of (34) reduces to zero, since the dot products s( v and s( p cancel each other, and, which can be verified by inserting definitions (7) and (8) for the dot and cross products, respectively, into (35). For the vector part, and, so that, [ s( v + ( v v + s( p, ( v v s( p + s( v + s 2 p + v( v ( v v 0 s( p + s( v 2s( v ( v v ( v p ( v v [easily verified through (7) and (8) (37) (34) (35) (36) [ 0, ( s 2 v p + 2s( v + 2( v v or, euivalently, (38) ( s 2 v p + 2s( v + 2( v v. (39) We are now ready to substitute (27) into (39): [ cos 2 ( θ 2) sin 2 ( θ 2) p + 2cos( θ 2) sin( θ 2) kˆ p + 2sin 2 ( θ 2) ( kˆ kˆ (40) - 3 -

Applying the following trigonometric half-angle identities, cosθ cos 2 ( θ 2) sin 2 ( θ 2) sinθ 2cos( θ 2) sin( θ 2) ( cosθ) ( cos 2 ( θ 2) + sin 2 ( θ 2) ) 2sin 2 ( θ 2) (4) (42) [from (4) and (42) (43) euation (40) simplifies even further to: ( cosθ)p + ( sinθ)kˆ p + ( cosθ) ( kˆ kˆ (44) ( cθ)p + ( sθ)kˆ p + ( vθ) ( kˆ kˆ, (45) where cθ cosθ, sθ sinθ and vθ cosθ. Euation (44) is an important result known as Rodrigues formula. When we expand euation (45) by component terms, we get (after a lot of math best left to Mathematica), R ( θ)p kˆ (46) R ( θ) kˆ ( k 2 x vθ + cθ) ( k x k y vθ k z sθ) ( k x k z vθ + k y sθ) ( k x k y vθ + k z sθ) ( k 2 y vθ + cθ) ( k y k z vθ k x sθ) ( k x k z vθ k y sθ) ( k y k z vθ + k x sθ) ( k 2 y vθ + cθ) (47) which is exactly the same result as obtained in class through an argument of composite rotations. The two most important euations in this section are (3) and (45), which are reprinted below to emphasize their importance: p [rotation through uaternions (48) ( cθ)p + ( sθ)kˆ p + ( vθ) ( kˆ kˆ [Rodrigues formula (49) B. Composite uaternion rotations Assume two rotations: o followed by. The result of the first rotation is given by, 0 p 0 (50) while the result ' after both rotations is given by, ' (5) ' ( 0 p 0 ) (52) ' ( 0 )p ( 0 ) ' ( 0 )p ( 0 ) (53) (54) Note that from (53) to (54) we used the following fact: 0 ( 0 ) (55) for unit uaternions, which can be readily shown through the definition of uaternion multiplication. Euation (55) is important in that it shows that composite rotations can be computed through simple unit uaternion multiplication. - 4 -

C. Quaternion to axis-angle representation For any uaternion, [ s, v (56) we can readily compute the euivalent axis-angle representation. From (27), [ cos( θ 2), sin( θ 2) kˆ we can compute θ and kˆ as: θ 2atan( v, s) kˆ v v (57) (58) (59) Note that when rotation. θ 0 D. Quaternion to rotation matrix Suppose we have a uaternion,, the axis of rotation becomes ill-conditioned, since any axis is euivalent for a null [ s, ( xyz,, ). (60) and would like to identify the corresponding 3 3 rotation matrix R. We start by expanding euation (39) into the components of v ( xyz,, ): ( s 2 v p + 2s( v + 2( v v (6) ( s 2 x 2 y 2 z 2 ) 00 00 00 0 z y + 2s z 0 x + 2 y x 0 x 2 xy xz xy y 2 yz p xz yz z 2 (62) 2( y 2 + z 2 ) 2( xy sz) 2( xz + sy) 2( xy + sz) 2( x 2 + z 2 ) 2( yz sx) 2( xz sy) 2( yz + sx) 2( x 2 + y 2 ) p (63) Note that in (62), we used the following matrix representation of the cross product: ( v 0 z y z 0 x y x 0 p (64) which is easily verified by doing a component-by-component comparison of both sides of euation (64). Thus, R is given by, R 2( y 2 + z 2 ) 2( xy sz) 2( xz + sy) 2( xy + sz) 2( x 2 + z 2 ) 2( yz sx) 2( xz sy) 2( yz + sx) 2( x 2 + y 2 ) (65) E. Rotation matrix to uaternion Suppose we have a rotation matrix R, - 5 -

r r 2 r 3 R r 2 r 22 r 23 (66) r 3 r 32 r 33 such that, Rp, (67) and would like to identify the corresponding uaternion, [ s, ( xyz,, ). (68) From the result of the previous section in (65), we can write down the following 0 convenient euations relating r ij to [ s, ( x, yz, ): s 2 -- ( + r 4 + r 22 + r 33 ) x 2 -- ( + r 4 r 22 r 33 ) y 2 -- ( r 4 + r 22 r 33 ) z 2 -- ( r 4 r 22 + r 33 ) (69) (70) (7) (72) and, sx 4 32 r 23 ) (73) sy 4 3 r 3 ) (74) sz 4 2 r 2 ) (75) xy 4 2 + r 2 ) (76) xz 4 3 + r 3 ) (77) yz 4 23 + r 32 ) (78) Now, to solve for the parameters [ s, ( x, yz, ) robustly, use the first four euations [(69) through (72), to solve for the largest valued parameter in { s 2, x 2, y 2, z 2 }. Then, solve for the remaining three parameters using three of the six remaining euations [(73) through (78). 5. Rotation trajectories through uaternions A. Linear interpolation (Ler Suppose you wish to generate a trajectory of orientations between two rotations represented by unit uaternions 0 and respectively. One method of achieving this is called Linear Interpolation (Ler, which is given by, - 6 -

where, Lerp( 0,, h) f ( 0,, h) -------------------------------, h [ 0,, (79) f ( 0,, h) f ( 0,, h) 0 ( h) + h. (80) Note that the normalization in euation (79) is reuired since f ( 0,, h) is not guaranteed to be a unit vector. It is easy to verify that, Lerp( 0,, 0) 0, and, (8) Lerp( 0,, ). (82) See [ for much more detail. B. Spherical linear interpolation (Sler One of the main objections to the Lerp trajectory is that the resulting trajectory is not constant velocity. Another method, called Spherical Linear Interpolation (Sler, achieves the shortest possible interpolation path between 0 and (or 0 and, whichever is shorter) along the four-dimensional unit sphere at constant velocity. The Slerp interpolation is given by, Slerp( 0,, h) ( 0 ) h 0, h [ 0,, (83) or euivalently as, Slerp( 0,, h) ( 0 ) h 0, h [ 0,. (84) Note that as was the case for Lerp, Slerp( 0,, 0) ( 0 ) 0 0 0 0, and, (85) Slerp( 0,, ) ( 0 ) 0 0 0. (86) The main difference between the Lerp and the Slerp interpolation is that the Lerp interpolation cuts through the unit uaternion sphere (before being projected back onto it through normalization), while the Slerp interpolation moves at constant velocity on the surface on the unit uaternion sphere. (see Figure 6.4 on page 42 in [). In order to compute (83) [or (84) for uaternion of the form, where kˆ is a unit vector, we define, h ( 0, ), we need a little more uaternion math. First, given a unit log( ) [ 0, Ωkˆ. (88) Second, for a uaternion of the form, we define, [ cosω, sinωkˆ [ 0, Ωkˆ exp( ) [ cosω, sinωkˆ. (90) Now, we define, (87) (89) h exp[ h log( ) (9) - 7 -

These definitions have some familiar (with respect to scalars) properties, such as: log( [ 0, ) [ 00,, (92), (93) A word of caution, though; not all properties scale from scalars to uaternions; for example, for uaternions p,. Now, we are ready to give a formula for computing the Slerp interpolation. Let, so that, 0 [ s 0, v 0, and, (96) [ s, v. (97) 0 [ s s 0 + ( v v 0 ), v v 0 + s 0 v s v 0. (98) If we let, a b a+ b ab ( a ) b. (94) log( p) log( + log( ) (95) 0 [ cosω, sinωkˆ [as in assumption (87), (99) then, cosω 0 s s 0 + ( v v 0 ) (00) Ω acos( 0 ), and, (0) k v 0 v + s 0 v s v 0, and, (02) kˆ k/ k 0 k 0 k 0 (03) Finally [from definition (9), ( 0 ) exp[ h log( 0 ) ( 0 ) exp( [ 0, hωkˆ ) (04) (05) ( 0 ) h [ cos( hω), sin( hω) kˆ. (06) Euation (06), together with (00) through (03), allows computation of Slerp( 0,, h) ( 0 ) h 0, h [ 0,. From (06), note that ( 0 ) 0 [, 0 and ( 0 ) 0. For much greater detail, see [. 6. Conclusions Unit uaternions represent rotations. They have several advantages over three-angle representations (both fixed axis and Euler angles) and rotation matrices:. Unit uaternions do not suffer from singularities, as three-angle conventions do. 2. Unit uaternions represent the most compact way of representing rotations without redundancy or singularity (unlike rotation matrices themselves). One can visualize unit uaternions populating the surface of a sphere in four-dimensional Euclidean space, where each uaternion and its antipode represent a uniue rotation in three dimensions. - 8 -

References 3. The unit uaternion representation allows us to define and compute a distance metric between two rotations. This is not, in general possible or easy with three-angle conventions or rotation matrices. 4. In finite-precision computations, ensuring proper rotations through freuent re-normalization is easy for unit uaternions, but significantly trickier for rotation matrices. 5. For simulation purposes, it is easy to generate a uniformly random distribution of rotations in uaternion space. 6. Unit uaternions allow for the computation of shortest-path, smooth, continuous-velocity trajectories between two rotations (represented as unit uaternions). Three-angle conventions make this very difficult, if not impossible. [ E. B. Dam, M. Koch and M. Lillholm, Quaternions, Interpolation and Animation, DIKU-TR-98/5, Technical Report, Department of Computer Science, University of Copenhagen, 998 (http://www.diku.dk/ research/published/98-5.ps.gz). - 9 -