Você está na página 1de 10

SAN FRANCISCO JULY 22-26 Volume 19, Number 3, 1985

Animating Rotation with Quaternion Curves


Ken Shoemaker
The Singer C o m p a n y
Link Flight Simulation Division

ABSTRA CT drawings. Physics says t h a t the general position of a


rigid b o d y can be given b y combining a t r a n s l a t i o n with
a rotation. Computer animators key such
Solid bodies roll and t u m b l e through space. In t r a n s f o r m a t i o n s to control both s i m u l a t e d cameras a n d
c o m p u t e r a n i m a t i o n , so do cameras. The r o t a t i o n s of objects to be rendered. In following such an a p p r o a c h ,
these objects are best described using a four coordinate one is n a t u r a l l y led to ask: W h a t is the best
system, quaternions, as is shown in this paper. Of all r e p r e s e n t a t i o n for general rotations, and how does one
quaternions, those on the unit sphere are most suitable in-between them? Surprisingly little has been published
for a n i m a t i o n , but the question of how to construct on these topics, and the answers are not trivial.
curves on spheres has not been much explored. This
p a p e r gives one answer by presenting a new kind of This p a p e r suggests t h a t the common solution, using
spline curve, c r e a t e d on a sphere, suitable for smoothly three Euler's angles i n t e r p o l a t e d independently, is not
in-hetweening (i.e. i n t e r p o l a t i n g ) sequences of a r b i t r a r y ideal. T h e more recent (1843) n o t a t i o n of quaternions
rotations. Both t h e o r y a n d experiment show t h a t the is proposed instead, along with i n t e r p o l a t i o n on the
motion g e n e r a t e d is smooth and n a t u r a l , w i t h o u t quirks quaternion unit sphere. A l t h o u g h quaternions are less
found in earlier methods. familiar, conversion to quaternions and generation of
in-between frames can be completely a u t o m a t i c , no
C.R. Classification: G . l . 1 [Numerical Analysis] m a t t e r how key frames were originally specified, so
Interpolation--Spline and piecewise polynomial users d o n ' t need to k n o w - - o r c a r e - - a b o u t inner details.
interpolation; G.1.2 [Numerical Analysis] The s a m e cannot be said for Euier's angles, which are
Approximation--Spline and piecewise polynomial more difficult to use.
a p p r o x i m a t i o n ; 1.2.9 [Artificial Intelligence] R o b o t i c s - - Spherical i n t e r p o l a t i o n itself can be used for purposes
M a n i p u l a t o r s ; 1.3.5 [Computer Graphics] C o m p u t a t i o n a l besides a n i m a t i n g rotations. For example, the set of all
G e o m e t r y and O b j e c t M o d e l l i n g - - C u r v e , surface, solid, possible directions in space forms a sphere, the so-called
and object representation, - - G e o m e t r i c algorithms, G a u s s i a n sphere, on which one might w a n t to control
languages, and systems, - - H i e r a r c h y a n d geometric the positions of infinitely d i s t a n t light sources.
transformations Modelling features on a globe is a n o t h e r possible
General Terms: Algorithms, Theory application.
ieywords and phrases: quaternlon, rotation, It is simple to use a n d to p r o g r a m the method proposed
spherical geometry, spline, B6zier curve, B-spline, here. i t is more difficult to follow its development.
a n i m a t i o n , interpolation, a p p r o x i m a t i o n , in-betweening This stems from two causes: 1) rotations in space are
more confusing t h a n one might think, a n d 2)
1. I n t r o d u c t i o n i n t e r p o l a t i n g on a sphere is trickier t h a n i n t e r p o l a t i n g
in, say, a plane. R e a d e r s well a c q u a i n t e d with splines
C o m p u t e r a n i m a t i o n of three dimensional objects and t h e i r use in c o m p u t e r a n i m a t i o n should have little
i m i t a t e s the key .frame techniques of t r a d i t i o n a l difficulty, although e~en t h e y m a y stumble a bit over
a n i m a t i o n , using key positions in space i n s t e a d of key quaternions.
Permission to copy without fee all or part of this material is granted 2. D e s c r i b i n g rotations
provided that the copics arc not made or distributed for direct
commercial advantage, the ACM copyright notice and the title of the 2.1 Rigid m o t i o n
publication and its date appear, and notice is given that copying is by
permission of the Association for Computing Machinery. To copy Imagine hurling a brick t o w a r d s a plate glass window.
otherwise, or to republish, requires a fee and/or specific permission. As the brick flies closer and closer, a n e a r b y physicist

t Author's current address: 1700 Santa Cruz Ave., Menlo Park,


© 1985 A C M 0-89791-166-0/85/007/0245 $00.75 CA 94025

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

reasonable w a y to "multiply" or otherwise combine two


E x c e p t for the cross p r o d u c t this looks like complex
rotations. Even converting between r o t a t i o n m a t r i c e s
multiplication, (al+ibl)(a2+ib2) ---- (ala2--blb2) +
a n d angle coordinates is difficult a n d expensive,
i(a lb2Wa2bl), as H a m i l t o n intended, t
involving a r b i t r a r y a s s u m p t i o n s a n d trigonometric
Q u a t e r n i o n s m u l t i p l y with a cross product because functions. In their defense, it must be said t h a t t h e y
r o t a t i o n s confound axes. To illustrate , place a book in are h a n d y for solving differential e q u a t i o n s - - w h i c h is
front of you, face up, w i t h the top f a r t h e s t away. Use how Euler used them. [Euler,1758]
this orientatiori as a reference. Now hold the sides and
flip it t o w a r d you onto its face, r o t a t i n g 180 degrees 3. I n - b e t w e e n i n g a l t e r n a t i v e s
a r o u n d a left-to-right axis, y. Then, keeping it face
3.1 S t r a i g h t line i n - b e t w e e n i n g
down, spin it clockwise 180 degrees a r o u n d an up-down
z axis. Two rotations a r o u n d two p e r p e n d i c u l a r axes; It is not i m m e d i a t e l y obvious how to in-between even
yet the t o t a l change in o r i e n t a t i o n must be, according two r o t a t i o n keys. W h a t o r i e n t a t i o n s should an o b j e c t
to Euler, a single rotation. Indeed, if you hold the ends assume on its j o u r n e y between them? A n a t u r a l answer
of the spine a n d flip the book 180 degrees a r o u n d this is: t a k e the first key as a reference, a n d represent the
third, o u t w a r d - p o i n t i n g , x axis, you should restore the second b y describing the single r o t a t i o n t h a t t a k e s you
original orientation. As quaternions, this is to it, according to Euler's theorem. The in-between
- - a n t i c i p a t i n g developments a h e a d - - [0,(0,1,0)] times o r i e n t a t i o n s should be positioned along t h a t r o t a t i o n .
[0,(0,0,1)] equals [0,(1,0,0)]; the cross product is
essential. If we plot quaternions as points in four-dimensional
space, the s t r a i g h t lines between t h e m give o r i e n t a t i o n s
Notice how quaternion o p e r a t i o n s give a new i n t e r p o l a t i n g the end points in exactly the above sense.
orientation, in "quaternion coordinates", much as If we plot Euler's angle coordinates instead, the in-
t r a n s l a t i o n s give a position, relative to some s t a r t i n g between orientations will t r y to twist a r o u n d three
reference. A central message of this p a p e r is t h a t different axes simultaneously. This angle i n t e r p o l a t i o n
quaternlon coordinates are best for interpolating t r e a t s the three angles of r o t a t i o n at each key
orientations. F o r comparison, imagine using spherical o r i e n t a t i o n as a three-dimensional vector whose
coordinates for translations! Q u a t e r n i o n s represent components are i n t e r p o l a t e d i n d e p e n d e n t l y from key to
o r i e n t a t i o n as a single rotation, j u s t as r e c t a n g u l a r key. P a r a d o x i c a l l y , we can not r o t a t e simply except
coordinates represent position as a single vector. a r o u n d the special axes chosen for composition. W e
T r a n s l a t i o n s combine by adding vectors; rotations, by m a y even encounter so-called "gimbal lock", the loss of
multiplying quaternions. The s e p a r a t e axes of one degree of r o t a t i o n a l freedom. G i m b a l lock results
t r a n s l a t i o n s d o n ' t i n t e r a c t ; the axes of r o t a t i o n s must. from trying to ignore the cross p r o d u c t i n t e r a c t i o n of
Q u a t e r n i o n s preserve this interdependence n a t u r a l l y ; rotations, which can align two of the three axes.
Euler's angle coordinates ignore it. Q u a t e r n i o n s are safe from gimbal lock, a n d so have
been used for y e a r s to handle s p a c e c r a f t , where it is
2.4 E u l e r ' s angles
unacceptable. [Kane][Mitchell]
W h y , then, do so m a n y a n i m a t o r s use Euler's angles? 3.2 H o w q u a t e r n i o n s r o t a t e
Mostly, I suspect, because quaternions are unfamiliar.
Unlike Euler's angles, quaternions are not t a u g h t early S t r a i g h t lines between quaternions, however, ignore
in s t a n d a r d m a t h a n d physics curricula. C e r t a i n l y some of the n a t u r a l g e o m e t r y of r o t a t i o n space. If our
there is a p l e t h o r a of a r g u m e n t s a g a i n s t angle i n t e r p o l a t e d points were evenly s p a c e d along a line, the
coordinates. Euler's angle coordinates specify a n i m a t e d r o t a t i o n would speed up in the middle. To
orientation as a series of three independent, rotations see why, we must look a t how a quaternion converts to
about pre-chosen axes. For example, the orientation of a r o t a t i o n matrix. We r o t a t e a vector b y a quaternion
an airplane is sometimes given as "yaw" (or "heading") so: m u l t i p l y it on the right by the quaternion and on
around a vertical axis, followed by "pitch" around a the left by the inverse of the quaternion, t r e a t i n g the
horizontal axis through the wings, followed by "roll" vector as [0,~].
around the nose-to-tail line. These three angles must
be used in exactly the order given because rotations do vr = Rot(v) = q--I 32 q
not commute. The ordering of rotation axes used is a
matter of convention, as is the particular set of axes,
no matter what the order. For instance some physicists Though it is not obvious, the result will always be a
use the body centered axes z-x-z, in contrast to the vector, with a zero s c a l a r component. Notice how this
aeronautics z-y-x. At least a dozen different guarantees
conventions are possible for which series of axes to use.
[Kane][Goldstein] The geometry of orientations in
R o t ( v l ) Rot(v2) = Rot(.ul V2)
Euler's angle coordinates is contorted, a n d varies with
choice of initial coordinate axes. There is no
which implies t h a t dot and cross products are
preserved, e m b e d d e d in t h e q u a t e r n i o n p r o d u c t .
Hamilton wrote a quaternion as s+iv~÷jv~+kv~, with i 2 =
jq = k 2 = i j k ------1. The multiplication rules given before are The inverse of a quaternlon is o b t a i n e d by negating its
consequences of this elegant formulation.

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

t Glenn Davis suggested this formula.

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

3.6 B~zier curves a n = Biseet(Donble(qn_l,%),q,+]) '


While Schoenberg invented splines based on numerical
analysis, Pierre Bdzier invented a class of curves, now where
called by his name, based on geometrical ideas. In fact,
he showed how to find points on such a curve by
drawing lines and splitting t h e m in regular proportions. D o u b l e ( p , q ) ~. 2(p-q)q -- p ;
[Bdzier] This is e x a c t l y w h a t is needed. We a l r e a d y
know how to do the e q u i v a l e n t - - d r a w g r e a t arcs and Bisect(p,q) = t tPWq
proportions of arcs---on a sphere. A complete solution ,,p+qlZ
needs only a little more.
The m a t c h i n g point for the segment before qn should
4. Spherical B~zier curves he
4.1 Joining curves
Bgzler curves go t h r o u g h only t h e i r first and last bn -~ D°uble(an ,qn)
defining points, b u t we w a n t to i n t e r p o l a t e all our
o r i e n t a t i o n s . The t r i c k is to splice t o g e t h e r s h o r t
Bdzier curves in the m a n n e r of splines. Their c r e a t o r For the numerically knowledgeable, this construction
approximates the derivative at points of a sampled function by
showed an easy w a y to do this which g u a r a n t e e s first averaging the central differences of the sample sequence.
[Dahlquist & Bj6rk]

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~

C=lcvl$tingg a B ~ z i e r ct)rve polnf recursivel y

$pliging B¢2iCr 3e3mentS lo~¢¢her 5, R e s u l t s


4.3 Evaluating on t h e sphere 5.1 T h e g r a n d s c h e m e
Everything is now in h a n d to imitate B~zier's curve W h a t have we ended up with? An a n i m a t o r sits at a
technique. Each short curve is defined by four workstation and interactively establishes a sequence of
quaternions, qn, an, bn+l, qn+l" Let the p a r a m e t e r u keys for, say, camera orientation. The interpolating
vary from 0 to 1 as the curve departs qn towards a n algorithm does not depend on the n a t u r e of the
and arrives at qn+l t a n g e n t to the arc from bn+ 1. interface the a n i m a t o r sees; all needed information is
Spherically interpolate by proportion u between qn and contained in the sequence of keys. P r o b a b l y the
an, a n and bn+l, bn+ 1 and qn+l, to obtain three new orientations will be represented internally as matrices,
quaternions. Then interpolate between those to get so a conversion step follows. The matrices are "lifted"
two more; and finally interpolate again, reducing to a to a sequence of neighboring quaternions, qn, on the
single point. A b b r e v i a t i n g Slerp(p,q;u) as (P:q)=, the unit sphere. Each quaternion within the sequence will
c o m p u t a t i o n looks like this: become the endpoint of two spherical B6zier curves.
qn =p~0) Between each q u a t e r n i o n pair, qn a n d qn+l, two
additional points, a n and bn+l, are added to control
(p~O):piO))u=p~ 1) motion through the joints. At this point, time becomes
a p a r a m e t e r along the composite curve. As the frame
an =P t °) (P~') :P i ') )u =p~2) n u m b e r increments, the p a r a m e t e r enters and leaves
successive curve pieces. Within each piece a local
(ptO):plO))u=pt 1) (p;2):pi2))u=p~3)=qn+u version of the p a r a m e t e r is adjusted to run from 0 to 1.
Now the B6zier geometric construction comes into play,
bn+l----p~ O) (p t1) :phi) )u ~-p t2) producing a n interpolated quaternion, qn+~, from qn,
an, bn+l, qn+l, and the local parameter, u. F i n a l l y the
mint-fresh interpolated quaternion is t r a n s m u t e d into a
matrix, to be used in rotating a list of object vectors
qn +1=P t 0) for rendering.
5.2 Properties
A look at one special case is revealinG. Suppose all the
4.4 Tangents revisited points to interpolate are spread along a single arc.
A simple check proves the curve touches q,~ and qn+l at This means they represent different a m o u n t s of rotation
its ends. A rather challenging differentiation shows it is a r o u n d a single axis, in which case quaternion
t a n g e n t there to the segments determined by a n and multiplication commutes. Under these special
bn+ 1. However, as with B6zi~r's original curve, the conditions, the formula for the curve sections reduces to
m a g n i t u d e of the t a n g e n t is three times t h a t of the
segment itself. T h a t is, we are spinning three times qn+u = qn(l-u)8 a : (1-u)~ bn3~'l]-~)u~ qn+l
us
faster t h a n spherical interpolation along the arc.
F o r t u n a t e l y we can correct the speed by merely
t r u n c a t i n g the end segments to one third their original W h e n this is compared to the s t a n d a r d B6zier
length, so t h a t a n is closer to qn and b,+ 1 closer to polynomial, pn(1--u) 3 + an3(1--u)2u + bn+13(1--u)u ~ +
qn+l" q,,+lu 3 , it is a p p a r e n t t h a t addition a n d multiplication

250
SAN FRANCISCO JULY 2 2 " 2 6 Volume 19, Number 3, 1985

have become m u l t i p l i c a t i o n a n d exponentiation. Of end points implies minimum c u r v a t u r e between


course, when the points are not on one arc, i n t e r m e d i a t e points as well. Along these lines, Gabriel
c o m m u t a t i v i t y fails, so the formula looks much messier. and K a j i y a , m o t i v a t e d b y quaternions, have been
developing a technique to find splines on a r b i t r a r y
In the interesting r e s t r i c t e d case when the points are
R e i m a n n i a n manifolds b y solving differential equations.
s p a c e d evenly a n d consecutively a r o u n d an arc, the
[Gabriel & K a j i y a ]
resulting a n i m a t i o n behaves exactly as we would hope:
we get smooth,, c o n s t a n t speed r o t a t i o n a r o u n d the
6. Questions
a p p r o p r i a t e axis. Notice t h a t we can choose a n y axis
for this r o t a t i o n . This is clearly preferable to F u t u r e research could answer some interesting p r a c t i c a l
i n t e r p o l a t i o n with Euler's angles, where the coordinate questions. W h a t are these spherical B6zier curves? Is
axes are special. A more subtle p r o p e r t y of all there some a b s t r a c t c h a r a c t e r i z a t i o n of them? Or is
quaternion i n t e r p o l a t i o n is t h a t the motion is there some related interpolant that is well-
i n d e p e n d e n t of coordinate axes. So, for example, if we characterized? In light of the success of the geometric
design a move, t h e n r o t a t e the coordinate system a d a p t a t i o n a p p r o a c h , it a p p e a r s reasonable to a p p l y
a r b i t r a r i l y , the g e o m e t r y of the motion will not change. the idea to B-splines, which also have a known
Euler i n t e r p o l a n t s , u n f o r t u n a t e l y , will do wildly geometric e v a l u a t i o n technique. [Cordon & Riesenfeld]
different things. How do spherical B-splines behave? Is it possible to
add new points to a sequence for either kind of curve
5.3 A p p l i c a b i l i t y
without disturbing it? How? C a n B-.splines be m a d e to
R o t a t i o n s in space are significantly more c o m p l i c a t e d i n t e r p o l a t e , not j u s t a p p r o x i m a t e , with a simple
t h a n r o t a t i o n s in a plane. It is easy to deal with the a d j u s t m e n t of control points? Is there a w a y to
latter, since only one parameter is involved. construct a curve p a r a m e t e r i z e d by arc length? This
Q u a t e r n i o n s are o u t of place in a plane. Joint control would be very useful. W h a t is the best w a y to allow
in robotics simulations has its own highly specialized varying intervals between sequence points in p a r a m e t e r
body of techniques; and though quaternions have shown space? A b a n d o n i n g the unit sphere, one could work
up in the l i t e r a t u r e , t h e y seem less useful in t h a t with the four-dimensional Euclidean space of a r b i t r a r y
context. [Brady] [Taylor] However, B.K.P. Horn has quaternlons. How do s t a n d a r d i n t e r p o l a t i o n m e t h o d s
used a tessellation of the quaternion unit sphere to applied there behave when m a p p e d back to matrices?
identify the o r i e n t a t i o n of an object from its extended Note t h a t we now have little guidance in picking the
G a u s s i a n image; a good reference is [Brou]. Non-rigid inverse image for a matrix, and t h a t cusp-free 1~4 p a t h s
motion obviously needs to be h a n d l e d specially. But for do not always project to cusp-free S 3 paths.
moving a c a m e r a eye-point, a n d for m a n y kinds of
However these questions are answered, quaternion
o b j e c t motion, quaternion i n t e r p o l a t i o n has strong
spline i n t e r p o l a n t s a l r e a d y offer a well-behaved
advantages.
i m p r o v e m e n t over t r a d i t i o n a l techniques. T h e y are
5.4 Comparisons and complaints simple to use, simple to implement, robust, efficient,
Cost a d v a n t a g e s are difficult to e s t i m a t e . Converting a consistent, a n d flexible. More research would m a k e
m a t r i x to a quaternion requires only one square root them even more so.
a n d three divides plus some adds, at worst. Converting
b a c k requires g multiplies and 15 adds. While the 7. Acknowledgments
conversions d o n ' t use trigonometric functions, the arc This work was begun for an a n i m a t i o n system I
proportioning does. For comparison, angle designed and i m p l e m e n t e d a t Singer-Link. Several
i n t e r p o l a t i o n requires several trigonometric functions as people there deserve t h a n k s , but I especially t h a n k
well as quite a few multiplies a n d adds to create each Glenn Davis, who befriended me with his good humor
i n t e r p o l a t e d m a t r i x . My experience is t h a t the B6zier and m a t h e m a t i c a l efforts as I struggled through trying
scheme is c o m f o r t a b l y fast enough for design work, times.
which is the only time speed has m a t t e r e d . (If, for I prefer not to invent the wheel if I can find the plans;
some application, more speed is essential, non-spherical so I p e s t e r e d Don Venhaus, Brian Bar~ky, Tom Duff,
quaternion splines will u n d o u b t e d l y be faster t h a n Lance Williams, and Jim Blinn, whom I t h a n k for their
angle i n t e r p o l a t i o n , while still free of axis bias a n d time, their comments, a n d t h e i r assurances t h a t t h e y
glmbal lock.) h a d not seen this p a r t i c u l a r wheel roll p a s t PDI,
These i n t e r p o l a n t s are not perfect, of course. Like all Berkeley, Lucasfilm, NYIT, or JPL.
i n t e r p o l a n t s , t h e y can develop kinks between the T h a n k s to everyone a t Pacific D a t a Images for the
i n t e r p o l a t e d points. There are simple algorithms for interest a n d e n c o u r a g e m e n t t h a t got me s t a r t e d .
adding new sequence points to o r d i n a r y splines w i t h o u t
altering the original curve [Boehm]; t h e y do not work The folks at Ridge C o m p u t e r were generous above and
for this i n t e r p o l a n t . A n d if these curves can be shown beyond the call of customer s u p p o r t in letting me use
to s a t i s f y some v a r i a t i o n a l principal, it will be b y their Imagen t y p e s e t t i n g system to produce this paper.
chance. It is useful to do this, because a n y solution to Lastly, I t h a n k Nori Hail for commenting on numerous
an integral equation like t h a t for splines a d m i t s drafts, and more.
subdivision [Lane et all; m i n i m u m c u r v a t u r e between

251
Q S I G G R A P H '85

References 17. KANE, THOMAS R., LIKINS, PETER W. AND LEVIN-


SON, DAVID A., Spacecraft Dynamics, McGraw-Hill,
1. BEZIER, P.E., Numerical Control - - Mathematics Inc. (1083).
and Applications, John Wiley and Sons, London
18. LANE, JEFFREY M., CARPENTER, LOREN C.,
(1072). WHITTED, TURNER, .AND BLINN~ JAMES F., "Scan
2. BOEHM, WOLFGANG, "Inserting new knots into ]3- line methods for displaying parametrically defined
spline curves," Computer-Aided Design 12(4)pp. surfaces," Comm. A C M 2a(1)pp. 23-34 (January
199-201 (July 1980). 1980).
3. BRADY,MICHAEL, "Trajectory Planning," in Robot 19. MACLANE, SAUNDERS AND BIRKHOFF, GARRETT,
Motion: Planning and Control, ed. Michael Brady, Algebra, second edition, Macmillan Publishing Co.,
John M. Hollerbach, Timothy L. Hohnson, Tomas Inc., New York (1979).
Lozano-Perez and Matthew T. Mason,The M.IT
20. MISNER, CHARLES W., THORNE, KIP S., AND
Press (1982). WHEELER, JOHN ARCHIBALD, Gravitation, W.H.
4. BROU, PHILIPPE, "Using the Gaussian Image to Freeman and Company, San Francisco (1973).
Find the Orientation of Objects," The Interna- Chapter 41 - - Spinors.
tional Journal off Robotics Research 3(4) pp. 89-125 21. MITCHELL, E.E.L. AND ROGERS, A.E., "Quaternion
(Winter 1984). Parameters in the Simulation of a Spinning Rigid
5. CAYLEY, ARTHUR, "On certain results relating to Body," in Simulation The Dynamic Modeling of
quaternions," Philosophical Magazine xxvi pp. Ideas and Systems with Computers, ed. John
141-145 (February 1845). McLeod, P.E., (1968).
6. COURANT, R. AND HILBERT, D., Methods o] 22. NEWMAN, WH LIAM M. AND SPROULL, ROBERT F.,
Mathematical Physics, Volume I, Interscience Pub- Principles of Interactive Computer Graphics, second
lishers, Inc., New York (1953). edition, McGraw-Hill, Inc., New York (1979).
7. DAttLQUIST, GERMUND AND BJiSRCK, A_KE, Numer- Chapter 21 - - Curves and surfaces.
ical Methods, Prentice-Hall, Inc., Englewood CLiffs, 23. PICKERT, G. AND STEINER; H.-G., "Chapter 8 - -
N.J. (1974). Translated by Ned Anderson. Complex numbers and quaternions," in Fundamen-
8. EULER, LEONHARD, "Decouverte d'un nouveau tals off Mathematics, Volume I - Foundations of
principe de m~canique (1752)," pp. 81-108 in Opera Mathematics: The Real Number System and Alge-
omnia, Ser. secunda, v. 5, Orell Ffisli Turici, bra, ed. H. Behnke, F. Bachmann, K. Fladt, and
Lausannae (1957). W. Sfiss, (1983). Translated by S.H. Gould.
9. EULER, LEONItARD, "Du mouvement de rotation 24. SCHMEIDLER,W. AND DREETZ, W., "Chapter 11 - -
des corps solides autour d'un axe variable (1758)," Functional analysis," in Fundamentals of
in Opera omnia, Ser. seeunda, v. 8, Orell F/isli Mathematics, Volume III - - Analysis, ed. H.
Turici, Lausannae 0" Behnke, F. Bachmann, K. Fladt, and W. Sfiss,MlT
10. GABRIEL, STEVEN A. AND KAJIYA, JAMES T., Press, Cambridge, Mass. (1983). Translated by
"Spline Interpolation in Curved Manifolds," , S.H. Gould.
(1985). Submitted 25. SCHOENBERG, I.J., "Contributions to the problem
11. GARDNER, MARTIN, New Mathematical Diversions of approximation of equidistant data by analytic
from Scientific American, Fireside, St. Louis, Mis- functions," Quart. AppL Math. 4 pp. 45-99 and
souri (1971). Chapter 2 112-141 (1946).
12. GOLDSTEIN,HERBERT, Classical Mechanics, second 2B. SMITH, ALVY RAY, "Spline tutorial notes," Techni-
edition, Addison-Wesley Publishing Company, Inc., cal Memo No. 77, Computer Graphics Project,
Reading, Mass. (1980). Chapter 4 and Appendix Lucasfilm Ltd. (May 1983).
B. 27. SOSS, W., GERICKE, H., AND BERGER, K.H.,
13. GORDON, WILLIAM J. AND RIESENFELD, RICHARD "Chapter 14 - - Differential geometry of curves and
F., "Bernstein-B~zier methods for the computer- surfaces," in Fundamentals of Mathematics,
aided design of free-form curves and surfaces," J. Volume II -- Geometry, ed. H.'Behnke, F. Bach-
A C M 21(2) pp. 293-310 (April 1974). mann, K. Fladt, and W. S/iss,MIT Press (1983).
14. GORDON, WILLIAM J. AND RIESENFELD, RICHARD Translated by S.H. Gould.
F., "B-spline curves and surfaces," in Compute~ 28. TAYLOR, RUSSELL H., "Planning and Execution of
Aided Geometric Design, ed. Robert E. Barnhill Straight Line Manipulator Trajectories," in Robot
and Richard F. Riesenfeld,Academic Press, New Motion: Planning and Control, ed. Michael Brady,
York (1974). John M. Hollerbach, Timothy L. Hohnson, Tomas
15. HAMILTON, SIR WILLIAM ROWAN, "On quatern- Lozano-Perez and Matthew T. Mason,The MIT
ions; or on a new system of imaginaries in alge- Press (1982).
bra," Philosophical Magazine xxv pp. 10-13 (July
1844).
16. HERSTEIN, I.N., Topics in Algebra, second edition,
John Wiley and Sons, Inc., New York (1975).

252
SAN FRANCISCO JULY 22-26 Volume 19, Number 3,1985

Appendix I--Conversions L8 Euler angles to quaternion

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

w 2 ~ 1/4 (1 + M l l + M22 + M33)


where ~b, 0, and ¢ are the angles of roll, pitch, and yaw,
w2>e? respe ctively.
TRUE FALSE
w=O
1.5 Matrix to Euler angles
X2 -- --1/2 (M22 + 2~'/33) While converting a matrix to a unit quaternion only
Z = (MI2 -- M21 ) / 4t.V x2>c? involves the sign ambiguity of square roots, converting
TRUE FALSE to Euler angles involves inverse trigonometric functions,
as we con only directly determine the sin's and cos's of
!,'2 = 1/2 (1 -- M ~ )
z ~ M m / 2:~
the angles. Some convention, such as principle angles,
y2>c? must be adopted. However interpolation paths will
TRUE FALSE vary greatly, depending on choice of angles. Setting
t h a t problem aside, here's a way to extract the sin's
z ~ M~3 / 2y z=l
and cos's. Looking at the previous equation, sin0 can
be read off directly as --M13. Use the trigonometric
identity cos 0 = ::t=%~"~"~0 to compute cos @to within
a sign, which is the best we can do. Assuming cos0 is
No more t h a n one square root, three divides, and a few
not zero, o b t a i n the sin's and cos's of the other angles
adds and binary scales are required for any conversion.
from

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

If cos t? is zero, t h e n we must avoid dividing by zero. It


also becomes impossible to distinguish roll from yaw.
A d o p t i n g the convention t h a t the yaw angle ¢ is 0
allows

sin ¢ = --M32

cos ¢ = M22

sine = 0

cos¢ = 1

F r o m these values a two a r g u m e n t t a n -1 will give


angles between --Tr a n d +Tr, or 0 and 275 or some other
conventional range; take your pick. (For a faster
conversion, j u s t compute, say, sin -1 a n d check the sign
of the cosine term with respect to cos6~.) Because of
the u n c e r t a i n t i e s of square roots, inverse trigonometric
functions, and yaw-roll separation, matrix to Euler
angle conversion is inherently very ill-defined.
1.6 Quaternion to Euler angles
Use the most straight-forward approach: convert the
q u a t e r n i o n to a matrix, t h e n the matrix to Euler
angles. Of course it is unnecessary to compute matrix
elements t h a t are never used. This conversion is also
u n a v o i d a b l y ill-defined, as quaternions contain no more
information a b o u t angles t h a n matrices do.

254

Você também pode gostar