Quaternions and Interpolation of Rotations - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Quaternions and Interpolation of Rotations

Description:

... the quaternion multiplication is ... is a quaternion with zero real part (like v) ... unit quaternion multiplication corresponds to composition of rotations ... – PowerPoint PPT presentation

Number of Views:322
Avg rating:3.0/5.0
Slides: 24
Provided by: lad6
Category:

less

Transcript and Presenter's Notes

Title: Quaternions and Interpolation of Rotations


1
Quaternions and Interpolation of Rotations
  • Ladislav Kavan

2
Rotations in R2 and R3
  • Recall a rotation in R3 is a linear
    transformation, whose matrix

is orthonormal and det(M) 1. Similarly, a
rotation in R2 is a linear transformation with
matrix
which is orthonormal and det(M') 1.
3
Complex Numbers
  • C ... the set of complex numbers
  • A complex number z?C can be written as z a
    ib,
  • where "i" is the imaginary unit, satisfying i2
    -1
  • z a - ib is the complex conjugate of z
  • z ?(zz) ?(a2 b2) is the complex norm of
    z
  • z is unit complex number if z1
  • Every z?C can be written as z zei?, because
    of
  • Euler's identity
  • ei? cos(?) isin(?)

4
Complex Numbers and 2D Rotation
  • Rotation of (x1, x2)T ? R2 by angle ? can be
    written using a 2?2 matrix as
  • Define
  • x?C such that x x1 ix2
  • y?C such that y y1 iy2
  • Then we can write the equation above as
  • yei?x
  • Why? Because of Euler's identity.

5
Complex Numbers and 2D Rotation
  • Observe ei? is a unit complex number, because
  • ei?2 cos2(?) sin2(?) 1
  • We have a unique correspondence between 2D
    rotations and unit complex numbers
  • Unit complex numbers form a unit circle in the
    complex plane
  • Identity is simply 1?C
  • Inverse rotation is complex conjugate,
  • because e-i? (ei?)
  • What about 3D rotations?

6
Quaternions
  • generalization of complex numbers
  • discovered by W.R.Hamilton

7
Quaternions
  • Three imaginary units i, j, k with properties
  • i2 -1, j2 -1, k2 -1
  • ij -ji k, jk -kj i, ki -ik j
  • Exercise derive this from i2 j2 k2 ijk
    -1
  • Quaternion is a four-tuple q w xi yj zk
  • 1 0i 0j 0k is a quaternion unit (1?Q)
  • addition of quaternions, scalar multiplication
    component-wise
  • compact notation q w r, where r xi yj zk
    (w is called the real part and r the vector one)
  • q can be interpreted as a R4 vector, w as a real
    number and r as a R3 vector

8
Quaternion Multiplication
  • Multiplication is what makes it an algebra. If
  • q0 w0 x0i y0j z0k w0 r0
  • q1 w1 x1i y1j z1k w1 r1
  • then the quaternion multiplication is defined as
  • q0 q1 w0 w1 - ltr0, r1gt w0 ? r1 w1 ? r0 r0
    ? r1
  • (when interpreting r0 and r1 as R3 vectors)
  • Quaternion multiplication Q ? Q ? Q
  • associative
  • non-commutative
  • Dot product of quaternions also possible Q ? Q ?
    R
  • ltq0, q1gt w0 w1 x0 x1 y0 y1 z0 z1

9
Quaternion Operations
  • Let q w xi yj zk w r
  • We define
  • quaternion conjugate q w - xi - yj - zk w -
    r
  • quaternion norm q ?(qq) ?(w2x2y2z2)
  • unit quaternion has q 1
  • Properties ?p,q?Q
  • p q pq
  • (p q) q p
  • if p is unit pp pp 1

10
Quaternion Operations
  • Euler's identity generalizes to quaternions
  • er? cos(?) rsin(?)
  • Each q?Q can be written as qqer? (for some
    ??R)
  • Especially, for a unit quaternion qer?
  • Power of a unit quaternion q can be therefore
    defined as
  • qt ert? (cos(t?) rsin(t?))
  • Warning er?es? ? er?s? in general, because
    quaternions are not commutative

11
Unit Quaternions and 3D Rotations
  • A rotation in R3 unit axis a?R3 and angle ??R
  • Let x (x1, x2, x3)T ? R3, and v ix1 jx2
    jx3 ? Q
  • Define unit quaternion q cos(?/2) a sin(?/2)
  • Then
  • v' q v q
  • is a quaternion with zero real part (like v).
  • Denote v' ix1' jx2' jx3' and x' (x1',
    x2', x3')T
  • Fact x' is a rotation of x about axis a with
    angle ?
  • A 3D rotation can be represented by a unit
    quaternion
  • Is this correspondence unique?

12
Unit Quaternions and 3D Rotations
  • No, quaternions q and -q represent the same
    rotation
  • (since -q v -q q v q)
  • Lets rotate v' by another unit quaternion p
  • v'' p v' p p q v q p (p q) v (p q)
  • Especially, if p q
  • v'' (qq) v (qq) v
  • unit quaternion multiplication corresponds to
    composition of rotations
  • conjugation of unit quaternion corresponds to
    inverse rotation
  • 1 is the identity (zero angle rotation)

13
Quaternion to Rotation Matrix
  • Let q w xi yj zk ? Q, q 1.
  • Rotation by q corresponds to multiplication by
    matrix
  • Conversion from matrix to quaternion is also
    possible (but a bit tricky because of numerical
    issues, see Shoemake 1985)
  • composition of rotations is faster in quaternions
  • transformation of vector is faster by matrix

14
Interpolation of Rotations
  • Consider two rotations R0, R1
  • The task is to define a rotation R(t) ?t?0,1,
    s.t.
  • R(0) R0
  • R(1) R1
  • ?t?0,1 R(t) is a rotation
  • The angular velocity of an object transformed by
    R(t) is constant
  • First idea interpolate rotation matrices
  • Problem the resulting matrix might not be a
    rotation (the orthonormality might be violated)

15
Interpolation of 2D Rotations
  • Let 2D rotations R0, R1 are represented by unit
    complex numbers z0, z1
  • Consider interpolation

Fulfills conditions 1,2,3 R(t) is a unit complex
number Violates condition 4
16
Interpolation of 2D Rotations
  • Express the complex numbers z0, z1 as
  • z0 ei?
  • z1 ei?
  • Consider interpolation R(t) ei(1-t)? it?
    z0(z0 z1)t
  • Fulfills conditions 1,2,3 and 4 the angle of
    rotation is interpolated linearly
  • How to generalize to 3D? Using quaternions!
    (but be careful quaternions do not commute
    like complex numbers)

17
Interpolation of 3D Rotations
  • Let p wp rp, q wq rq are unit
    quaternions.
  • Then the interpolation
  • R(t) p(pq)t
  • is called a Spherical Linear Interpolation
    (SLERP), and
  • fulfills conditions 1,2,3 and 4.
  • Catch -q represents the same rotation as q
    what happens if we employ -q instead of q?
  • A scalar part of pq is wpwq ltrp,rqgt ltp,qgt
  • Since p and q are unit, ltp,qgtcos(?), ??0,?)
  • Observe 2? is the angle of rotation pq

18
Spherical Linear Interpolation
  • If we apply -q instead of q, we get
  • -ltp,qgt -cos(?) cos(? - ?)
  • The angle of rotation -pq is thus 2? - 2?
  • Example for ? 60 degrees

interpolating pq
interpolating -pq
19
Spherical Linear Interpolation
The same on a quaternion sphere (a 2D slice below)
p
pq interpolation
-pq interpolation
q
0
-q
  • Conclusion If we want the shortest-path
    interpolation, we must ensure ltp,qgt ? 0
  • (by using -q instead of q)

20
Spherical Linear Interpolation
  • Unit quaternions p, q are points on unit sphere
    in R4.
  • SLERP interpolates along the shortest arc on the
    unit sphere in R4. This gives formula
  • where ? is again the angle inclined by p and q.
  • This formula is
  • more efficient for computation
  • equivalent to R(t) p(pq)t

21
Spherical Linear Interpolation
  • Input
  • unit quaternions p, q,
  • interpolation parametr t?lt0,1gt
  • The algorithm
  • c_sig ltp,qgt
  • if c_sig lt 0 then q -q c_sig -c_sig
  • sig acos(c_sig)
  • res sin((1-t)sig)
  • res sin(tsig)
  • res / sin(sig)
  • return res

22
Comparison
  • Quaternions have 4 elements
  • Better than matrices (9 elements)
  • However, 3D rotation has only 3 DoFs
  • 3 scalars are sufficient (Euler angles)
  • Any 3D rotation M can be expressed as
  • M Rx(?)Ry(?)Rz(?),
  • where Rx, Ry, Rz are rotations about coordinate
    axis
  • Why dont use Euler angles instead of quaternions?

23
Gimbal Lock
  • M Rx(?)Ry(?)Rz(?)
  • If ? 90 degrees, Rx does the same rotation as
    Rz
  • One DoF lost
  • Not good for interpolation
Write a Comment
User Comments (0)
About PowerShow.com