Four different ways to represent

my head is spinning... The of

SO( 3) = {R ∈ R3×3 | RRT = I,det(R) = +1}

Special (3):

Why det( R ) = ± 1 ?

− = − Rotations preserve distance: Rp1 Rp2 p1 p2

Rotations preserve : ( ) × ( ) = ( × ) Rp1 Rp2 R p1 p2 The space of rotations

SO( 3) = {R ∈ R3×3 | RRT = I,det(R) = +1}

Special orthogonal group(3):

Why it’s a group: • Closed under multiplication: if ∈ ( ) then ∈ ( ) R1, R2 SO 3 R1R2 SO 3 • Has an identity: ∃ ∈ ( ) = I SO 3 s.t. IR1 R1 • Has a unique inverse… • Is associative…

Why orthogonal: • vectors in are orthogonal Why it’s special: det( R ) = + 1 , NOT det(R) = ±1

Right hand 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 • ZYX (roll, pitch, yaw) • Axis One four-number representation: • ZYZ Euler Angles

φ    = θ rzyz     ψ   φ − φ  cos sin 0 To get from A to B: φ = φ φ Rz ( )  sin cos 0   1. Rotate φ about z axis  0 0 1  θ θ  2. Then rotate θ about y axis  cos 0 sin  θ =   ψ Ry ( ) 0 1 0 3. Then rotate about z axis   − sinθ 0 cosθ   ψ − ψ  cos sin 0 ψ = ψ ψ Rz ( )  sin cos 0    0 0 1 ZYZ Euler Angles

φ θ ψ Remember that R z ( ) R y ( ) R z ( ) encode the desired rotation in the pre- rotation reference frame: φ = pre−rotation Rz ( ) Rpost−rotation

Therefore, the sequence of rotations is concatentated as follows: (φ θ ψ ) = φ θ ψ Rzyz , , Rz ( )Ry ( )Rz ( )

 φ − φ  θ θ  ψ − ψ  cos sin 0 cos 0 sin cos sin 0 (φ θ ψ ) = φ φ ψ ψ Rzyz , ,  sin cos 0 0 1 0  sin cos 0      0 0 1− sinθ 0 cosθ  0 0 1  − − −  cφ cθ cψ sφ sψ cφ cθ sψ sφ cψ cφ sθ  (φ θ ψ ) =  + − +  Rzyz , , sφ cθ cψ cφ sψ sφ cθ sψ cφ cψ sφ sθ  −   sθ cψ sθ sψ cθ  ZYX Euler Angles (roll, pitch, yaw)  φ − φ  cos sin 0 To get from A to B: φ = φ φ Rz ( )  sin cos 0   1. Rotate φ about z axis  0 0 1  θ θ  2. Then rotate θ about y axis  cos 0 sin  θ =   ψ Ry ( ) 0 1 0 3. Then rotate about x axis   − sinθ 0 cosθ    1 0 0  ψ = ψ − ψ Rx ( ) 0 cos sin    0 sinψ cosψ  (φ θ ψ ) = φ θ ψ Rzyx , , Rz ( )Ry ( )Rx ( )  φ − φ  θ θ   cos sin 0 cos 0 sin 1 0 0  (φ θ ψ ) = φ φ ψ − ψ Rzyz , ,  sin cos 0 0 1 0 0 cos sin       0 0 1− sinθ 0 cosθ 0 sinψ cosψ  ZYX Euler Angles (roll, pitch, yaw)

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

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 (φ θ ψ ) = φ θ ψ Rzyx , , Rz ( )Ry ( )Rx ( ) 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  =  =    r1 90  r2 89       0  90  −    90  − =     r1 r2 1 , but the actual distance is 1    − 90  Problem w/ Euler Angles: 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 Problem w/ Euler Angles: Problem w/ Euler Angles: gimbal lock Axis-angle representation

Theorem: (Euler). Any orientation, R ∈ SO ( 3 ) , is equivalent to a rotation about a fixed axis, ω ∈ R 3 , through an angle θ ∈[0,2π )

(also called exponential coordinates)

 k   x  = Angle: θ Axis: k k y     kz 

Converting to a :

= S ( k )θ = + ( ) (θ ) + ( ) 2 ( − (θ ) ) Rkθ e I S k sin S k 1 cos = [ that equation in the book...]

Rodrigues’ formula Axis-angle representation

Converting to axis angle: − −1 trace(R) 1 Magnitude of rotation: θ = k = cos    2   −  r32 r23 1   Axis of rotation: kˆ =  r − r  2sinθ 13 31  −   r21 r12   r r r   11 12 13  Where: = R r12 r22 r23    r13 r23 r33 

and: = + + trace(R) r11 r22 r33 Axis-angle representation

Axis angle is can be encoded by just three numbers instead of four:  k If k ≠ 0 then kˆ =  and θ = k k

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

For most orientations, , is unique. Rk

For rotations of 180  , there are two equivalent representations: =  = If k 180 then Rk R−k Axis-angle problems

Still suffers from the “edge” and distance preserving problems of Euler angles:    0   0   0  − =     r1 r2  0  r =  0  =    1 r2  0  358       179  −179  , but the actual distance is 2

Distance metric changes as you get further from origin. Projection distortions Example: differencing rotations

 π   0  Calculate the difference between  2    = =  π  these two rotations: k1  0  k2 2      0   0 

 π   2  This is NOT the right answer: − = − π k1 k2  2     0 

π According to that, this is the k − k = =127.27 magnitude of the difference: 1 2 2 Example: differencing rotations

Convert to rotation matrices to solve this problem:  π   0   2    π 1 B T B =   k =   R = R R k1 0 2 2 2 1 2      0   0      1 0 0  1 0 0  b = ( π ) = ( π ) − ( π ) = − R1 Rx 2 0 cos 2 sin 2  0 0 1  ( π ) ( π )    0 sin 2 cos 2  0 1 0   cos( π ) 0 sin( π )   0 0 1  2 2    b = ( π ) = = R2 Ry 2  0 1 0   0 1 0 − ( π ) ( π )  −   sin 2 0 cos 2   1 0 0      1 0 0 0 0 1  0 0 1 1 =B T B = = − R2 R1 R2 0 0 1 0 1 0  1 0 0      0 −1 0−1 0 0  0 −1 0  −  −  r32 r23 1 −1     2   −  trace(R) −1 −  1  1 1 π θ = 1  = 1−  = 2 π ˆ = − = 3 cos cos 3 k  r13 r31   1  k =  1   2   2  2sinθ  −  3 −  3    r21 r12   1 −1 Quaternions

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?

Answer: quaternions… Quaternions

= + + + Generalization of complex numbers: Q q0 iq1 jq2 kq3 = ( ) Q q0 ,q

Essentially a 4-dimensional quantity

Properties of complex ii = jj = kk = ijk = −1 jk = −kj = i : ij = − ji = k ki = −ik = j

= ( + + + )( + + + ) Multiplication: QP q0 iq1 jq2 kq3 p0 ip1 jp2 kp3 = ( − ⋅ + + × ) QP p0q0 p q, p0q q0 p p q

* Complex conjugate: * = ( ) = ( − ) Q q0 ,q q0 , q Quaternions

Invented by Hamilton in 1843:

Along the royal canal in Dublin… Quaternions

Let’s consider the set of unit quaternions: 2 = 2 + 2 + 2 + 2 = Q q0 q1 q2 q3 1

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

The identity is: Q = (1,0)

* = ( )( − ) = ( − 2 − + × ) = Since: QQ q0 ,q q0 , q q0q0 q ,q0q q0q q q (1,0)

− Therefore, the inverse of a unit quaternion is: Q* = Q 1 Quaternions

Associate a rotation with a unit quaternion as follows:

Given a unit axis, k ˆ , and an angle, θ : (just like axis angle)  θ  θ  =  ˆ  The associated quaternion is: Q ˆ cos ,k sin  k,θ   2   2  Therefore, Q represents the same rotation as − Q

i Let i P = ( 0 , i p ) be the quaternion associated with the vector p

You can rotate a from frame a to b: b = a * P P Qba PQba = Composition: Qca QcbQba = −1 Inversion: Qcb QcaQba Example: Quaternions      0   1    Rotate a by Q =  1 , 1  P = 0,0 2 2        0   0     0  1  0         b P =QaPQ* =  1 , 1 0,0 1 ,− 1   2  2    2  2    0  0  0    0   1      2  =  1 , 1 0, 0   2  2    0  − 1      2    1  − 1    0    2   2     = 0, 0  +  0  = 0, 0      − 1  − 1  −    2   2    1 Example: Quaternions  π   0  Find the difference between these two axis angle  2    = = π rotations: k1  0  k2  2       0   0 

    1   0    π π 1     2  ( ) = ( ) = Q =  1 , 1  =  1   sin 4 cos 4 cb 2 2 Qba , 0 2     2     0    0 

= ( − ⋅ + + × ) QP p0q0 p q, p0q q0 p p q   0  − 1    2  −     = 1 = 1 1  1  Qcb QcaQba  ,  , 0   2  2  2     0   0  θ = −1( 1 ) = 2 π cb cos 2 3  − 1   − 1    2 − 1   2        1 1 1  1 1 3 = ,   =  ,  1 2 2 2 2 2 k =         cb  3   − 1  − 1  1    2  −   2   3  Quaternions: Interpolation

Suppose you’re given two rotations, and R1 R2 How do you calculate intermediate rotations? R = αR + (1−α ) R This does not even result in a rotation i 1 2 matrix

Do quaternions help? αQ + (1−α )Q Suprisingly, this actually works Q = 1 2 i α + ( −α ) • Q1 1 Q2 Finds a geodesic

This method normalizes automatically (SLERP): Q sin(1−α )Ω + Q sinαΩ Q = 1 2 i sin Ω