Lec 18
Lec 18
These lecture summaries are designed to be a review of the lecture. Though I do my best to include all main topics from the
lecture, the lectures will have more elaborated explanations than these notes.
1 Lecture 18: Rotation and How to Represent it, Unit Quaternions, the Space
of Rotations
Today, we will focus on rotations. Note that unlike translations, rotations are not commutative, which makes fitting
estimates to data, amongst other machine vision tasks, more challenging. In this lecture, we will cover rotation in terms of:
• Properties
• Representations
• Hamilton’s Quaternions
• Rotation as Unit Quaternion
• Space of rotations
• Photogrammetry
• Closed-form solution of absolute quaternions
• Recognition/orientation
• Graphics/CAD
• Virtual Reality
• Protein Folding
• Vehicle Attitude
• Robotics
• Spatial Reasoning
• Path Planning - Collision Avoidance
1
1.1 Euclidean Motion and Rotation
Rotation and translation form Euclidean motion. Some properties of Euclidean motion, including this property. Euclidean
motion:
• Preserves handedness
• Preserves dot-products
– Reflections
– Skewing
– Scaling
• Euler’s Theorem: There is a line of fixed points that remain the same in any rotation. This is known as the axis of
rotation.
• Parallel axis theorem: Any rotation is equivalent to rotation through the origin along with a translation. This allows
for the decoupling between translation and rotation.
• Rotation of sphere includes rotation of space: I.e, any rotation that is induced on a space can be induced on an
equivalent-dimensional sphere.
• Attitude, Orientation - Rotation Relative to Reference: This helps for determining the orientation of objects
relative to another frame of reference.
• Rotational velocity can be described by a vector. This set of rotational vectors together form a lie algebra, specifically,
so(3). The set of rotations form the counterpart to this lie algebra, namely the Special Orthogonal group SO(3), which
is a Lie group. If you are not familiar with Lie groups/algebras, here are a few useful terms to get started with these
concepts:
– A group is a set equipped with a binary operation that combines any two elements to form a third element in such a
way that four conditions called group axioms are satisfied, namely closure, associativity, identity and invertibility [1].
– A manifold is a d-dimensional topological space that locally resembles Euclidean space at each point i.e. any patch
of the manifold can be “locally” approximated as a d-dimensional Euclidean space [2].
– A Lie group is a group that is also a differentiable manifold. One key Lie group that we will study in this course is
the Special Orthogonal group, known as SO(3), which is the space of orthonormal rotation matrices.
• We can define the derivative of the radius vector ṙ using Poisson’s Formula: ṙ = ω̂ × r
• Rotational velocities add - this holds because these vectors belong to Lie algebras
• Finite rotations do not commute - this holds because rotations are defined by Lie groups in a non-Euclidean space.
n(n−1)
• The Degrees of Freedom for rotation in dimension n is given by 2 , which coincidentally equals 3 in 3 dimensions.
• Intuition: Oftentimes, it is easier to think about rotation “in planes”, rather than “about axes”. Rotations preserve
points in certain planes.
2
1.2.1 Isomorphism Vectors and Skew-Symmetric Matrices
A technical note that is relevant when discussing cross products: Although a cross product produces a vector in 3D, in higher
dimensions the result of a cross product is a subspace, rather than a vector.
Specifically, this subspace that forms the result of a higher-dimensional cross product is the space that is perpendicu-
lar/orthogonal to the two vectors the cross product operator is applied between.
With this set up, we can think of cross products as producing the following isomorphism vectors and skew-symmetric ma-
trices: One Representation:
a × b = Ab
⎡ ⎤
0 −az ay
A = ⎣ az 0 −ax ⎦
−ay ax 0
An Isomorphic Representation:
a × b = B̄a
⎡ ⎤
0 bz −by
A = ⎣−bz 0 bx ⎦
by −bx 0
Note that while these skew-symmetric matrices have 9 elements as they are 3 × 3 matrices, they only have 3 DOF.
2. Euler Angles
3. Orthonormal Matrices
4. Exponential cross product
8. Unit Quaternions
3
1.3.3 Orthonormal Matrices
We have studied these previously, but these are the matrices that have the following properties:
3. R ∈ SO(3) (see notes on groups above) - being a member of this Special Orthogonal group is contingent on satisfying the
properties above.
R = eθΩ
Taking the Taylor expansion of this expression, we can write this matrix exponential as:
R = eθΩ
∞
X 1
= (θΩ)i
i=0
i!
∞
X θi
= T
(VΩ ΛiΩ VΩ T
) (Taking an eigendecomposition of Ω = VΩ ΛΩ VΩ )
i=0
i!
(Optional) Let us look a little deeper into the mathematics behind this exponential cross product. We can write a rotation about
ω̂ through angle θ as:
r = R(θ)r0
dr d
= (R(θ)r0 )
dθ dθ
dr
= ω̂ × r = Ωr = ΩR(θ)r0
dθ
d
R(θ)r0 = ΩR(θ)r0
dθ
Then for all r0 :
d
R(θ) = ΩR(θ) =⇒ R(θ) = eθΩ
dθ
• This plane is treated as a complex plane that we can apply homogeneous transforms to.
We can conceptually visualize this mapping from a sphere to the complex plane using the figure below:
Figure 1: Mapping from a sphere to a complex plane, which we then apply a homogeneous transformation to and map back to
the sphere in order to induce a rotation.
4
Specifically, the homogeneous transform we consider maps the complex variable z to z 0 :
az + b
z0 = , for some a, b, c, d ∈ C
cz + d
We can actually generalize this framework even further - any rotation in 3-space can be thought of as an operation in a complex
plane.
Figure 2: Geometric interpretation of the Rodrigues formula: Rotation about the vector ω̂ through an angle θ.
One disadvantage of this approach is that there is no way to have compositions of rotations.
Next, let us take an in-depth analysis of the Rodrigues Formula and the Exponential Cross Product:
dR
= ΩR =⇒ R = eΩθ
dθ
∞
X θi
1
eΩθ = I + θΩ + (θΩ)2 + ... = Ωi
2! i=0
i!
5
Next, we have that:
Ω2 = (ω̂ω̂ T − I)
Ω3 = −Ω
r = eθΩ r
r0 = (cos θ)r + (1 − cos θ)(ω̂ · r)ω̂ + sin θ(ω̂ × r)
1.6 Quaternions
In this section, we will discuss another way to represent rotations: quaternions.
6
1.6.1 Hamilton and Division Algebras
Goal: Develop an algebra where we can use algebraic operations such as addition, subtraction, mulitplication, and division.
1. Hamilton’s representation is motivated by Algebraic couples, for instance, complex numbers as pairs of reals a + bi, a − bi
4. Expected next: Three conponents (vectors) - note that this was before Gibb’s vector and 3-vectors
Hamilton’s insight here is that these quaternions require a “4th dimension for the sole purpose of calculating triples”.
1. i2 = j 2 = k 2 = ijk = −1
(a) ij = k
(b) jk = i
(c) ki = j
(d) ji = −k
(e) kj = −i
(f) ik = −j
Note: As you can see from these properties, multiplication of the components of these quaternions is not commutatitve.
5. Complex Composite of Two Complex Numbers: Here, we have (a + bi) and (c + di), and we replace all the real
constants a, b, c, d with complex numbers. We can build sophisticated algebras from these operations.
7
2. Scalar and 3-Vector:
Note: Here we also have an isomorphism between the quaternion and the 4 x 4 orthogonal matrix (this matrix is or-
thonormal if we have unit quaternions). Here we can show the isomorphism and relate this back to the cross product we
saw before by considering the equivalence of the two following righthand-side expressions:
⎡ ⎤
p0 −px −py −pz
oo o ⎢px p0 −pz py ⎥
(a) pq = P q, where P = ⎢ ⎥
⎣py pz p0 −px ⎦
pz −py px p0
⎡ ⎤
q0 −qx −qy −qz
oo o ⎢qx q0 qz −qy ⎥
(b) pq = q̄p, where q̄ = ⎢
⎣qy −qz
⎥
q0 qx ⎦
qz qy −qx q0
A few notes about these matrices P and q̄:
• These matrices are orthonormal if quaternions are unit quaternions
o o
• P is normal if p is a unit quaternion, and q̄ is normal if q is a unit quaternion.
o o
• P is skew-symmetric if p has zero scalar part, and q̄ is skew-symmetric if q has zero scalar part.
• P and q̄ have the same signs for the first row and column, and flipped signs for off-diagonal entries in the bottom
right 3 x 3 blocks of their respective matrices.
8
oo oo o o o o
2. (pq) · (pr) = (p · p)(q · r)
oo o o o o∗
3. (pq) · r = p · (rq )
We can also represent these quaternions as vectors. Note that these quaternions all have zero scalar component.
o
1. r = (0, r)
o∗
2. r = (0, −r)
o o
3. r · s = r · s
oo
4. rs = (−r · s, r × s)
oo o o oo
5. (rs) · t = r · (st) = [r s t] (Triple Products)
oo o
6. rr = −(r · r)e
Another note: For representing rotations, we will use unit quaternions. We can represent scalars and vectors with:
• Representing scalars: (s, 0)
• Representing vectors: (0, v)
9
1.7.1 Relation of Quaternion Rotation Operation to Rodrigues Formula
Let us see how this operator relates to the Rodrigues formula and the axis-angle representation of rotations:
• (q 2 − q · q) = cos θ
• 2||q||22 = (1 − cos θ)
• 2q||q||22 = sin θ2
�
• q = cos θ2
�
• ||q||22 = sin θ2
�
o �θ �θ
q = (cos , ω̂ sin )
2 2
A few notes on this:
o
• We see that both the scalar and vector components of the quaternion q depend on the axis of rotation ω̂ and the angle of
rotation θ.
• The vector component of this quaternion is parallel to ω̂.
• Knowing the axis and angle of a rotation allows us to compute the quaternion.
o o
• Note that −q represents the same mapping as q since:
o o o∗ o o o∗
(−q)r(−q ) = qrq
To build intuition with this quaternion rotation operator, one way we can conceptualize this is by considering that our space
of rotations is a 3D sphere in 4D, and opposite points on this sphere represent the same rotation.
We will start by applying this to our first problem, absolute orientation. Recall our goal with this photogrammetry problem
is to find the 3D transformation between our coordinate systems.
10
1.8.1 Least Squares Approach to Find R
Recall our first attempt to solve for this transformation was done through least squares to solve for an optimal rotation matrix
and a translation vector. While we showed in lecture 17 that we can solve for an optimal translation vector that depends on the
rotation matrix R, we could not find a closed-form solution for the rotation matrix R. We review why:
n
X n
X
min +R ||ei ||22 = (r0r,i − R(r0l,i )(r0r,i − R(r0l,i ))
i=1 i=1
Xn n
X n
X
= ||r0r,i ||22 − 0
(rr,i 0
− R(rl,i )) − 0
||rl,i ||22
i=1 i=1 i=1
Where the first of these terms is fixed, the second of these terms is to be maximized (since there is a negative sign in front of
this term, this thereby minimizes the objective), and the third of these terms is fixed. Therefore, our rotation problem can be
simplified to:
n
X n
X
R∗ = min ||ei ||22 = −2 (r0r,i − R(rl,i
0
)) (1)
R
i=1 i=1
n
X
= min(−2 r0r,i · R(rl,i
0
)) (2)
R
i=1
Xn
= max( rb0r,i · R(rl,i
0
)) (3)
R
i=1
But since we are optimizing over an orthonormal rotation matrix R, we cannot simply take the derivative and set it equal to
zero as we usually do for these least squares optimization problems. Though we can solve this as a Lagrangian optimization
problem, specifying these constraints is difficult and makes for a much more difficult optimization problem. It turns out this a
common problem in spacecraft attitude control. Let us see how we can use quaternions here!
Where the term in the sum is a 4 × 4 matrix derived from point cloud measurements.
From here, we can solve for an optimal rotation quaternion through Lagrangian Optimization, with our objective given by:
n
oT o o o Δ
X
T
max
o
q N q, subject to: q · q = 1, N = R̄l,i Rr,i
q i=1
11
Then written with the Lagrangian constraints this optimization problem becomes:
oT o o o
max
o
q N q + λ(1 − q · q)
q
o
Differentiating this expression w.r.t. q and setting the result equal to zero yields the following first-order condition:
o o
2N q − 2λq = 0
It turns out that similarly to our inertia problem from the last lecture, the quaternion solution to this problem is the solution to
an eigenvalue/eigenvector problem. Specifically, our solution is the eigenvector corresponding to the largest eigenvalue of a 4 × 4
real symmetric matrix N constructed from elements of the matrix given by a dyadic product of point cloud measurements from
the left and righthand systems of coordinates:
n
X
M= r0l,i rr,i
0 T
i=1
This matrix M is an asymmetric 3 × 3 real matrix. A few other notes about this:
• The eigenvalues of this problem are the Lagrange Multipliers of this objective, and the eigenvectors are derived from
the eiegenvectors of N , our matrix of observations.
• This analytic solution leads to/requires solving a quartic polynomial - fortunately, we have closed-form solutions of poly-
nomials up to a quartic degree! Therefore, a closed-form solution exists. Specifically, the characteristic equation in this
case takes the form:
λ4 + c3 λ3 + c2 λ2 + c1 λ + c0 = 0
Because the matrix of point cloud measurements N is symmetric, this characteristic equation simplifies and we get the
following coefficients:
1. c3 = tr(N ) = 0
2. c2 = −2tr(M T M )
3. c1 = −8 det |M |
4. c0 = det |N |
In addition to solving absolute orientation problems with quaternions, this approach has applications to other problems as
well, such as:
• Camera Calibration
• Manipulator Kinematics
• Manipulator Fingerprinting
• Spacecraft Dynamics
12
• Computational efficiency
We will discuss this in more detail further below.
• Ability to take derivative w.r.t. rotation - e.g. for optimization and least squares
Yes!
Compared with orthonormal matrices, composing quaternions is faster for this operation (orthonormal matrices require
27 multiplications and 18 additions.
o o o∗
• Operation: Rotating Vectors: qrq
This is given by:
o o o∗
qrq →r0 = (q 2 − r · q)r + 2(q · r)q + 2q(q × r)
r0 = r + 2q(q × r) + 2q × (q × r) (More efficient implementation)
Compared with orthonormal matrices, composing quaternions is slower for this operation (orthonormal matrices require
9 multiplications and 6 additions.
• Operation: Renormalization This operation is used when we compose many rotations, and the quaternion (if we are
using a quaternion) or the orthonormal matrix is not quite an orthonormal matrix due to floating-point arithmetic. Since
this operation requires matrix inversion (see below) for orthonormal matrices, it is much faster to carry out this operation
with quaternions.
o
Nearest Unit Quaternion: √qo o
q·q
1
Nearest Orthonormal Matrix: M (M T M )− 2
• Sampling: Sampling in this space can be done in regular and random intervals
13
• Finite rotation groups: These include the platonic solids with 12, 24, 60 elements - we can have rotation groups for (i)
tetrahedron, (ii) hexahedron/octahedron, and (iii) dodecahedron/icosahedron
• Finer-grade Sampling can be achieved by sub-dividing the simplex in the rotation space
o o0 o0 o o
• If {q i }N N
i=1 is a group, then so is {q i }i=1 , where q i = q 0 q i .
1.10 References
1. Group, ______________________________________________
https://en.wikipedia.org/wiki/Group (mathematics)
2. Manifold, https://en.wikipedia.org/wiki/Manifold
14
MIT OpenCourseWare
https://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms