rotation - university of pennsylvania

48
Rotation

Upload: others

Post on 05-Oct-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Rotation - University of Pennsylvania

Rotation

Page 2: Rotation - University of Pennsylvania

Rotation

Page 3: Rotation - University of Pennsylvania

Rotation = axis + angle

Anders Adermark @ flickr

“30 minutes shutter time. How cool isn't this? You see the stars above the north axis of our globe being fixed, and then the circles gets wider and wider the further you get from them. “

Page 4: Rotation - University of Pennsylvania

Axis Angle Representation

X

Y

Z

Page 5: Rotation - University of Pennsylvania

Axis Angle Representation

X

Y

Z

Page 6: Rotation - University of Pennsylvania

Axis Angle Representation

X

Y

Z

⎡ ⎤⎢ ⎥= ⎢ ⎥⎢ ⎥⎣ ⎦

eX

Y

Z

eee

Euler’s theoremAny displacement of a rigid body such that a point on the rigid body remains fixed, is equivalent to a single rotation about some axis that runs through the fixed point.

Page 7: Rotation - University of Pennsylvania

Axis Angle Representation

X

Y

Z

⎡ ⎤⎢ ⎥= ⎢ ⎥⎢ ⎥⎣ ⎦

eX

Y

Z

eee

A quadruple can represent 3D rotation, i.e., , where .

( )e,=e 1

Euler’s theoremAny displacement of a rigid body such that a point on the rigid body remains fixed, is equivalent to a single rotation about some axis that runs through the fixed point.

Page 8: Rotation - University of Pennsylvania

Leonhard Euler

Page 9: Rotation - University of Pennsylvania

Leonhard Euler

“I wanted to have a water jet in my garden: Euler calculated the force of the wheels necessary to raise the water to a reservoir, from where it should fall back through channels, finally spurting out in Sanssouci. My mill was carried out geometrically and could not raise a mouthful of water closer than fifty paces to the reservoir. Vanity of vanities! Vanity of geometry!”-Frederick II

Page 10: Rotation - University of Pennsylvania

He can do geometry

Page 11: Rotation - University of Pennsylvania

Euler’s work

Graph Theory:

V − E + F = 2

Page 12: Rotation - University of Pennsylvania

Matthew T. Mason

Page 13: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

What do we want from axis-angle?

I Operate on pointsI Rodrigues’s formula

I Compose rotations, average, interpolate, sampling,. . .?

I Not using axis-angleI Convert to other representations? There aren’t any

yet. But, later we will use axis-angle big time. It’svery close to quaternions.

Matthew T. Mason

Page 14: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Rodrigues’s formulaOthers derive Rodrigues’s formula using rotationmatrices: ugly and messy. The geometrical approach isclean and insightful.

I Given point x, decompose intocomponents parallel andperpendicular to the rotation axis

x = n(n · x)� n⇥ (n⇥ x)

I Only x? is affected by the rotation,yielding Rodrigues’s formula:

x

0 = n(n·x)+sin ✓ (n⇥x)�cos ✓ n⇥(n⇥x)

I A common variation:

x

0 = x+(sin ✓) n⇥x+(1�cos ✓) n⇥(n⇥x)

n n x

n n x

n

n xx

x

O

Matthew T. Mason

Page 15: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Rotation matricesI Choose O on rotation axis. Choose frame

(u1, u2, u3).I Let (u0

1, u

02, u

03) be the image of that frame.

I Write the u

0i vectors in ui coordinates, and collect

them in a matrix:

u

01 =

0

@a11a21a31

1

A =

0

@u1 · u

01

u2 · u

01

u3 · u

01

1

A

u

02 =

0

@a12a22a32

1

A =

0

@u1 · u

02

u2 · u

02

u3 · u

02

1

A

u

03 =

0

@a13a23a33

1

A =

0

@u1 · u

03

u2 · u

03

u3 · u

03

1

A

A =�aij

�=

�u

01|u0

2|u03�

Matthew T. Mason

Page 16: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

So many numbers!

I A rotation matrix has nine numbers,I but spatial rotations have only three degrees of

freedom,I leaving six excess numbers . . .

I There are six constraints that hold among the ninenumbers.

|u01| = |u0

2| = |u03| = 1

u

03 = u

01 ⇥ u

02

I i.e. the u

0i are unit vectors forming a right-handed

coordinate system.I Such matrices are called orthonormal or rotation

matrices.

Matthew T. Mason

Page 17: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Rotating a point

I Let (x1, x2, x3) be coordinates of x in frame(u1, u2, u3).

I Then x

0 is given by the same coordinates taken inthe (u0

1, u

02, u

03) frame:

x

0 =x1u

01 + x2u

02 + x3u

03

=x1Au1 + x2Au2 + x3Au3

=A(x1u1 + x2u2 + x3u3)

=Ax

I So rotating a point is implemented by ordinary matrixmultiplication.

Matthew T. Mason

Page 18: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Sub- and superscript notation for rotating apoint

I Let A and B be coordinate frames.I Let A

x be coordinates in frame A.I Let B

AR be the rotation matrix that rotates frame B toframe A.

I Then (see previous slide) BAR represents the rotation

of the point x :B

x

0 = BAR B

x

I Note presuperscripts all match. Both points, andxform, must be written in same coordinate frame.

Matthew T. Mason

Page 19: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Coordinate transform

There is another use for BAR:

I Ax and B

x represent the same point, in frames A andB resp.

I To transform from A to B:

Bx = B

AR Ax

I For coord xform, matrix subscript and vectorsuperscript “cancel”.

Rotation from B to A is the same as coordinate transformfrom A to B.

Matthew T. Mason

Page 20: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Nice things about rotation matrices

I Composition of rotations: {R1; R2} = R2R1.({x ; y} means do x then do y .)

I Inverse of rotation matrix is its transposeBAR�1 = A

BR = BART .

I Coordinate xform of a rotation matrix:

BR = BAR AR A

BR

Matthew T. Mason

Page 21: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Example rotation matrix

BAR =

�B

xAB

yAB

zA�

=

0

@1 0 00 0 �10 1 0

1

A

How to remember what BAR does? Pick a

coordinate axis and see. The x axis isn’tvery interesting, so try y :

0

@1 0 00 0 �10 1 0

1

A

0

@010

1

A =

0

@001

1

A

Matthew T. Mason

Page 22: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Converting rot(n, ✓) to R

I Ugly way: define frame with z aligned with n, usecoordinate xform of previous slide.

I Keen way: Rodrigues’s formula!

x

0 = x + (sin ✓) n⇥ x + (1� cos ✓) n⇥ (n⇥ x)

I Define “cross product matrix” N:

N =

0

@0 �n3 n2n3 0 �n1�n2 n1 0

1

A

so thatNx = n⇥ x

Matthew T. Mason

Page 23: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

. . . using Rodrigues’s formula . . .

I Substituting the cross product matrix N intoRodrigues’s formula:

x

0 = x + (sin ✓)Nx + (1� cos ✓)N2x

I Factoring out x

R = I + (sin ✓)N + (1� cos ✓)N2

I That’s it! Rodrigues’s formula in matrix form. If youwant to you could expand it:0

@n2

1 + (1� n21)c✓ n1n2(1� c✓)� n3s✓ n1n3(1� c✓) + n2s✓

n1n2(1� c✓) + n3s✓ n22 + (1� n2

2)c✓ n2n3(1� c✓)� n1s✓n1n3(1� c✓)� n2s✓ n2n3(1� c✓) + n1s✓ n2

3 + (1� n23)c✓

1

A

where c✓ = cos ✓ and s✓ = sin ✓. Ugly.

Matthew T. Mason

Page 24: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Converting from R to rot(n, ✓) . . .

I Problem: n isn’t defined for ✓ = 0.I We will do it indirectly. Convert R to a unit quaternion

(next lecture), then to axis-angle.

Page 25: Rotation - University of Pennsylvania

Quaternion Notes by HyunSoo Park

Page 26: Rotation - University of Pennsylvania

Euler Equation

Recall Euler’s 2D rotation representation

X

Y( ) = cos sinexp i + i

This can be interpreted as a rotation about Z axis with .

Page 27: Rotation - University of Pennsylvania

Quaternion

X

Y

Z

⎡ ⎤⎢ ⎥= ⎢ ⎥⎢ ⎥⎣ ⎦

eX

Y

Z

eee

( )⎛ ⎞ = + +⎜ ⎟⎝ ⎠e X Y Ze e eexp + i j kcos sin2 2 2

q3D rotation via a quaternion is to rotate about e axis with

We will see why . 2/

Page 28: Rotation - University of Pennsylvania

Quaternion, inverse of rotation

X

Y

Z⎡ ⎤⎢ ⎥= − ⎢ ⎥⎢ ⎥⎣ ⎦

-eX

Y

Z

eee

( )

-− ⎛ ⎞⎜ ⎟⎝ ⎠

= + +

q = e

X Y Ze e e

exp

- i j k

1

2

cos sin2 2

Page 29: Rotation - University of Pennsylvania

Quaternion’s Topological SpaceY

X

=Ze 0 ⎡ ⎤⎢ ⎥= ⎢ ⎥⎢ ⎥⎣ ⎦

eX

Y

ee0

Torus: ×S S

Page 30: Rotation - University of Pennsylvania

Quaternion’s Topological SpaceY

X

⎡ ⎤⎢ ⎥= ⎢ ⎥⎢ ⎥⎣ ⎦

eX

Y

Z

eee High dimensional torus: ×2S S

Z

A slice in X, Y, or Z direction produces 2D torus.

Page 31: Rotation - University of Pennsylvania

ExerciseFind q such that q describes a rotation of 60 degrees about d = [3, 4, 0].

X

Y

Z

[ ]/= =e d d T3/ 5 4 / 5 0

3=

= = =q13cos cos

2 6 2

ˆ ⎛ ⎞= = = = +⎜ ⎟⎝ ⎠

q e e e i j1 1 3 4sin sin2 6 2 2 5 5

/= =e d d 3 4+5 5i j

⎛ ⎞= + +⎜ ⎟⎝ ⎠

q i j3 1 3 42 2 5 5

ˆ = +q X Y Zq q qi j + kwhere

Page 32: Rotation - University of Pennsylvania

Quaternion Algebra

= + + +q X Y Ze e ecos sin sin sin2 2 2 2i j k

= = = =2 2 2 -1i j k ijkwhere

i

jk

Quaternion product

( )( )( ) ( )( ) ( )

( ) ( )ˆ ˆ ˆ ˆ ˆ ˆ

= + + + + + +

= − − − + + + −

+ − + + + + − +

= − ⋅ + + + ×

qp

q p p q q p

W X Y Z W X Y Z

W W X X Y Y Z Z W X X W Y Z Z Y

W Y X Z Y W Z X W Z X Y Y X Z W

W W W W

q q q q p p p p

q p q p q p q p q p q p q p q p

q p q p q p q p q p q p q p q p

q p q p

i j k i j k

i

j kˆ = +q X Y Zq q qi j + kwhere

Page 33: Rotation - University of Pennsylvania

Lecture 8.Quaternions

Overview,motivation

Background

Definition andproperties

Rotation using unitquaternions

Intuition

Using quaternionsto representrotations

Why we lovequaternions.

Basis element multiplication

From that one axiom, we can derive other products:

ijk = �1i(ijk) = i(�1)

�jk = �ijk = i

Writing them all down:

ij = k , ji = �kjk = i , kj = �iki = j , ik = �j

Quaternion products of i , j , k behave like cross product.

Matthew T. Mason

Page 34: Rotation - University of Pennsylvania

Lecture 8.Quaternions

Overview,motivation

Background

Definition andproperties

Rotation using unitquaternions

Intuition

Using quaternionsto representrotations

Why we lovequaternions.

Conjugate, lengthDefinition (Conjugate)

q⇤ = q0 � q1i � q2j � q3k

Note that

qq⇤ = (q0 + q)(q0 � q)

= q20 + q0q� q0q� qq

= q20 + q · q� q⇥ q

= q20 + q2

1 + q22 + q2

3

Definition (Length)

|q| =p

qq⇤ =q

q20 + q2

1 + q22 + q2

3

Matthew T. Mason

Page 35: Rotation - University of Pennsylvania

Lecture 8.Quaternions

Overview,motivation

Background

Definition andproperties

Rotation using unitquaternions

Intuition

Using quaternionsto representrotations

Why we lovequaternions.

Quaternion inverse

Every quaternion except 0 has an inverse:

q�1 =q⇤

|q|2

Without commutativity, quaternions are a division ring, ora non-commutative field, or a skew field.Just as complex numbers are an extension of the reals,quaternions are an extension of the complex numbers(and of the reals).If 1D numbers are the reals, and 2D numbers are thecomplex numbers, then 4D numbers are quaternions, andthat’s all there is. (Frobenius) (Octonions are notassociative.)

Page 36: Rotation - University of Pennsylvania

Quaternion Composition Example

Y

XZ

Z

XY

Z

X

Y

Rotating 90 degrees about Y axis. Rotating 90 degrees about Z axis.

/ /= +q1

2 2cos sin2 2

j / /= +q2

2 2cos sin2 2

k =q qq12 1 2 ?

Page 37: Rotation - University of Pennsylvania

Quaternion Composition Example

Y

XZ

= +q12 22 2

j = +q22 22 2

k

Y

XZ

23

=

( )e= + +13i j k

Rotating about (1,1,1) axis with 120 degrees.

=1cos

2 2 =3sin

2 223

=

=

⎛ ⎞⎛ ⎞= + +⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠⎝ ⎠

= + + +

⎛ ⎞= + + +⎜ ⎟

⎝ ⎠

q qq12 1 2

2 2 2 22 2 2 2

1 1 1 12 2 2 21 3 1 1 12 2 3 3 3

j k

i j k

i j k

Page 38: Rotation - University of Pennsylvania

Rotating a Point via QuaternionHamiltonian product

Representing a 3D point in quaternion representation with zero angle.

= + + +p X Y Zp p p0 i j kRotation via quaternion:ʹ =p qpq-1 = − − −q X Y Ze e e-1 cos sin sin sin

2 2 2 2i j kwhere

Y

XZ

q

q-1( )( ) ( ) ( )

ˆ ˆ ˆ

ˆ ˆ ˆ

ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ ˆ

ˆ ˆ ˆ⊥ ⊥

ʹ

⎛ ⎞ ⎛ ⎞= + −⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

= − ⋅ + × + ⋅

= + +q q q

p = qpq

q p q

p q p q q p q p q

p p pP

-1

1 2

cos sin cos sin2 2 2 2

cos sin

cos sin

Page 39: Rotation - University of Pennsylvania

Geometric Interpretation

( )( ) ( ) ( )ˆ ˆˆ

ˆ ˆ ˆ

ˆ ˆ

ˆ

ˆ ˆ ˆ ˆ ˆ ˆ ˆ

ˆ ˆ⊥⊥

ʹ

⎛ ⎞ ⎛ ⎞= + −⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

= − ⋅ + × + ⋅

= + + qqq

p = qpq

q p q

p q p q q p q p q

p pp P

-

1

1

2

cos sin cos sin2 2 2 2

cos sin

cos sin

Y

X

Z

q

ˆp= p

ˆˆ⊥qp1

ˆˆ⊥qp2

ˆˆ qpP

ʹp

Page 40: Rotation - University of Pennsylvania

ExampleY

XZ

23

=

( )e= + +13i j k

→X Y →Y Z →Z X

q= 1+ + +2

i j k p= +i j

p= +i j

( )

( )( )

( )( )

( )

( )

ʹ =

− − −⎛ ⎞ ⎛ ⎞= ⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

= − − − − − − −

= − − − −

= + + − −

= + = +

p qpq-1

1+ + + 1+2 2

1 + 1+ 1+ 141 2 2 141 2 2 2 2 2+2 +2 +241 4 44

i j k i j ki j

i j k k j i i j k

j i j k

j k i i j k

j k j k

Y

XZ

23

=

p= +i jʹp = +j k

Page 41: Rotation - University of Pennsylvania

Quaternion to Rotation Matrix( )( )( )

( ) ( ) ( )( )( ) ( ) ( )( )( ) ( ) ( )( )

ʹ =

= + + + − − −

= − − + − + + +

+ + + − − + −

+ − + + + − −

p qpq

W X Y Z X Y Z W X Y Z

z z y y X z w y x Y y w z x Z

x y w z X z z x x Y z y x w Z

x z w y X y z w x Y y y x x Z

q q q q p p p q q q q

1 2q q 2q q p 2q q 2q q p 2q q 2q q p

2q q 2q q p 1 2*q q 2q q p 2q q 2q q p

2q q 2q q p 2q q 2q q p 1 2q q 2q q p

-1

+ +i j k i j k i j k

i

j

k

ʹ ⎡ ⎤− − − + +⎡ ⎤ ⎡ ⎤⎢ ⎥⎢ ⎥ ⎢ ⎥ʹ = + − − −⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥ʹ⎢ ⎥ ⎢ ⎥− + − −⎣ ⎦ ⎣ ⎦⎣ ⎦

X z z y y z w y x y w z x X

Y x y w z z z x x z y x w Y

Z x z w y y z w x y y x x Z

p 1 2q q 2q q 2q q 2q q 2q q 2q q pp 2q q 2q q 1 2*q q 2q q 2q q 2q q pp 2q q 2q q 2q q 2q q 1 2q q 2q q p

R

Y

XZ 23

=

+ + +q= 12i j k ⎡ ⎤

⎢ ⎥⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥ ⎣ ⎦

⎢ ⎥⎢ ⎥⎣ ⎦

R= =

2 2 2 2 2 21- - - + +4 4 4 4 4 4 0 0 12 2 2 2 2 2+ 1- - - 1 0 04 4 4 4 4 4

0 1 02 2 2 2 2 2- + 1- -4 4 4 4 4 4 Permutation matrix

Page 42: Rotation - University of Pennsylvania

Quaternion to Rotation MatrixLecture 8.

Quaternions

Overview,motivation

Background

Definition andproperties

Rotation using unitquaternions

Intuition

Using quaternionsto representrotations

Why we lovequaternions.

From quaternion to rotation matrix

Just expand the product

qxq⇤ =0

@q2

0 + q21 � q2

2 � q23 2(q1q2 � q0q3) 2(q1q3 + q0q2)

2(q1q2 + q0q3) q20 � q2

1 + q22 � q2

3 2(q2q3 � q0q1)2(q1q3 � q0q2) 2(q2q3 + q0q1) q2

0 � q21 � q2

2 + q23

1

Ax

Page 43: Rotation - University of Pennsylvania

Lecture 8.Quaternions

Overview,motivation

Background

Definition andproperties

Rotation using unitquaternions

Intuition

Using quaternionsto representrotations

Why we lovequaternions.

From rotation matrix to quaternion

Given R = (rij), solve expression on previous slide forquaternion elements qi

Linear combinations of diagonal elements seem to solvethe problem:

q20 =

14(1 + r11 + r22 + r33)

q21 =

14(1 + r11 � r22 � r33)

q22 =

14(1� r11 + r22 � r33)

q23 =

14(1� r11 � r22 + r33)

so take four square roots and you’re done? You have tofigure the signs out. There is a better way . . .

Page 44: Rotation - University of Pennsylvania

Lecture 8.Quaternions

Overview,motivation

Background

Definition andproperties

Rotation using unitquaternions

Intuition

Using quaternionsto representrotations

Why we lovequaternions.

Look at the off-diagonal elements

I

q0q1 =14(r32 � r23)

q0q2 =14(r13 � r31)

q0q3 =14(r21 � r12)

q1q2 =14(r12 + r21)

q1q3 =14(r13 + r31)

q2q3 =14(r23 + r32)

I Given any one qi , could solve the above for the otherthree.

Page 45: Rotation - University of Pennsylvania

Lecture 8.Quaternions

Overview,motivation

Background

Definition andproperties

Rotation using unitquaternions

Intuition

Using quaternionsto representrotations

Why we lovequaternions.

The procedure

1. Use first four equations to find the largest q2i . Take its

square root, with either sign.2. Use the last six equations (well, three of them

anyway) to solve for the other qi .

I That way, only have to worry about getting one signright.

I Actually q and �q represent the same rotation, so noworries about signs.

I Taking the largest square root avoids division bysmall numbers.

Page 46: Rotation - University of Pennsylvania

Axis-angle <-> Rotation Matrix

• Axis-angle -> Rotation of point with Rodrigues formula -> convert to Rotation matrix with same formula

• Rotation Matrix -> Quaternion -> Axis-angle

Page 47: Rotation - University of Pennsylvania

Lecture 7.Representing

Rotation

Kinematicrepresentation:goals, overview

Planardisplacements

Spatial rotationsPreview

Axis-angle

Rodrigues’s formula

Rotation matrices

Euler angles

Rodrigues’s formula for differential rotations

Consider Rodrigues’s formula for a differential rotationrot(n, d✓).

x

0 =(I + sin d✓N + (1� cos d✓)N2)x

=(I + d✓N)x

so

dx =Nx d✓

=n⇥ x d✓

It follows easily that differential rotations are vectors: youcan scale them and add them up. We adopt theconvention of representing angular velocity by the unitvector n times the angular velocity.

Page 48: Rotation - University of Pennsylvania

• https://vimeo.com/49145144

• https://vimeo.com/48948064