Escolar Documentos
Profissional Documentos
Cultura Documentos
245
@ S I G G R A P H '85
might observe t h a t , while it does not change shape or T h a t is, the change m a t r i x M is orthogonal; its columns
size, it can t u m b l e freely. L e o n h a r d Euler proved two (and rows) are m u t u a l l y p e r p e n d i c u l a r unit m a g n i t u d e
centuries ago t h a t , however the brick tumbles, each vectors. Because M m u s t also preserve d e t e r m i n a n t s , it
position can be achieved by a single r o t a t i o n from a is a special orthogonal m a t r i x , satisfying
reference position. [Euler,1752] [Goldstein] The same is
true for any rigid body. ( S h a t t e r i n g glass is obviously d e t ( M ) = +1
not a single rigid body.)
W h i l e t r a n s l a t i o n s are well a n i m a t e d by using vectors, It is well known, a n d a n y h o w easy to show, t h a t the
r o t a t i o n a n i m a t i o n can be improved b y using the special o r t h o g o n a l m a t r i c e s form a group, SO(3), u n d e r
progenitor of vectors, quaternions. Q u a t e r n i o n s were m u l t i p l i c a t i o n . [MacLane][Goldstein][Misner] In this
discovered b y Sir W i l l i a m R o w a n H a m i l t o n in O c t o b e r r o t a t i o n group, the inverse of M is j u s t M t, the
of 1843. The m o m e n t is well recorded, for he opposite r o t a t i o n .
considered t h e m his most i m p o r t a n t contribution, the
inspired answer to a fifteen-year search for a successor To illustrate, the m a t r i x
to complex numbers. [Hamilton] By an odd quirk of
m a t h e m a t i c s , only systems of two, four, or eight 1 0 0 ]
c o m p o n e n t s will m u l t i p l y as H a m i l t o n desired; triples
M = 0 cos ~ --sin
h a d been his s t u m b l i n g block.
0 sin ~ cos
Soon a f t e r quaternions were introduced, A r t h u r Cayley
published a w a y to describe r o t a t i o n s using the new
m u l t i p l i c a t i o n . [Cayley] The n o t a t i o n in his p a p e r so effects a r o t a t i o n t h r o u g h an angle of ~9 a r o u n d t h e x
closely a n t i c i p a t e s m a t r i x notation, which he devised axis. A f t e r verifying the properties discussed so far,
several y e a r s later, t h a t it m a y be t a k e n as a formula note t h a t the diagonal entries sum to l + 2 c o s 0. While
for converting a quaternion to a r o t a t i o n matrix. It it is too lengthy to show here, the diagonal sum
t u r n s out t h a t the four values m a k i n g up a quaternion m e a s u r e s the same q u a n t i t y for m a t r i c e s g e n e r a t i n g
describe r o t a t i o n in a n a t u r a l way: three of t h e m give r o t a t i o n a r o u n d a n y axis. [MaeLane]
the coordinates for the axis of r o t a t i o n , while the 2.3 Quaternions
f o u r t h is d e t e r m i n e d by t h e angle r o t a t e d through.
[Courant & Hilbert] Quaternions, like rotations, also form a non-
c o m m u t a t i v e group u n d e r their multiplication, a n d
Since c o m p u t e r graphics leans heavily on v e c t o r these two groups are closely related. [Goldstein]
o p e r a t i o n s , it is p e r h a p s easiest to explain quaternlons [Pickert][Misner] In fact, we can s u b s t i t u t e quaternion
and r o t a t i o n m a t r i c e s in terms of these, reversing m u l t i p l i c a t i o n for r o t a t i o n m a t r i x multiplication, a n d
history. However quaternions can s t a n d on their own do less c o m p u t i n g as a result. [Taylor]
as an elegant a l g e b r a of space. [Herstein] [Pickert]
[MacLane] To perform quaternion a r i t h m e t i c , group the four
c o m p o n e n t s into a real p a r t - - a scalar, a n d an
2.2 R o t a t i o n matrices i m a g i n a r y p a r t - - a vector. A d d i t i o n is easy: a d d s c a l a r
T h a t a t u m b l i n g brick does not change size, shape, nor to s c a l a r a n d v e c t o r to vector. But our m a j o r i n t e r e s t
"handedness" is m a t h e m a t i c a l l y expressed as the is in m u l t i p l i c a t i o n . S t a r t with a simple case: m u l t i p l y
p r e s e r v a t i o n of dot products a n d cross products, since two quaternions w i t h o u t real p a r t s , or more precisely,
these measure lengths, angles, and handedness. A n d with zero real p a r t s . T h e result quaternion has a
since the d e t e r m i n a n t of a 3X3 m a t r i x can be c o m p u t e d vector t h a t is the cross p r o d u c t of the two vector p a r t s ,
as the dot p r o d u c t of one column w i t h the cross and a s c a l a r t h a t is t h e i r dot p r o d u c t , negated:
p r o d u c t of the o t h e r two, d e t e r m i n a n t s are also
preserved. Symbolically:
• 1~2 = [ ( - a l " ~ ) , ( ~ l x - ~ ) ]
Rot(~l)'Rot(-u2) = ~i'~2
It is c e r t a i n l y convenient to e h e o m p a s s b o t h v e c t o r
p r o d u c t s with a single quaternion p r o d u c t . (One early
Rot(-/11)XRot(~2) = Rot(.121)O22)
lover of quaternion a l g e b r a called v e c t o r a l g e b r a a
" h e r m a p h r o d i t e monster", since it required two kinds of
det(Rot(_ul),Rot(~2),Rot(.u3) ) ----det(.ul,.U2,~3)
p r o d u c t , each yielding a different t y p e of result.) If one
q u a t e r n i o n has only a s c a l a r p a r t , with its v e c t o r
A n i m m e d i a t e consequence is t h a t o r i e n t a t i o n changes c o m p o n e n t s all zero, multiplication is j u s t real
m u s t be linear o p e r a t i o n s , since the preserved m u l t i p l i c a t i o n a n d vector scaling. Combining the two
operations are; hence they have a matrix effects gives the general rule [Brady]:
r e p r e s e n t a t i o n , M . Using the m a t r i x form of a dot
p r o d u c t , 32~ a22, we can s a y more precisely t h a t
[81,~1] ['52,.-/22]= [(8182--121".122),(81.122+82jj.1-Jr-.illX222)].
( M a21)t ( M 322) = 32~ J22, from which it follows t h a t
M t M=I.
246
SAN FRANCISCO JULY 22-26 Volume 19, Number 3, 1985
247
@ S I G G R A P H '85
I IIII
vector p a r t and dividing both parts by the magnitude while from the 4-D geometry comes'~
squared. F o r q ~ [s,_~],
Slerp(ql,q2;u) _-- sin ( 1 - - u ) ~ sin u_.~
q-1 1 ; [ [ q I [2 = s2"4".IZ'.IZ . sin0 ql+ sin0 q2'
Itlqll 2
where ql'q2 ~ cos 0. The first is simpler for analysis,
Because all effects of magnitude are divided out,, any while the second is more pra.ctical for applications.
scalar multiple of a quaternlon gives the same rotation. But a n i m a t i o n s t y p i c a l l y have more t h a n two key poses
(This kind of behavior is not unknown in computer to connect, and here even our spherical elaboration of
graphics; any scalar multiple of a point in homogeneous simple linear interpolation shows flaws. While
coordinates gives the same non-homogeneous point.) orientation changes seamlessly, the direction of r o t a t i o n
changes a b r u p t l y . In m a t h e m a t i c a l terms, we w a n t
If the scalar p a r t has value w, and the vector p a r t higher order continuity. There are lots of ways to
values x, y, and z, the corresponding matrix can be achieve it---off the sphere; u n f o r t u n a t e l y we've learned
worked out to be too much.
3.4 Rotation geometry and topology
1--2y2--2z 2 2xy+2wz 2xz--2wy
No m a t t e r w h a t we do in general quaternion space, the
M = 2xy--2wz 1--2x2--2z 2 2yz++2wx u l t i m a t e effect must be i n t e r p r e t e d via the sphere; so
2xz.+2wy 2yz--2wx 1--2x2--2y 2 we h a d best work there in spite of the difficulty. It is
i m p o r t a n t to grasp this point. The metric structure,
hence the intrinsic geometry, of the rotation group
when the magnitude w2-l-x2-4-y2.+z2 equals 1. The SO(3) is t h a t of a sphere. Over small regions, meaning
m a g n i t u d e restriction implies t h a t , plotted in four- in this case small rotation angles, a sphere looks as if it
dimensional space, these quaternions lie on a sphere of is flat. But if we go far enough along a "straight line",
radius one. Deeper investigation shows t h a t such unit we end up back where we s t a r t e d . W h a t could be more
quaternions carry the amount of rotation in w, as evident a b o u t rotations? Their very essence is moving
cos 0/2, while the vector p a r t points along the r o t a t i o n in circles. Looking b a c k to the book-turning
axis with magnitude sin 0/2. The axis of a rotation is experiment, the confounding of axes is like traveling on
t h a t line in space which remains unmoved; but notice a sphere: if we go in some direction to a quarter of the
t h a t ' s exactly w h a t happens when scalar multiples of .u way a r o u n d the sphere, turn 90 degrees, travel the
are r o t a t e d by [s,~]. Because the cross product drops same distance, then t u r n and travel again, we will
out, multiplication commutes, q - ! meets q, m u t u a l arrive b a c k home, coming in at right angles to the
annihilation occurs, a n d the vector emerges unscathed. direction we h e a d e d out. Even more revealing, we can
Summing the m a t r i x diagonal leads to the formula leave the north pole in a n y direction and end up at the
s t a t e d for w. The sum equals 4w2~1, but must also be south pole, j u s t as we can r o t a t e 360 degrees around
l + 2 c o s 0. A trig identity, cos 2t9 = 2cos 2 0--1, finishes a n y axis and end up oriented the same way.
the demonstation.
3.3 G r e a t a r c in-betweening Local geometry does not, however, determine global
topology. C o n t r a d i c t o r y though it m a y seem, the
This sphere of unit quaternions forms a sub-group, S 3, geometry curves like a sphere, but the topology says
of the quaternion group. F u r t h e r m o r e , the spherical north and south poles are the same! In fact, each pair
metric of S 3 is the same as the angular metric of of opposite points represents the same rotation. The
SO(3). [Misner] F r o m this it follows t h a t we can rotate reader m a y preserve s a n i t y through two expedients.
without speeding up by interpolating on the sphere. One is to see t h a t this, like homogeneous coordinates, is
Simply plot the two given orientations on the sphere geometry under perspective projection. The second is
and draw the great circle arc between them. T h a t arc to restore spherical topology • by including
is the curve where the sphere intersects a plane through "entanglements". Physically, t a k i n g an object with
the two points and the origin. We sped up before strings a t t a c h e d and rotating it 360 degrees leaves the
because we were cutting across instead of following the strings tangled; y e t - - m o s t o d d - - r o t a t i n g 720 degrees
arc; otherwise the p a t h s of rotation are the same. does not. [Misner][Gardner]
A formula for spherical linear interpolation from ql to Accepting the topological o d d i t y is more useful here,
q2, with p a r a m e t e r u moving from 0 to 1, can be but it leaves a minor inconvenience. Namely, when
o b t a i n e d two different ways. F r o m the group structure converting an o r i e n t a t i o n in some foreign form, such as
we find a matrix, to a quaternion form, which quaternion
should we choose? W h i c h side of the sphere? A n
answer t h a t works well is this. Construct a string of
Slerp(ql,q2;u ) = q l ( q ~ l q 2 ) ~ ;
quuternions through which to interpolate by choosing
248
SAN FRANCISCO JULY 22-26 Volume 19, Number 3, 1985
each a d d e d quaternion on the side closest to the one o r d e r continuity, p r o b a b l y enough for us. As the curve
before. T h e n small changes in o r i e n t a t i o n will yield goes t h r o u g h its end points it is t a n g e n t to its end
small d i s p l a c e m e n t s on the sphere. segments. Line up the segments across a join, m a t c h
\ t h e i r lengths, a n d the curves will piece t o g e t h e r
smoothly. If the key o r i e n t a t i o n s are placed at joints,
t h e n each short curve moves us from one key to the
next, because each piece passes t h r o u g h its ends.
Now, a l t h o u g h the two segments a b u t t i n g a curve
j u n c t i o n should m a t c h each other, one of the segments
can be chosen freely. These choices determine the axis
and speed of r o t a t i o n as we pass t h r o u g h the keys.
points at
The b u r d e n of choice can be passed to the a n i m a t o r of
course, but a u t o m a t i o n is feasible, a n d generally
preferable.
4.2 C h o o s i n g j o i n t s e g m e n t s
Spherical linear i n t e r p o l a t i o n gives two conflicting arc
segments a t a joint, one on each side. Smooth the
Rep,-eSenti~ a proje~ive pJa~e
difference with a n even compromise, aiming for a point
h a l f w a y between where the incoming segment would
3.5 Splines proceed, a n d where the outgoing segment must a r r i v e . t
W e are left with the problem of constructing smooth
curves on spheres. About a hundred years after
quaternions appeared, Isaac Schoenberg published a
two p a r t a t t a c k on ballistics a n d a c t u a r i a l problems,
a~
using w h a t he called splines. [Schoenberg] N a m e d by
a n a l o g y to a d r a f t m a n ' s tool, these are i n t e r p o l a t i n g
curves c o n s t r u c t e d from cubic polynomial pieces, with
second order c o n t i n u i t y between pieces. Cubic spllnes
solve an integral equation which says to minimize the
t o t a l "wiggle" of the curve, as measured by the second
derivative. These i n t e r p o l a n t s are very popular, and
the equation can be a u g m e n t e d with L a g r a n g e
multipliers to constrain t h e solution curves t o lie on a
sphere [Courant h: Hilbert]; y e t there are problems. Co~$tt'u~ft~ g pot~t for f a ~ e r ~ t
F i r s t , the a u g m e n t e d equation is much more difficult
a n d expensive t o solve. Second, the curve must a d j u s t Given successive key quaternions q n - 1 , qn, qn+l
everywhere if one of the points changes; t h a t is, we i n t e r p r e t t e d as 4-D unit vectors, the c o m p u t a t i o n for a
have no local control. segment point a n after q~ is
249
~~ S I G G R A P H '85
b~÷j = ~2 (o)
to ensure a smooth join, regardless of how a n is chosen.
a~
250
SAN FRANCISCO JULY 2 2 " 2 6 Volume 19, Number 3, 1985
251
Q S I G G R A P H '85
252
SAN FRANCISCO JULY 22-26 Volume 19, Number 3,1985
L1 Quatcrnion to matrix There are twelve possible axis conventions for Euler
angles. The one used here is roll, pitch, and yaw, as
Using the restriction t h a t w2-t-x2-Fy2-t-z2= 1 for u used in aeronautics. A general rotation is obtained by
quaternion q = [w,(x,y,z)], the formula for the first yawing around the z axis by a n angle of ¢, t h e n
corresponding matrix is pitching around the y axis by 0, and finally rolling
around the x axis by ¢. Using the way quaternion
M = [1--2y2--2z2
2xy--2wz
2xz+2wy
2xy+2wz
1--2x2--2z2
2yz--2wx
2xz--2wy ]
2yz+2wx ].
1--2x2--2y 2]
components describe a rotation, we first o b t a i n a
quaternion for each simple rotation.
qrott = [cos@,(sin-~,O,O)]
If the quaternion does not have unit m~gnitude, a n
additional 4 multiplies and divides, 3 adds, and a qpitch '~ [cos~,(O,sin~,O)]
square root will normalize it. (For the matrix
conversion, the square root can be avoided in favor of
divides if desirable.) Now we can obtain the operation q~aw = [c°s 2~,(O,O,sin 2~)]
count for creating the matrix. Most terms of the
entries are a product of two factors, one of which is
doubled. So we proceed as follows. First double x, y, Multlplying these together in the right order gives the
and z, and form their products with w, x, y, and z. desired quaternion q -- qyaw qpitch qroll, with components
That will take 3 adds and 9 multiplies. Then form the
sum for each of the 9 entries using 1 add each, plus a n = cos --¢ eos --0 cos --¢ + sin -C-sln--0sin
2 2 2 2 2 2
extra add for each of the 3 diagonal elements, for a
total of 12 adds. Thus 9 multiplies a n d 15 adds suffice
= si.- cos --0cos --¢ -- cos -C-sin--0sin--¢
to convert a unit quaternion to a matrix. 2 2 2 2 2 2
L2 Matrix to quaternion
y = cos sin £¢os + sin -C-cos sin--¢
An efficient way to determine quaternion components 2 2 2 2 2 2
w, x, y, z from a matrix is to use linear combinations
of the entries Mra,~. Notice that the diagonal entries z = cos -.f-cos 2-sin-¢ - sin -C-sin £eos £
are formed from the squares of the quaternion 2 2 2 2 2 2
components, while off-diagonal entries are the sum of a
symmetric and a skew-symmetric part. Thus linear
combinations of the diagonal entries will isolate squares 1.4 Euler angles to matrix
of components; sums and differences of opposite off- Combining the results of the previous two conversions
diagonal entries will isolate products among x, y, a n d z gives
and products with w. Using off-diagonals risks dividing M =
by a component that may be zero, or within ¢ (the
machine precision) of zero. However we can avoid t h a t cos 8cos¢ cos 0sin¢ --sin 0 /
pitfall, and easily compute all components as follows. sin ~bsin8cosC--cos~sin ¢ sin ~bsin0sin¢+cos ¢cos 8 cos 0sin~],
cos Csin 0cos¢q.-sinCsin ¢ cos ~sin 0sin¢--sln ¢cos ¢ cos 0cos ~J
253
SIGG RAPH '85
sin 0 = --Mi3
cosO =
sine = M23/cos
cos~b = M a 3 / c o s / ~
s i n e = Ml~ / c o s
~os¢ = M l l / c o s e
sin ¢ = --M32
cos ¢ = M22
sine = 0
cos¢ = 1
254