Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ...

28
my head is spinning... Four different ways to represent rotation

Transcript of Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ...

Page 1: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

my head is spinning...

Four different ways to represent rotation

Page 2: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

The space of rotations

Special orthogonal group(3):

1)det(,|3 33 RIRRRRSO T

Rotations preserve distance: 2121 ppRpRp

Rotations preserve orientation: 2121 ppRRpRp

Why ? 1)det( R

Page 3: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

The space of rotations

Special orthogonal group(3):

1)det(,|3 33 RIRRRRSO T

Why it’s a group:

• Closed under multiplication: if then

• Has an identity:

• Has a unique inverse…

• Is associative…

321 SORR 3, 21 SORR 11 s.t. 3 RIRSOI

Why orthogonal:

• vectors in matrix are orthogonal

Why it’s special: , NOT1)det( R 1)det( R

Right hand coordinate system

Page 4: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Possible rotation representations

You need at least three numbers to represent an arbitrary rotation in SO(3) (Euler theorem). Some three-number representations:

• ZYZ Euler angles

• ZYX Euler angles (roll, pitch, yaw)

• Axis angle

One four-number representation:

• quaternions

Page 5: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

To get from A to B:

1. Rotate about z axis

2. Then rotate about y axis

3. Then rotate about z axis

ZYZ Euler Angles

zyzr

100

0cossin

0sincos

)(

zR

cos0sin

010

sin0cos

)(yR

100

0cossin

0sincos

)(

zR

Page 6: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

)()()(,, zyzzyz RRRR

Therefore, the sequence of rotations is concatentated as follows:

ZYZ Euler Angles

100

0cossin

0sincos

cos0sin

010

sin0cos

100

0cossin

0sincos

,,

zyzR

Remember that encode the desired rotation in the pre-rotation reference frame:

)(zR )(yR )(zR

rotationpostrotationpre

z RR )(

csscs

ssccscsscccs

sccssccssccc

Rzyz ,,

Page 7: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

100

0cossin

0sincos

)(

zR

cos0sin

010

sin0cos

)(yR

cossin0

sincos0

001

)(xR

To get from A to B:

1. Rotate about z axis

2. Then rotate about y axis

3. Then rotate about x axis

)()()(,, xyzzyx RRRR

ZYX Euler Angles (roll, pitch, yaw)

cossin0

sincos0

001

cos0sin

010

sin0cos

100

0cossin

0sincos

,,zyzR

Page 8: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Problems w/ Euler Angles

If two axes are aligned, then there is a “don’t care” manifold of Euler angles that represent the same orientation

• The system loses one DOF

0

90

0

1r

90

89

90

2r

90

1

90

21 rr , but the actual distance is 1

Page 9: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Problem w/ Euler Angles: gimbal lock

1. When a small change in orientation is associated with a large change in rotation representation

2. Happens in “singular configurations” of the rotational representation (similar to singular configurations of a manipulator)

3. This is a problem w/ any Euler angle representation

Page 10: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Problem w/ Euler Angles: gimbal lock

Page 11: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Problem w/ Euler Angles: gimbal lock

Page 12: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Axis-angle representation

Theorem: (Euler). Any orientation, , is equivalent to a rotation about a fixed axis, , through an angle

z

y

x

k

k

k

k

3SOR3R )2,0[

Axis: Angle:

cos1sin 2 kkk

k SSIeR S

(also called exponential coordinates)

book... in theequation that

Rodrigues’ formula

Converting to a rotation matrix:

Page 13: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Axis-angle representation

2

1)(cos 1 Rtrace

k

332313

232212

131211

rrr

rrr

rrr

R

Magnitude of rotation:

332211)( rrrRtrace

Where:

1221

3113

2332

sin2

rr

rr

rr

k

Axis of rotation:

and:

Converting to axis angle:

Page 14: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Axis-angle problems

Still suffers from the “edge” and distance preserving problems of Euler angles:

179

0

0

1r

179

0

0

2r

358

0

0

21 rr

, but the actual distance is 2

Distance metric changes as you get further from origin.

Page 15: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Axis-angle representation

Axis angle is can be encoded by just three numbers instead of four:

kIf then0k and

For most orientations, , is unique.kR

If the three-number version of axis angle is used, then

IR 0

For rotations of , there are two equivalent representations:180

kk RR If then180k

Page 16: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Projection distortions

Page 17: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Example: differencing rotations

0

02

1

kCalculate the difference between

these two rotations:

0

0

22k

02

2

21

kkThis is NOT the right answer:

27.1272

21 kkAccording to that, this is the

magnitude of the difference:

Page 18: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

0

02

1

k

Convert to rotation matrices to solve this problem:

0

0

22k

010

001

100

001

010

100

010

100

001

2121 RRR BTB

010

100

001

cossin0

sincos0

001

22

2221

x

b RR

001

010

100

cos0sin

010

sin0cos

22

22

22

y

b RR

3211

2

1cos

2

1)(cos

Rtrace

Example: differencing rotations

1

1

1

3

1

sin2

1221

3113

2332

rr

rr

rr

k

1

1

1

332

k

2121 RRR BTB

Page 19: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

So far, rotation matrices seem to be the most reliable method of manipulating rotations. But there are problems:

• Over a long series of computations, numerical errors can cause these 3x3 matrices to no longer be orthogonal (you need to “orthogonalize” them from time to time).

• Although you can accurately calculate rotation differences, you can’t interpolate over a difference.’

• Suppose you wanted to smoothly rotate from one orientation to another – how would you do it?

Quaternions

Answer: quaternions…

Page 20: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Quaternions

3210 kqjqiqqQ Generalization of complex numbers:

qqQ ,0

qqqqQ ,, 0*

0*

Essentially a 4-dimensional quantity

32103210 kpjpippkqjqiqqQP Multiplication:

qppqqpqpqpQP 0000 ,

Complex conjugate:

1 ijkkkjjii

kjiij

ikjjk

jikki

Properties of complex dimensions:

Page 21: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Quaternions

Invented by Hamilton in 1843:

Along the royal canal in Dublin…

Page 22: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Quaternions

123

22

21

20

2 qqqqQLet’s consider the set of unit

quaternions:

This is a four-dimensional hypersphere, i.e. the 3-sphere 3S

Therefore, the inverse of a unit quaternion is: 1* QQ

)0,1(,,, 002

0000* qqqqqqqqqqqqqQQ

The identity quaternion is: 0,1Q

Since:

Page 23: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

You can rotate from frame a to b:

Quaternions

Pa *ba

aba

b PQQP

Given a unit axis, , and an angle, :

Associate a rotation with a unit quaternion as follows:

k̂ (just like axis angle)

2sinˆ,

2cos

kQ

kThe associated quaternion is:

Therefore, represents the same rotation asQ Q

Let be the quaternion associated with the vector pP ii ,0 pi

bacbca QQQ Composition:

1 bacacb QQQInversion:

Page 24: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Rotate by

Example: Quaternions

0

0

,2

12

1Q

0

0

1

,0Pa

0

0

,

0

0

1

,0

0

0

,2

12

12

12

1*PQQP ab

21

21

21

21 0,0

0

0

,

1

0

0

,000,0

21

21

21

21

Page 25: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

0

02

1

kFind the difference between these two axis angle

rotations:

0

0

22k

Example: Quaternions

0

0

,2

12

1cbQ

0

0,2

1

21

baQ 2

144 cossin

0

0,

0

0

,2

1

21

21

211

bacacb QQQ

qppqqpqpqpQP 0000 ,

21

21

21

21

21

21

21

21

21 ,,

32

211cos

cb

31

31

31

cbk

Page 26: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Quaternions: Interpolation

Suppose you’re given two rotations, and

How do you calculate intermediate rotations?1R 2R

21 1 RRRi This does not even result in a rotation matrix

Do quaternions help?

21

21

1

1

QQ

QQQi

Suprisingly, this actually works

• Finds a geodesic

This method normalizes automatically (SLERP):

sin

sin1sin 21 QQQi

Page 27: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

Supplementary

Page 28: Four different ways to represent rotationAssociate a rotation with a unit quaternion as follows: kˆ (just like axis angle) 2,ˆsin 2 cos ˆ, Q k k The associated quaternion is: Therefore,

In Euler angles, the each rotation is imagined to be represented in the post-rotation coordinate frame of the last rotation

)()()(,, xyzzyx RRRR

ZYX Euler Angles (roll, pitch, yaw)

In Fixed angles, all rotations are imagined to be represented in the original (fixed) coordinate frame.

ZYX Euler angles can be thought of as:

1. ZYX Euler

2. XYZ Fixed