Title: CPSC 441: Computer Graphics Rotation Representation and Interpolation
1CPSC 441 Computer Graphics Rotation
Representation and Interpolation
2Joints and Rotation
- Rotational dofs are widely used in character
animation
3 translation dofs 48 rotational dofs
1 dof knee
2 dof wrist
3 dof shoulder
3Orientation vs. Rotation
- Orientation is described relative to some
reference alignment - A rotation changes object from one orientation to
another - Can represent orientation as a rotation from the
reference alignment
4Ideal Orientation Format
- Represent 3 degrees of freedom with minimum
number of values - Allow concatenations of rotations
- Math should be simple and efficient
- concatenation
- interpolation
- rotation
5Outline
- Rotation matrix
- Fixed angle and Euler angle
- Axis angle
- Quaternion
6Matrices as Orientation
- Matrices just fine, right?
- No
- 9 values to interpolate
- dont interpolate well
7Representation of orientation
- Homogeneous coordinates (review)
- 4X4 matrix used to represent translation,
scaling, and rotation - a point in the space is represented as
- Treat all transformations the same so that they
can be easily combined
8Rotation
old points
New points
rotation matrix
9Interpolation
- In order to move things, we need both
translation and rotation - Interpolating the translation is easy, but what
about rotations?
10Interpolation of Orientation
- How about interpolating each entry of the
rotation matrix? - The interpolated matrix might no longer be
orthonormal, leading to nonsense for the
inbetween rotations
11Interpolation of Orientation
- Example interpolate linearly from a positive 90
degree rotation about y axis to a negative 90
degree rotation about y - Linearly interpolate each component and halfway
between, you get this...
Rotate about y-axis with 90
Rotate about y-axis with -90
12Properties of Rotation Matrix
- Easily composed?
- Interpolation?
- Compact representation?
13Properties of Rotation Matrix
- Easily composed? yes
- Interpolation?
- Compact representation?
14Properties of Rotation Matrix
- Easily composed? yes
- Interpolation? not good
- Compact representation?
15Properties of Rotation Matrix
- Easily composed? yes
- Interpolation? not good
- Compact representation?
- - 9 parameters (only needs 3 parameters)
-
16Outline
- Rotation matrix
- Fixed angle and Euler angle
- Axis angle
- Quaternion
17Fixed angles
- Angles used to rotate about fixed axes
- Orientations are specified by a set of 3 ordered
parameters that represent 3 ordered rotations
about fixed axes - Many possible orderings x-y-z, x-y-x,y-x-z
- - as long as axis does immediately follow
itself such as x-x-y
18Fixed angles
Ordered triple of rotations about global axes,
any triple can be used that doesnt immediately
repeat an axis, e.g., x-y-z, is fine, so is
x-y-x. But x-x-z is not.
E.g., (qz, qy, qx)
Q Rx(qx). Ry(qy). Rz(qz). P
19Euler Angles vs. Fixed Angles
- One point of clarification
- Euler angle
- - rotates around local axes
- Fixed angle
- - rotates around world axes
- Rotations are reversed
- - x-y-z Euler angles z-y-x fixed angles
20Euler angle Interpolation
- Interpolating each components separately
- Might have singularity problem
- Halfway between (0, 90, 0) (90, 45, 90)
- Interpolate directly, get (45, 67.5, 45)
- Desired result is (90, 22.5, 90) (verify this!)
21Euler angle concatenation
- Can't just add or multiply components
- Best way
- Convert to matrices
- Multiply matrices
- Extract Euler angles from resulting matrix
- Not cheap
22Gimbal lock
- Euler/fixed angles not well-formed
- Different values can give same rotation
- Example with z-y-x fixed angles
- ( 90, 90, 90 ) ( 0, 90, 0 )
23Gimbal lock
- Euler/fixed angles not well-formed
- Different values can give same rotation
- Example with z-y-x fixed angles
- ( 90, 90, 90 ) ( 0, 90, 0 )
24Gimbal lock
- Euler/fixed angles not well-formed
- Different values can give same rotation
- Example with z-y-x fixed angles
- ( 90, 90, 90 ) ( 0, 90, 0 )
z
(90,0,0)
y
x
25Gimbal lock
- Euler/fixed angles not well-formed
- Different values can give same rotation
- Example with z-y-x fixed angles
- ( 90, 90, 90 ) ( 0, 90, 0 )
z
(90,0,0)
(90,90,0)
y
y
x
z
x
26Gimbal lock
- Euler/fixed angles not well-formed
- Different values can give same rotation
- Example with z-y-x fixed angles
- ( 90, 90, 90 ) ( 0, 90, 0 )
z
(90,0,0)
(90,90,0)
(90,90,90)
z
y
y
x
z
y
x
x
27Gimbal lock
- A Gimbal is a hardware implementation of Euler
angles used for mounting gyroscopes or expensive
globes - Gimbal lock is a basic problem with representing
3D rotation using Euler angles or fixed angles
28Gimbal lock
- When two rotational axis of an object pointing in
the same direction, the rotation ends up losing
one degree of freedom
29Outline
- Rotation matrix
- Fixed angle and Euler angle
- Axis angle
- Quaternion
30Axis angle
Rotate object by q around A
(Ax,Ay,Az,q)
A
q
Y
Z
X
Eulers rotation theorem An arbitrary rotation
may be described by only three parameters.
?
31Axis-angle rotation
Given r Vector in space to rotate n
Unit-length axis in space about which to rotate
q The amount about n to rotate Solve r
The rotated vector
r
r
n
32Axis-angle rotation
- Compute rpar the projection of r along the n
direction - rpar (nr)n
r
rpar
r
33Axis-angle rotation
- Compute rperp rperp r-rpar
rperp
r
rpar
r
34Axis-angle rotation
- Compute v a vector perpedicular to rpar and
rperp v rparxrperp
v
rperp
r
rpar
r
35Axis-angle rotation
- Compute v a vector perpedicular to rpar and
rperp v rparxrperp
v
rperp
r
rpar
Use rpar, rperp and v, ? to compute the new
vector!
r
36Axis-angle rotation
rperp r (nr) n
q
V n x (r (nr) n) n x r
r
rpar (nr) n
r
n
r rpar rperp
rpar (cos q) rperp (sin q) V (nr) n
cos q(r (nr)n) (sin q) n x r (cos q)r (1
cos q) n (nr) (sin q) n x r
37Axis-angle rotation
- Can interpolate rotation well
38Axis-angle interpolation
1. Interpolate axis from A1 to A2 Rotate axis
about A1 x A2 to get A
A1
q1
A
Y
q
A2
A1 x A2
2. Interpolate angle from q1 to q2 to get q
q2
Z
X
3. Rotate the object by q around A
39Axis-angle rotation
- Can interpolate rotation well
- Compact representation
- Messy to concatenate
- - might need to convert to matrix form
40Outline
- Rotation matrix
- Fixed angle and Euler angle
- Axis angle
- Quaternion
41Quaternion
- Remember complex numbers aib, where i2-1
- Quaternions are a non-commutative extension of
complex numbers - Invented by Sir William Hamilton (1843)
-
- Quaternion
- - Q a bi cj dk where
i2j2k2ijk-1,ijk,jki,kij - - Represented as q (w, v) w xi yj
zk
42Quaternion
- 4 tuple of real numbers w, x, y, z
- Same information as axis angles but in a more
computational-friendly form
43Quaternion math
Unit quaternion
Multiplication
Non-commutative
Associative
44Quaternion math
Conjugate
Inverse
45Quaternion Example
let
then
46Quaternion Rotation
47Quaternion rotation
48Quaternion Example
- Rotate a point (1,0,0) about y-axis with -90
degrees
z
(0,0,1)
y
x
(1,0,0)
49Quaternion Example
- Rotate a point (1,0,0) about y-axis with 90
degrees
z
(0,0,1)
y
x
(1,0,0)
50Quaternion Example
- Rotate a point (1,0,0) about y-axis with 90
degrees
z
(0,0,1)
y
x
(1,0,0)
Point (1,0,0)
51Quaternion Example
- Rotate a point (1,0,0) about y-axis with 90
degrees
z
(0,0,1)
y
x
(1,0,0)
Point (1,0,0)
Quaternion rotation
52Quaternion Example
- Rotate a point (1,0,0) about y-axis with 90
degrees
z
(0,0,1)
y
x
(1,0,0)
53Quaternion composition
- Rotation by p then q is the same as rotation by
qp
54Matrix Form
For a 3D point (x,y,z)
55Quaternion interpolation
1-angle rotation can be represented by a unit
circle
56Quaternion interpolation
1-angle rotation can be represented by a unit
circle
2-angle rotation can be represented by a unit
sphere
57Quaternion interpolation
1-angle rotation can be represented by a unit
circle
2-angle rotation can be represented by a unit
sphere
- Interpolation means moving on n-D sphere
- Now imagine a 4-D sphere for 3-angle rotation
58Quaternion interpolation
- Moving between two points on the 4D unit
- Sphere
- a unit quaternion at each step - another point
on the 4D unit sphere - move with constant angular velocity along the
great circle between the two points on the 4D
unit sphere
59Quaternion interpolation
Direct linear interpolation does not
work Linearly interpolated intermediate points
are not uniformly spaced when projected onto the
circle
60Quaternion interpolation
Spherical linear interpolation (SLERP)
Normalize to regain unit quaternion
61Quaternion interpolation
Spherical linear interpolation (SLERP)
Normalize to regain unit quaternion
62Quaternion interpolation
Spherical linear interpolation (SLERP)
Normalize to regain unit quaternion
63Quaternions
- Can interpolate rotation well
- Compact representation
- Also easy to concatenate