Four different ways to represent rotation
my head is spinning... The space of rotations SO 3 R R33 | RRT I,det(R) 1
Special orthogonal group(3):
Why det( R ) 1 ?
Rotations preserve distance: Rp1 Rp2 p1 p2
Rotations preserve orientation: Rp1 Rp2 R p1 p2 The space of rotations SO 3 R R33 | 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 matrix are orthogonal Why it’s special: det( R ) 1 , NOT det(R) 1
Right hand coordinate system 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 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 cos 0 sin 2. Then rotate about y axis 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:
prerotation Rz () Rpostrotation
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 cos 0 sin 2. Then rotate about y axis 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 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: 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 Problem w/ Euler Angles: gimbal lock 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 Axis: Angle: k k y kz
Converting to a rotation matrix:
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 r r 32 23 Axis of rotation: ˆ 1 k r13 r31 2sin r21 r12
r11 r12 r13 Where: R r12 r22 r23 r13 r23 r33
and: trace(R) r11 r22 r33 Axis-angle problems
Still suffers from the “edge” and distance preserving problems of Euler angles: 0 0 0 r r 0 1 2 r1 0 r 0 2 358 179 179 , but the actual distance is 2
Distance metric changes as you get further from origin. Axis-angle representation
Axis angle is can be encoded by just three numbers instead of four:
If k 0 then and 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 Rk Projection distortions Example: differencing rotations
2 0 Calculate the difference between k these two rotations: k1 0 2 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: 2 0 1 B T B k1 0 k2 2 R2 R1 R2 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 2 0 sin 2 0 0 1 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 1 1 2 1 trace(R) 1 1 1 2 ˆ 3 cos cos 3 k r13 r31 1 k 1 2 2 2sin 3 r r 1 3 21 12 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 dimensions: 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-sphere S 3
The identity quaternion 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* Q1 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 1 0 1 1 Rotate a by Q , 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 1 2 2 Example: Quaternions
2 0 Find the difference between these two axis angle rotations: k1 0 k2 2 0 0
0 1 2 1 1 1 1 sin cos Qcb , Q , 0 4 4 2 2 2 ba 2 0 0
QP p0q0 p q, p0q q0 p p q
0 1 2 Q Q Q 1 1 , 1 1 , 0 cb ca ba 2 2 2 0 0 1 1 2 cb cos 2 3 1 1 1 2 2 3 1 1 1 1 1 , , 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?
Q1 1 Q2 Suprisingly, this actually works Qi • Q1 1 Q2 Finds a geodesic
This method normalizes automatically (SLERP):
Q1 sin1 Q2 sin Q i sin Supplementary 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 ( )