Professional Documents
Culture Documents
Valentin Koch
Autodesk Inc.
1 Introduction
2 Rotation Matrices in R2
3 Rotation Matrices in R3
4 Gimbal Lock
5 Quaternions
1 Introduction
2 Rotation Matrices in R2
3 Rotation Matrices in R3
4 Gimbal Lock
5 Quaternions
x⇤
cos t = ,
r
y⇤
sin t = ,
r
and if r = 1, we obtain
x ⇤ = cos t,
y ⇤ = sin t.
Similarly, we have
y ⇤ = y cos + x sin .
Since
x ⇤ = x cos y sin ,
⇤
y = y cos + x sin ,
we write ✓ ◆ ✓ ◆✓ ◆
x⇤ cos sin x
=
y⇤ sin cos y
and our rotation matrix in R2 is
✓ ◆
cos sin
R= .
sin cos
1 Introduction
2 Rotation Matrices in R2
3 Rotation Matrices in R3
4 Gimbal Lock
5 Quaternions
Question
Why selecting 3 axis to rotate an object in R3 ?
Example
Step 1 Take 2x2 rotation matrix
✓ ◆
cos sin
R=
sin cos
.
Step 2 Extend to 3x3 by adding z-axis, and keep z value unchanged
0 1
cos sin 0
Rz = @ sin cos 0A .
0 0 1
Given angles ↵, , and , we obtain the basic rotations about the x-axis
0 1
1 0 0
Rx = @0 cos ↵ sin↵A ,
0 sin ↵ cos ↵
the y-axis 0 1
cos 0 sin
Ry = @ 0 1 0 A,
sin 0 cos
and the z-axis 0 1
cos sin 0
Rz = @ sin cos 0A .
0 0 1
Example
⇡
Linearly interpolate between identity I and rotation A, which is 2 around
x-axis.
0 1 0 1 0 1
1 0 0 1 0 0 1 0 0
R = 0.5 @0 1 0A + 0.5 @0 0 1 A = @0 0.5 0.5A
0 0 1 0 1 0 0 0.5 0.5
1 Introduction
2 Rotation Matrices in R2
3 Rotation Matrices in R3
4 Gimbal Lock
5 Quaternions
we obtain
0 1
0 0 1
R = @ sin(↵ + ) cos(↵ + ) 0A
cos(↵ + ) sin(↵ + ) 0
A rotation vector
r = ✓ê,
where ê = (ex , ey , ez )T is an
arbitrary unit vector, and ✓ is the
angle of rotation about the axis ê.
No Gimbal Lock.
Combining two rotations defined by Euler vectors is not simple.
Cannot use LERP to interpolate.
1 Introduction
2 Rotation Matrices in R2
3 Rotation Matrices in R3
4 Gimbal Lock
5 Quaternions
Definition
A quaternion is a quadruple formed by a scalar w , and a vector
v = (x, y , z). We write it as
q = (w , v).
Definition
A unit quaternion is a quaternion q, such that kqk = 1, where
kqk = w 2 + x 2 + y 2 + z 2 .
u = (ux , uy , uz ),
and an angle
✓.
Example
We want to rotate 90 about the y -axis using a quaternion.
Rotation
Any vector v 2 R3 can be rotated using a rotation quaternion q by
1
qpq ,
What is the Hamilton product and how do you take the inverse of a
quaternion?
Definition
Let q0 = (w0 , v0 ) and q1 = (w1 , v1 ). The Hamilton Product is defined as
q0 q1 = (w0 w1 v0 · v1 , w0 v1 + w1 v0 + v0 ⇥ v1 ).
Warning
Quaternion multiplication is not commutative, q0 q1 6= q1 q0
Definition
The inverse of a quaternion q = (w , v) is computed as
1 (w , v)
q = .
kqk2
0 1
2y 2 2z 2
1 2xy 2zw 2xz + 2yw
Rq = @ 2xy + 2zw 1 2x 2 2z 2 2yz 2xw A .
2xz 2yw 2yz + 2xw 1 2x 2 2y 2
Example
Sword movement We rotate = ⇡2 about the y -axis v0 = (0, 1, 0), followed
by ↵ = 6⇡ about the x-axis v1 = (1, 0, 0). We obtain the quaternions
⇡ ⇡ ⇡ ⇡
q0 = (cos , 0, sin , 0), q1 = (cos , sin , 0, 0).
4 4 12 12
Compose them q = q1 q0 = (w , x, y , z), we get
⇡ ⇡ ⇡ ⇡
w = cos cos , x = sin cos ,
12 4 12 4
⇡ ⇡ ⇡ ⇡
y = cos sin , z = sin sin .
12 4 12 4
Valentin Koch (ADSK) IEEE Okanagan January 27, 2016 35 / 37
Quaternions
Interpolation
Links:
Gimbal Lock
Rotating Objects Using Quaternions
Understanding Quaternions