Transcript ppt

Orientations
• Goal:
– Convenient representation of orientation of
objects & characters in a scene
• Applications to:
– inverse kinematics
– rigid body simulation
– rag doll physics
– etc.
Euler Angles
• …so far, used one angle per axis, ie. Euler
angles.
• Pros:
– Simple!
• Cons:
– Singularities (“gimbal lock”)
– Interpolation is tricky
– Composing rotations is tricky
Singularities
• Singularities may arise when axes are
rotated to coincide
• Lose a degree of freedom
• Consider an airplane’s roll-pitch-yaw
– eg. (0,90,0) vs. (90,90,90) – identical position
• IK problems:
– Infinitely many solutions if coincident
– Ill-posed when very close to coincident
Interpolation
• Vital for keyframe animation, blending
mocap data, etc.
• Linear interpolating each angle
independently gives odd behaviour near
singularities
• Not “coordinate independent”
– For 2 orientations, rotate-interpolate gives a
different result than interpolate-rotate
Composition
• Given two rotations applied sequentially,
find a single orientation that gives the
same result.
• Not at all obvious how to handle this
3x3 Orthogonal Matrices
• Eliminate many issues of Euler angles,
but…
– Hard to work with: 9 components, 6
constraints
– Highly redundant
– Linear interpolation doesn’t work
3x3 Orthogonal Matrices
• But:
– Very effective for quickly transforming many
points
– Composition is straightforward – multiply
• Still useful, but not as our primary
representation
Axis-angle
• Unit axis vector and an angle indicating
how much to rotate.
• Very intuitive
• 4 numbers, 1 constraint – less redundant
• Comparison, interpolation, composition
still difficult.
2D Rotations
• Can use complex numbers to represent
2D rotations
• View a point (x,y) as x+ i*y
• Rotation about origin is multiplication by:
– cos(theta) + i*sin(theta)
• Equivalently, e^(i*theta)
– ie. A unit magnitude complex number
2D Rotations
• And composition is again multiplication
• Isn’t this overkill?
– In 2D, yes
– But this idea extends elegantly to 3D
Quaternions
•
•
•
•
Generalizes complex numbers
Two additional sqrt(-1) terms, j and k
Form: a + bi + cj + dk
Behave mostly like regular numbers:
– But NOT commutative! a*b ≠ b*a
Quaternions
• Small set of simple multiplication rules:
i*i = -1, j*j = -1, k*k = -1
i*j = k, j*k = i, k*i = j
j*i = -k, k*j=-i, i*k = -j
• When j & k components are 0, this reverts
to basic complex numbers
– ie. 2D rotations.
Rotating points
• Given complex number: q a
• Conjugate is: q a ib
2
• Then: q 0 ix q 0 q ix
ib
• If q is unit magnitude, just gives back 0 + ix
• Real part remains 0, imaginary part retains its
length, x
Rotating points
•
•
•
•
Quaternion: q a ib jc kd
Conjugate: q a ib jc kd
Zero real-part quaternion: 0 ix jy
Consider:
q 0 ix
jy kz q
q
2
x
2
y
kz
2
z
2
• Real part stays 0, imaginary part keeps length
• For unit q, this is a rotation of the vector (x,y,z) in
quaternion form
Quaternion Rotation
• So, to perform a rotation by unit
quaternion q on vector v = (x,y,z) to get
new vector v’ = (x’,y’,z’) just do:
0 ix '
jy ' kz '
q 0 ix
jy kz q
Quaternion Rotation
• Unit-length quaternions can represent any
orientation in 3D, without singularities
• Relation to axis-angle form:
– Real part is cos(theta/2)
– Imaginary part is vector parallel to the rotation axis
• Redundancy: q = -q
– But since the two possible representations are
maximally far apart, no harm done.
Quaternion Interpolation
• Interpolation is much more convenient
– linear interpolating, then renormalizing q to unit-length
works fairly well
– For better results, ensure dot product of their
imaginary parts is non-negative,by flipping sign, since
q = -q is the same orientation.
• We want the two quaternion’s “axes” to be pointing in the
same direction, so that the interpolation path is as short as
possible.
• For improved interpolation of unit vectors, look
into “slerp”
Quaternion Composition
• Similar to matrix form, just multiply
• Consider 2 quaternion rotations applied to
a point 0+ix+jy+kz
q 1 q2 ix
jy kz q 2 q1 q1 q 2 ix
or q 3 ix
jy kz q1 q 2
jy kz q3 for q 3 q 1 q2