3D Rotation Representations

Euler-angles

3D rotations can be represented by a sequence of 2D rotations about each axis respectively. Typically, the order is Z, Y, and then X; the angles are denoted by α,β and γ.

Gimbal Lock

When two axes become aligned, applying a rotation around these axes is equivalent to each other, resulting in degree of freedom loss.

Suppose we have β=±π2. If we fix α+γ, the result is unchanged.

Rotation Matrices

A matrix RR3×3 can be used to represent a 3D rotation. However, R should be in the rotation group SO(3), and thus satisfy

RTR=RRT=I,det(R)=1.

With the above constraints, a rotation matrix has actually 3 degrees of freedom.

We can also combine the rotation matrix R and a translation vector t into a transformation matrix

T=[Rt01]R4×4.

When applying this to a vector, note that this vector should be in homogeneous coordinates.

Axis-angles

According to Euler's rotation theorem, any 3D rotation can be specified using two parameters: a unit vector ω that defines the axis of the rotation, and the angle θ that describes the magnitude of the rotation about that axis. The rotated vector can be represented using Rodrigues' formula, which has 3 representations.

Vector Notation

a=cosθa+sinθ(ω×a)+(1cosθ)(ωa)ω.

Matrix Notation

R(ω,θ)=I+sinθ[ω]×+(1cosθ)[ω]×2,

where [ω]× is the skew symmetric matrix of the vector ω.

Exponential Notation

R(ω,θ)=e[ω]×θ.
lemma

If ω=[a,b,c]T, letting K=[ω]×, then
K3=ω22K

proof
K=[0cbc0aba0]K2=[b2c2abcaabc2a2bccabca2b2]K3=[0(a2+b2+c2)c(a2+b2+c2)b(a2+b2+c2)c0(a2+b2+c2)a(a2+b2+c2)b(a2+b2+c2)a0]=ω22K

Therefore, if ω is a unit vector, K3=K

Quaternions

Quaternions are generalized complex numbers of the form:

q=w+xi+yj+zk,

where

i2=j2=k2=ijk=1.

Quaternion products are not reflexible, i.e.
ij=k,ji=k.

A quaternion can also be represented as a scalar with a 3D vector:

q=[wv]T,

where v=[xyz]T.

Quaternion Product

The product of two quaternions is

q1q2=[w1w2v1v2w1v2+w2v1+v1×v2]=[w1w2x1x2y1y2z1z2w1x2+x1w2+y1z2z1y2w1y2x1z2+y1w2+z1x2w1z2+x1y2y1x2+z1w2].

Rotation Quaternions

A quaternion can also be used to represent a rotation:

q=[cosθ2sinθ2ω].

Rotation of vector a can be defined as

a~=qa~q1,

where a~ is a pure quaternion:

a~=[0a].

Quaternion products are equivalent to Rodrigue's formula.

Double Cover Issue

Quaternions have double cover issue that q and q represents the same rotation. If we want to sum to quaternion, we need to calculate if the quaternions are in the same hemisphere.

Dual Quaternions

A dual quaternion has the form

q^=qr+ϵqd,

where qr and qd are ordinary quaternions. qr is the real part, and qd is the dual part. ϵ is the dual unit satisfying ϵ2=0.

q^1q^2=qr1qr2+ϵ(qr1qd2+qr2qd1).

6D Rotation Representation

Also see On the Continuity of Rotation Representations in Neural Networks.

Represent a 3D rotation with two 3D vectors a1 and a2, which makes sure continuity in the representation space.

Conversion Between Representations

From Euler-angles to Rotation Matrices

Given Euler-angles α,β,γ, we can define the rotation matrix about each axis:

Rx=[1000cosαsinα0sinαcosα];Ry=[cosβ0sinβ010sinβ0cosβ];Rz=[cosγsinγ0sinγcosγ0001].

The resulting rotation matrix is

R(α,β,γ)=Rx(α)Ry(β)Rz(γ).

From Rotation Matrices to Quaternions

Given a rotation matrix RSO(3), where

R=[R11R12R13R21R22R23R31R32R33],

we want to compute the quaternion

q=[w,x,y,z].

First compute tr(R)=R11+R22+R33.
If tr(R)>0, then

w=12tr(R)+1x=14w(R32R23)y=14w(R13R31)z=14w(R21R12)

If tr(R)0, then we find the largest diagonal element.
If R11 is the largest,

x=121+R11R22R33w=14x(R32R23)y=14x(R12+R21)z=14x(R13+R31)

If R22 is the largest,

y=121+R22R11R33w=14y(R13R31)x=14y(R12+R21)z=14y(R23+R32)

If R33 is the largest,

z=121+R33R11R22w=14z(R21R12)x=14z(R13+R31)y=14z(R23+R32)

From Quaternions and Translations to Dual Quaternions

Given a quaternion q=[w,x,y,z] and a translation vector [tx,ty,tz], the real part of the dual quaternion is simply

qr=q.

The dual part is calculated via quaternion multiplication

qd=12[0,tx,ty,tz]q.

The resulting dual quaternion is

q^=qr+ϵqd.

From 6D Representations to Rotation Matrices

Given 3D vectors a1λa2, the resulting rotation matrix is

R=[b1b2b3],

where

b1=N(a1),b2=N(a2(a2b1)b1),b3=b1×b2,N(x):=xx.

Summary

Methods Descriptions Pros Cons
Euler-angles Use rotation angles about three principle axes to represent a rotation - Intuitive to represent
- Use only three parameters
- Gimbal lock: one degree of freedom is lost if two of the three rotational axes align
- Hard and unintuitive to interpolate
- Do not commute under composition
- Non-uniqueness: infinite number of angle choices for a rotation
Rotation Matrices Use a 3×3 or 4×4 (with translation) matrix to represent a rotation - Trivial to compute and apply
- Easy to combine two rotations
- Can represent rotation and translation in one matrix
- Redundancy in parameters
- Normalization required
- Hard to interpolate
- Hard to visualize
Axis-angles Use a unit axis ω and a rotation angle θ to represent a rotation - Straightforward - Non-uniqueness: infinite number of angle choices for a rotation
- Hard to interpolate
Quaternions Encode the axis-angle into a quaternion [cosθ2,sinθ2ω] - Provide direct ways for smooth interpolation
- Use only four parameters
- Unintuitive to understand
- Combining rotations requires non-linear operations
Dual Quaternions Use two quaternions to represent both rotation and translation - Unify rotation and translation into a single framework
- Lower computational cost than using matrices
- Require fewer parameters than matrices
- Easy to concatenate transforms
- Unintuitive to understand
- Not widely adopted