Quaternions cs520 6up
Quaternions cs520 6up
• 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
5 6
1
Gimbal Lock Gimbal Lock
7 8
Outline Quaternions
• Rotations • Generalization of complex numbers
• Quaternions
• Quaternion Interpolation • Three imaginary numbers: i, j, k
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
• Conjugate quaternion: q = s - x i - y j - z k
15 16
• 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
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!
For q = a + b i + c j + d k
R=
19 20
• Interpolating rotations
corresponds to curves Source:
Wolfram Research
on the 4-D sphere
21 22
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
27 28
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)
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