
Quaternions, Interp olation and Animation Erik B. Dam Martin Ko ch Martin Lillholm [email protected] [email protected] [email protected] Technical Rep ort DIKU-TR-98/5 Department of Computer Science University of Cop enhagen Universitetsparken 1 DK-2100 Kbh Denmark July 17, 1998 Abstract The main topics of this technical rep ort are quaternions, their mathematical prop- erties, and how they can b e used to rotate ob jects. Weintro duce quaternion math- ematics and discuss why quaternions are a b etter choice for implementing rotation than the well-known matrix implementations. We then treat di erent metho ds for interp olation between series of rotations. During this treatment we give complete pro ofs for the correctness of the imp ortantinterp olation metho ds Slerp and Squad . Inspired by our treatment of the di erentinterp olation metho ds we develop our own interp olation metho d called Spring based on a set of ob jective constraints for an optimal interp olation curve. This results in a set of di erential equations, whose analytical solution meets these constraints. Unfortunately, the set of di erential equations cannot be solved analytically. As an alternative we prop ose a numerical solution for the di erential equations. The di erentinterp olation metho ds are visu- alized and commented. Finally we provide a thorough comparison of the two most convincing metho ds Spring and Squad . Thereby, this rep ort provides a comprehen- sive treatment of quaternions, rotation with quaternions, and interp olation curves for series of rotations. i Contents 1 Intro duction 1 2 Geometric transformations 3 2.1 Translation . 3 2.2 Rotation . 3 3 Two rotational mo dalities 5 3.1 Euler angles . 5 3.2 Rotation matrices . 6 3.3 Quaternions . 7 3.3.1 Historical background . 7 3.3.2 Basic quaternion mathematics . 8 3.3.3 The algebraic prop erties of quaternions. 12 3.3.4 Unit quaternions . 14 3.3.5 The exp onential and logarithm functions . 15 3.3.6 Rotation with quaternions . 17 3.3.7 Geometric intuition . 22 3.3.8 Quaternions and di erential calculus . 23 3.4 An algebraic overview . 26 ii 4 A comparison of quaternions, Euler angles and matrices 27 4.1 Euler angles/matrices | Disadvantages . 27 4.2 Euler angles/matrices | Advantages . 31 4.3 Quaternions | Disadvantages . 31 4.4 Quaternions | Advantages . 31 4.5 Conclusion . 32 4.6 Other mo dalities . 33 5 Visualizing interp olation curves 34 5.1 Direct visualization . 34 5.2 Visualizing an approximation of angular velo city . 34 5.3 Visualizing the smo othness of interp olation curves . 35 5.4 Some examples of visualization . 36 6 Interp olation of rotation 38 6.1 Interp olation b etween two rotations . 38 6.1.1 Linear Euler interp olation: LinE ul er . 38 6.1.2 Linear Matrix interp olation: LinM at . 39 6.1.3 Linear Quaternion interp olation: Ler p . 40 6.1.4 A summary of linear interp olation . 41 6.1.5 Spherical Linear Quaternion interp olation: Slerp . 42 6.2 Interp olation over a series of rotations: Heuristic approach . 49 6.2.1 Spherical Spline Quaternion interp olation: Squad . 51 6.3 Interp olation b etween a series of rotations: Mathematical approach . 56 6.3.1 The interp olation curve . 56 6.3.2 De nitions of smo othness . 56 6.3.3 The optimal interp olation . 57 6.3.4 Curvature in H . 58 1 6.3.5 Minimizing curvature in H : Continuous, analytical solution . 60 1 6.3.6 Minimizing curvature in H : Continuous, semi-analytical solution . 63 1 6.3.7 Minimizing curvature in H : Discretized, numerical solution . 64 1 iii 7 Squad and Spring 77 7.1 Example: A semi circle . 77 7.2 Example: A nice soft curve . 78 7.3 Example: Interp olation curve with cusp . 79 7.4 Example: A p endulum . 80 7.5 Example: A p erturb ed p endulum . 81 7.6 Example: Global prop erties . 81 7.7 Conclusion . 84 8 The Big Picture 85 8.1 Comparison to previous work . 85 8.2 Future work . 87 A Conventions 89 B Conversions 90 B.1 Euler angles to matrix . 90 B.2 Matrix to Euler angles . 90 B.3 Quaternion to matrix . 91 B.4 Matrix to Quaternion . 93 B.5 Between quaternions and Euler angles . 93 C Implementation 94 C.1 The basic structure of quat . 95 iv Chapter 1 Intro duction To animate means to \bring to life." Animation is a visual presentation of change. Traditionally this has b een used in the entertainment business, for example Donald Duckmoving in a carto on. More serious applications have later b een develop ed for physics visualization of particle systems and chemistry displaying molecules. This pap er treats a small part of the world of animation | animation of rotation. As a back- ground for the following chapters, we will in this section giveanoverview of how animation was done traditionally i. e. b efore the computer, and how it is done now. The presentation is based on [Foley et al., 1990 ] and [Lasseter, 1987 ]. An animation is based on a story|amanuscript. The manuscript is used to makeastoryboard, in which it is decided how to split the story into individual scenes. For each scene a sketch is made with some text describing the scene. Based on the storyb oard, a series of key frames is pro duced showing the characters of the carto on in key p ositions. The frames between the key frames can then b e made from these key p ositions. Traditionally, the most exp erienced artists pro duced the key frames and were therefore named key framers , leaving the frames in-b etween to the less exp erienced artists who b ecame known as in-betweeners . The animators pro duce a rough draft of the animation, which is presented at a pencil test. Once the draft is satisfactory, the nal version is pro duced and transferred to celluloid. This metho d of animation is called key framing and has since b een used in computer animation systems. Already in 1968 animation of 3D mo dels was known, and the idea of using computers for key frame animation was used in 1971 [Burtnyk & Wein, 1971 ]. Computers are natural replacements for the in-b etweeners. Given two key frames, the frames in-b etween can b e generated byinterp olation. Admittedly there are several problems with this approach: 1 A translation b etween twokey frames can easily b e obtained by simple linear interp olation. When the movement consists of more key frames it is necessary to use more advanced curves for example splines to pro duce a smo oth movement across key frames. Ordinary physics cannot be used to describ e how the eye p erceives moving ob jects in a carto on. Ob jects will change shap e as they move: A ball will morph into an oval when b ouncing fast see gure 1.1. This will not happ en automatically if a computer is used to animate the motion of the ball. Animation of rotational movement has also b een attempted using key frames and inter- p olation. Rotation is more complex than translation, however. The problems involved in interp olating rotations will b e treated in this pap er. Figure 1.1: The cartoon version of a bouncing bal l. Computer animation consists of much more than pure motion. Apart from the problems of interp olation of the movement there are complicated issues concerning light, sound, colors, camera angles, camera motion, shadows, physical prop erties of the ob jects b eing mo delled etc. We limit this pap er to treat metho ds for representation and implementation of rotation. The metho ds are mostly based on quaternions, a kind of four-dimensional complex numb ers. Through a series of attempts to de ne \nice" rotation, we derive a mathematical description of rotation through a series of key frames. We will not discuss the matters mentioned in the rst two bullets ab ove or the other asp ects mentioned light, sound etc. The main foundation for this pap er is the articles [Sho emake, 1985 ], [Barr et al., 1992 ], and [Watt & Watt, 1992 ]. We do not require any knowledge of these articles. It will, however, b e an advantage for the reader to b e familiar with the common transformation metho ds using matrices and to have basic knowledge of interp olation curves in the plane in particular splines . Some basic mathematics knowledge will also be advantageous group theory, di erentional calculus, calculus of variations and di erential geometry. 2 Chapter 2 Geometric transformations In this chapter we will brie y discuss selected transformations of ob jects in 3D. The key topic will b e rotation but since interp olation b etween p ositions o ers useful parallels to interp olation of rotation, we include translation. Note that these parallels serve only as inspiration for the rotational case | mainly b ecause the space of translations is Euclidean while the space of rotations is not. This di erence will b e discussed in depth in the following chapters. 2.1 Translation Translation is the most obvious kind of transformation: A p oint in space is moved from one 3 p osition to another. Let a p oint P 2 R be denoted by a 3-tuple x; y ; z ; x; y ; z 2 R and 0 the translation by a vector x; y; z . Then the new p osition P is calculated by simple 0 addition: P =x +x; y +y; z +z .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages103 Page
-
File Size-