0% found this document useful (0 votes)
35 views

Quaternions cs520 6up

This document discusses different methods for representing 3D rotations, including orthogonal matrices, axis-angle representations, Euler angles, and quaternions. It provides the following key points: 1. Euler angles represent rotations as a sequence of rotations around the x, y, and z axes and can have gimbal lock singularities. 2. Quaternions, invented by Hamilton in 1843, represent rotations using four parameters and avoid gimbal lock. A unit quaternion corresponds to a rotation of a given angle about a given axis. 3. Rotations in 3D space can be composed and represented using quaternion multiplication, though quaternions are non-commutative unlike other representations. Unit quaternions

Uploaded by

zhaodong.liang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Quaternions cs520 6up

This document discusses different methods for representing 3D rotations, including orthogonal matrices, axis-angle representations, Euler angles, and quaternions. It provides the following key points: 1. Euler angles represent rotations as a sequence of rotations around the x, y, and z axes and can have gimbal lock singularities. 2. Quaternions, invented by Hamilton in 1843, represent rotations using four parameters and avoid gimbal lock. A unit quaternion corresponds to a rotation of a given angle about a given axis. 3. Rotations in 3D space can be composed and represented using quaternion multiplication, though quaternions are non-commutative unlike other representations. Unit quaternions

Uploaded by

zhaodong.liang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Rotations

CSCI 520 Computer Animation and Simulation


•  Very important in computer animation
and robotics

Quaternions and Rotations •  Joint angles, rigid body orientations,


camera parameters

•  2D or 3D
Jernej Barbic
University of Southern California

1 2

Representing Rotations in 3D
Rotations in Three Dimensions
•  Rotations in 3D have essentially three
• Orthogonal matrices:
parameters
RRT = RTR = I
det(R) = 1 •  Axis + angle (2 DOFs + 1DOFs)
–  How to represent the axis?
Longitude / lattitude have singularities

•  3x3 matrix
–  9 entries (redundant)

3 4

Representing Rotations in 3D Euler Angles


•  Euler angles
–  roll, pitch, yaw 1.  Yaw
–  no redundancy (good) rotate around y-axis
–  gimbal lock singularities
2.  Pitch
rotate around (rotated) x-axis
•  Quaternions Source: Wikipedia
3.  Roll
–  generally considered the “best” representation
rotate around (rotated) y-axis
–  redundant (4 values), but only by one DOF (not severe)
Source: Wikipedia
–  stable interpolations of rotations possible

5 6

1
Gimbal Lock Gimbal Lock

When all three gimbals When all three gimbals


are lined up (in the same are lined up (in the same
plane), the system can only plane), the system can only
move in two dimensions move in two dimensions
from this configuration, from this configuration,
not three, and is not three, and is
in gimbal lock. in gimbal lock.

Source: Wikipedia Source: Wikipedia

7 8

Choice of rotation axis sequence


Example: XYZ Euler Angles
for Euler Angles
•  First rotate around X by angle θ1,
•  12 choices: then around Y by angle θ2,
XYX, XYZ, XZX, XZY, then around Z by angle θ3 .
YXY, YXZ, YZX, YZY,
ZXY, ZXZ, ZYX, ZYZ •  Used in CMU Motion Capture
Database AMC files

•  Rotation matrix is:

•  Each choice can use static axes, or


rotated axes, so we have
a total of 24 Euler Angle versions!
9 10

Outline Quaternions
•  Rotations •  Generalization of complex numbers
•  Quaternions
•  Quaternion Interpolation •  Three imaginary numbers: i, j, k

i2 = -1, j2 = -1, k2 = -1,


ij = k, jk = i, ki = j, ji = -k, kj = -i, ik = -j

•  q = s + x i + y j + z k, s,x,y,z are scalars

11 12

2
Quaternions Quaternions
•  Invented by Hamilton in 1843 in Dublin, Ireland •  Quaternions are not commutative!

q1 q2 ≠ q2 q1
•  Here as he walked by
on the 16th of October •  However, the following hold:
1843 Sir William Rowan (q1 q2) q3 = q1 (q2 q3)
Hamilton in a flash of (q1 + q2) q3 = q1 q3 + q2 q3
genius discovered the q1 (q2 + q3) = q1 q2 + q1 q3
fundamental formula for α (q1 + q2) = α q1 + α q2 (α is scalar)
quaternion multiplication (αq1) q2 = α (q1q2) = q1 (αq2) (α is scalar)
Source: Wikipedia

i2 = j2 = k2 = i j k = −1 •  I.e., all usual manipulations are valid, except cannot


reverse multiplication order.
& cut it on a stone of this bridge. 13 14

Quaternions Quaternion Properties


•  Exercise: multiply two quaternions •  q = s + x i + y j + z k

(2 - i + j + 3k) (-1 + i + 4j - 2k) = ... •  Norm: |q|2 = s2 + x2 + y2 + z2

•  Conjugate quaternion: q = s - x i - y j - z k

•  Inverse quaternion: q-1 = q / |q|2

•  Unit quaternion: |q| =1

•  Inverse of unit quaternion: q-1 = q

15 16

Quaternions and Rotations Rotations to Unit Quaternions


•  Rotations are represented by unit quaternions •  Let (unit) rotation axis be [ux, uy, uz], and angle θ

•  q = s + x i + y j + z k •  Corresponding quaternion is

q = cos(θ/2) +
s2 + x2 + y2 + z2 = 1
sin(θ/2) ux i + sin(θ/2) uy j + sin(θ/2) uz k

•  Unit quaternion sphere •  Composition of rotations q1 and q2 equals q = q2 q1


(unit sphere in 4D)
Source:
Wolfram Research •  3D rotations do not commute!
unit sphere
in 4D
17 18

3
Unit Quaternions to Rotations Quaternions
•  Let v be a (3-dim) vector and let q be a unit quaternion •  Quaternions q and -q give the same rotation!

•  Then, the corresponding rotation transforms


vector v to q v q-1 •  Other than this, the relationship between
(v is a quaternion with scalar part equaling 0, rotations and quaternions is unique
and vector part equaling v)

For q = a + b i + c j + d k

R=

19 20

Outline Quaternion Interpolation


•  Rotations •  Better results than
•  Quaternions Euler angles
•  Quaternion Interpolation
•  A quaternion is a point
on the 4-D unit sphere

•  Interpolating rotations
corresponds to curves Source:
Wolfram Research
on the 4-D sphere

21 22

Spherical Linear intERPolation


SLERP
(SLERPing)
•  Interpolate along the great
circle on the 4-D unit sphere

•  Move with constant angular


velocity along the great circle
between the two points •  u varies from 0 to 1
San Francisco
to London •  qm = sm + xm i + ym j + zm k , for m = 1,2
•  Any rotation is given by •  The above formula does not produce a unit
two quaternions, so there are two quaternion and must be normalized;
SLERP choices; pick the shortest replace q by q / |q|
23 24

4
Interpolating more than two rotations Interpolation with smooth velocities
•  Simplest approach: •  Use splines on the
connect consecutive unit quaternion sphere
quaternions using SLERP
•  Reference: Ken Shoemake
•  Continuous rotations in the SIGGRAPH '85
proceedings (Computer
Graphics, V. 19, No. 3,
•  Angular velocity
P. 245)
not smooth at the joints

25 26

Bezier Spline Bezier Spline


•  Four control points •  p(0) = P1, p(1) = P4,
–  points P1 and P4 are on the curve •  p'(0) = 3(P2-P1)
–  points P2 and P3 are off the curve; •  p'(1) = 3(P4 - P3)
they give curve tangents at beginning and end
•  Convex Hull property:
curve contained within the
convex hull of control points
•  Scale factor “3” is chosen to
make “velocity” approximately
constant

27 28

The Bezier Spline Formula DeCasteljau Construction

Bezier basis Bezier


control matrix

•  [x,y,z] is point on spline corresponding to u


•  u varies from 0 to 1 Efficient algorithm to evaluate Bezier splines.
•  P1 = [x1 y1 z1] P2 = [x2 y2 z2] Similar to Horner rule for polynomials.
•  P3 = [x3 y3 z3] P4 = [x4 y4 z4] Can be extended to interpolations of 3D rotations.
29 30

5
DeCasteljau on Quaternion Sphere Bezier Control Points for Quaternions
•  Given quaternions qn-1, qn , qn+1 , form:
an = Slerp(Slerp(qn-1, qn, 2.0), qn+1, 0.5)
an = Slerp(qn , an , 1.0 / 3)
bn = Slerp(qn , an , -1.0 / 3)

Given t, apply DeCasteljau construction:

Q0 = Slerp(P0,P1,t) Q1 = Slerp(P1,P2,t)
Q2 = Slerp(P2,P3,t) R0 = Slerp(Q0,Q1,t)
R1 = Slerp(Q1,Q2,t) P(t)= Slerp(R0,R1,t) 31 32

Interpolating Many Rotations on


Quaternion Sphere
•  Given quaternions q1, ..., qN ,
form Bezier spline control points (previous slide)

•  Spline 1: q1, a1, b2, q2


•  Spline 2: q2, a2, b3, q3 etc.

•  Need a1 and bN; can set


a1 = Slerp(q1, Slerp(q3, q2, 2.0), 1.0 / 3)
bN = Slerp(qN, Slerp(qN-2, qN-1, 2.0), 1.0 / 3)

•  To evaluate a spline at any t, use DeCasteljau


construction 33

You might also like