Animation Maths: Ivo de Pauw Bieke Masselis
Animation Maths: Ivo de Pauw Bieke Masselis
CAMPUS HANDBOOK
Animation
Maths
Go to www.ecampuslearn.com.
Good luck!
Chapter 1, David Ritter; 2, John Evans; 3, Wouter Verweirder; 4, Daryl Beggs, Juan Pablo Arancibia Medina;
5, Stephanie Berghaeuser; 6, Martin Walls; 7, 12, Wouter Tansens; 8, Danie Pratt; 9, Ivo De Pauw;
10, Caetano Lacerda; 11, Ken Munyard; 13, Bieke Masselis; 14, Boke Haide; 15, Waldemar Zielinski;
16, Detje Holger; 17, Cornelia Roessing; p.25, p.103, Wouter Tansens; p.48, Wouter Verweirder;
p.52, Leo Storme; p.185, Bieke Masselis; p.268, Yu-Sung Chang; p.343, Angelo Fallein.
©
Ivo De Pauw, Bieke Masselis & Lannoo Publishers nv, Tielt, 2021.
LannooCampus Publishers
Vaartkom 41 box 01.02 P.O. Box 23202
3000 Leuven 1100 DS Amsterdam
Belgium Netherlands
www.lannoocampus.com
This book is dedicated to Malaika.
A c k n ow l e d g e m e n t s 15
C h a p t e r 2 · L i n e ar s y s t e m s 37
2.1 Definitions 38
2.2 Methods for solving linear systems 40
Solving by substitution 40
Solving by elimination 41
2.3 Exercises 45
C h a p t e r 3 · Tr i g o n o m e t r y 47
3.1 Angles 48
3.2 Triangles 50
3.3 Right triangle 54
3.4 Unit circle 55
3.5 Special angles 57
π
Trigonometric ratios for an angle of 45°= 4 rad 58
π
Trigonometric ratios for an angle of 30°= 6 rad 58
π
Trigonometric ratios for an angle of 60°= 3 rad 59
Overview 59
3.6 Pairs of angles 60
3.7 Sum identities 60
3.8 Inverse trigonometric functions 63
3.9 Exercises 65
6 A N I M AT I O N M AT H S
C h a p t e r 4 · Fu n c t i o n s 67
4.1 Basic concepts on real functions 68
4.2 Polynomial functions 69
Linear functions 69
Quadratic functions 71
4.3 Intersection of functions 73
4.4 Logarithmic functions 75
4.5 Exponential functions 76
4.6 Trigonometric functions 78
Elementary sine function 78
General sine function 78
Transversal oscillations 82
4.7 Inverse trigonometric functions 82
arcsine 82
arccosine 84
arctangent 84
atan2 85
4.8 Maclaurin expansions 86
4.9 Exercises 89
C h a p t e r 6 · C o or d i n a t e s y s t e m s 107
6.1 Cartesian coordinates 108
6.2 Parametric curves 108
6.3 Polar coordinates 112
6.4 Polar curves 115
6.5 Exercises 118
CONTENTS 7
C h a p t e r 7 · Ve c t or s 121
7.1 The concept of a vector 122
Vectors as arrows 122
Vectors as arrays 123
Free vectors 126
Base vectors 126
7.2 Addition of vectors 127
Vectors as arrows 127
Vectors as arrays 127
Vector addition summarised 128
7.3 Scalar multiplication of vectors 129
Vectors as arrows 129
Vectors as arrays 129
Scalar multiplication summarised 130
Normalisation 130
Properties 130
7.4 Vector subtraction 131
Creating free vectors 131
Euler’s method for trajectories 132
7.5 Decomposition of vectors 133
Decomposition of a plane vector 133
Base vectors defined 134
7.6 Dot product 135
Definition 135
Geometric interpretation 136
Orthogonality 139
7.7 Cross product 140
Definition 140
Geometric interpretation 142
Parallelism 144
7.8 Normal vectors 145
7.9 Exercises 147
8 A N I M AT I O N M AT H S
C h a p t e r 8 · Par a m e t e r s 149
8.1 Parametric equations 150
8.2 Vector equation of a line 151
8.3 Intersecting straight lines 155
8.4 Vector equation of a plane 157
8.5 Exercises 161
C h a p t e r 10 · C o l l i s i o n d e t e c t i o n 203
10.1 Collision detection using circles and spheres 204
Circles and spheres 204
Intersecting line and circle 206
Intersecting circles and spheres 208
10.2 Collision detection using vectors 211
Location of a point with respect to other points 211
Altitude to a straight line 212
Altitude to a plane 214
Frame rate issues 216
Location of a point with respect to a polygon 217
10.3 Exercises 220
CONTENTS 9
C h a p t e r 11 · M a t r i c e s 223
11.1 The concept of a matrix 224
11.2 Determinant of a square matrix 225
11.3 Addition and scalar multiplication of matrices 227
Addition of matrices 227
Scalar multiplication of a matrix 229
11.4 Transpose of a matrix 230
11.5 Dot product of matrices 230
Introduction 230
Condition 232
Definition 232
Properties 233
11.6 Inverse of a matrix 235
Introduction 235
Definition 235
Conditions 236
Row reduction 236
Matrix inversion 237
Inverse of a product 240
Solving systems of linear equations 241
11.7 The Fibonacci operator 243
11.8 The matrix exponential 245
Structures 245
Matrix exponential 245
11.9 Exercises 247
C h a p t e r 12 · B e z i e r c u r v e s 249
12.1 Vector equation of segments 250
Linear Bezier segment 250
Quadratic Bezier segment 251
Cubic Bezier segment 252
Bezier segments of higher degree 254
12.2 De Casteljau algorithm 255
12.3 Bezier curves 256
Concatenation 256
Linear transformations 258
Illustrations 258
12.4 Matrix representation 260
Linear Bezier segment 260
Quadratic Bezier segment 261
10 A N I M AT I O N M AT H S
C h a p t e r 13 · Tr a n s f or m a t i o n s 271
13.1 Translation 272
13.2 Scaling 277
13.3 Rotation 280
Rotation in 2D 280
Rotation in 3D 282
13.4 Reflection 284
13.5 Shearing 286
13.6 Combining standard transformations 288
2D rotation around an arbitrary centre 290
3D scaling about an arbitrary centre 293
2D reflection over an axis through the origin 294
2D reflection over an arbitrary axis 295
3D combined rotation 298
13.7 Row-representation 299
13.8 Exercises 300
C h a p t e r 14 · Tr a n s f or m a t i o n A n a l y s i s 303
Typesetting 304
14.1 Translation analysis 304
14.2 Scaling analysis 308
14.3 Rotation analysis 311
14.4 Composite transformation analysis 315
14.5 Conventions 318
14.6 Applications 319
Pivot transformation 319
Orbit transformation 320
Look-at transformation 322
14.7 Exercises 326
C h a p t e r 15 · S c e n e G r a p h s 329
15.1 Concept of a scene graph 330
15.2 Bone structures 332
CONTENTS 11
C h a p t e r 16 · V i e w Tr a n s f or m a t i o n 341
16.1 The Rendering Pipeline 342
The concept of the pipeline 342
The stages of the pipeline 342
16.2 Camera transformation 344
16.3 View transformation 346
16.4 View operator 349
16.5 Camera with zoom 351
16.6 Exercises 354
C h a p t e r 17 · H y p e r c o m p l e x n u m b e r s 357
17.1 Complex numbers 358
17.2 Complex number arithmetic 362
Complex conjugate 362
Addition and subtraction 362
Multiplication 363
Exponentiation 365
Division 366
17.3 Complex numbers and transformations 368
Translation 368
Standard rotation 369
Standard scaling 370
Composite transformation 370
17.4 Complex continuation of the Fibonacci numbers 371
Integer Fibonacci numbers 371
Complex Fibonacci numbers 372
17.5 Quaternions 374
17.6 Quaternion arithmetic 375
Addition and subtraction 375
Scalar multiplication 376
Normalisation 376
Quaternion multiplication 376
Quaternion conjugate 378
Inverse quaternion 379
17.7 Quaternions and rotations 379
Trigonometrical representation of quaternions 380
Euler representation of quaternions 380
12 A N I M AT I O N M AT H S
Bibliography 400
Index 403
Acknowledgements
We hereby insist on thanking a lot of people who made this book possible: Prof.
Dr. Leo Storme, Wim Serras, Wouter Tansens, Wouter Verweirder, Koen Samyn [14]
(credited for the chapters Transformation Analysis, Scene Graphs, View Transformation),
Hilde De Maesschalck, Ellen Deketele, Conny Meuris, Hans Ameel, Dr. Rolf Mertig,
Dick Verkerk, ir. Gose Fischer, Prof. Dr. Fred Simons, Sofie Eeckeman, Dr. Luc
Gheysens, Dr. Bavo Langerock, Wauter Leenknecht, Marijn Verspecht, Sarah Rommens,
Prof. Dr. Marcus Greferath, Dr. Cornelia Roessing, Tim De Langhe, Niels Janssens,
Peter Flynn, Jurgen Leemans, Stef Lantsoght, Hilde Vanmechelen, Jef De Langhe,
Ann Deraedt, Rita Vanmeirhaeghe, Prof. Dr. Jan Van Geel, Dr. Ann Dumoulin,
Bart Uyttenhove, Rik Leenknegt, Peter Verswyvelen, Roel Vandommele, ir. Lode De
Geyter, Bart Leenknegt, Olivier Rysman, ir. Johan Gielis, Frederik Jacques, Kristel
Balcaen, ir. Wouter Gevaert, Bart Gardin, Dieter Roobrouck, Dr. Yu-Sung Chang
(Wolfram Demonstrations [24]), Prof. Dr. Sy Blinder (Wolfram Demonstrations), Steven
De Keninck, Prof. Dr. Mark McClure (Wolfram Demonstrations), Dr. Felipe Dimer de
Oliveira (Wolfram Demonstrations), Steven Verborgh, Ingrid Viaene, Kayla Chauveau,
Angelika Kirkorova, Thomas Vanhoutte, Fries Carton, Jef Daels, Andries Geens, Angelo
Fallein, Jolan Plaum, Charles Derre, Anna Rich and whomever we might have forgotten!
As this chapter offers all the necessary mathematical skills for the full mastery of all
further topics explained in this book, we strongly recommend it. To serve its purpose, the
successive paragraphs below refresh some required aspects of mathematical language as
used on the applied level.
1.1 Algebra
Real numbers
We typeset the set of:
. natural numbers (unsigned integers) as N including zero,
. integer numbers as Z including zero,
. rational numbers as Q including zero,
. real numbers (floats) as R including zero.
All the above make a chain of subsets: N ⊂ Z ⊂ Q ⊂ R.
To avoid possible confusion, we outline a brief glossary of mathematical terms. We recall
that using the correct mathematical terms reflects correct mathematical thinking. Putting
down ideas in the correct words is of major importance for profound insight.
Sets
. We recall writing all subsets in between braces, e.g. the empty set appears as {}.
. We define a singleton as any subset containing only one element, e.g. {5} ⊂ N, as
a subset of natural numbers.
. We define a pair as any subset containing just two elements, e.g. {115, −4} ⊂ Z,
as a subset of integers. In programming the boolean values true and false make up
a pair {true, f alse} called the boolean set which we typeset as B.
. We define Z− = {. . . , −3, −2, −1} whenever we need negative integers only. We
express symbolically that −1234 is an element of Z− by typesetting −1234 ∈ Z− .
. We typeset the set minus operator to delete elements from a set by using a back-
slash, e.g. N \ {0} reading all natural numbers except zero, Q \ Z meaning all pure
rational numbers after all integer values left out and R \ {0, 1} expressing all real
numbers apart from zero and one.
ARITHMETIC REFRESHER 19
Calculation basics
operation expression a b c
We define the factorial of a natural argument as the returned product of this argument
multiplied with all natural numbers from this number n down to 1. Put in symbols:
n! = n · (n − 1) · (n − 2) · . . . · 3 · 2 · 1 restricted to n ∈ N
2! = 2 · 1 = 2, 3! = 3 · 2 · 1 = 6, 4! = 4 · 3 · 2 · 1 = 24.
We write the opposite of a real number r as −r, defined by the sum r + (−r) = 0. We
typeset the reciprocal of a nonzero real number r as 1r or r−1 , defined by the product
r · r−1 = 1.
We define subtraction as equivalent to adding the opposite: a − b = a + (−b). We define
division as equivalent to multiplying with the reciprocal: a : b = a · b−1 .
When we mix operations we need to apply priority rules for them. There is a fixed priority
list ‘PEMDAS’ in performing mixed operations in R that can easily be memorised by
‘Please Excuse My Dear Aunt Sally’.
. First process all that is delimited in between Parentheses,
. then Exponentiate,
. then Multiply and Divide from left to right,
. finally Add and Subtract from left to right.
20 A N I M AT I O N M AT H S
(a + b)3 6= a3 + b3 ,
√ √ √
a + b 6= a + b,
p
x2 + y2 6= x + y.
Fractions
A fraction is what we call any rational number written as nt given t, n ∈ Z and n 6= 0,
wherein t is called the numerator and n the denominator. We define the reciprocal of a
−1
nonzero fraction nt as 1t = nt or as the power nt . We define the opposite fraction as
n
−t
− nt = n = t
−n . We summarise fractional arithmetic:
t
sum n + ab = t·b+n·a
n·b
t
difference n − ab = t·b−n·a
n·b
t
product n · ab = t·a
n·b
t
division n
a = nt · ab
b
t m m
= nt m
exponentiation n
1
singular fractions 0 = ±∞ infinity (see page 76)
0
0 =? indeterminate
Powers
We define a power as any real number written as gm , wherein g is called its base and m
its exponent. The opposite of gm is simply −gm . The reciprocal of gm is g1m = g−m , given
g 6= 0.
ARITHMETIC REFRESHER 21
multiply g3 · g2 = g3+2 = g5 ,
g3
divide g2
= g3 · g−2 = g3−2 = g1 ,
2
exponentiate g3 = g3·2 = g6 them.
p
We insist on avoiding typesetting radicals like 7 g3 and strongly recommend their con-
temporary notation using radicand g and exponent 73 , consequently exponentiating g to
3 √ 1
g 7 . We recall the fact that all square roots are non-negative numbers, a = a 2 ∈ R+ for
a ∈ R+ .
As well as knowing the above exponent types, understanding the above rules to calcu-
late them is necessary for using powers successfully. We advise memorising the integer
squares running from 12 = 1, 22 = 4, . . ., up to 152 = 225, 162 = 256 and the integer cubes
running from 13 = 1, 23 = 8, . . ., up to 73 = 343, 83 = 512 in order to easily recognise
them.
Recall that the only way out of any power is exponentiating with its reciprocal exponent.
For this purpose we need to exponentiate both left hand side and right hand side of any
given relation (see also paragraph 1.2).
√7
Example: Find x when x3 = 5 by exponentiating this power.
3
3 7 7
3
x 7 = 5 ⇐⇒ x 7 = (5) 3 ⇐⇒ x ≈ 42.7494.
We emphasise the above strategy as the only successful one to free base x from its expo-
nent, yielding its correct expression numerically approximated if we wish to.
Example: Find x when x2 = 5 by exponentiating this power.
21 1 1
x2 = 5 ⇐⇒ x2 = (5) 2 or − (5) 2 ⇐⇒ x ≈ 2.23607 or − 2.23607.
We recall the above double solution whenever we free base x from an even exponent,
yielding their correct expression as accurately as we wish to.
22 A N I M AT I O N M AT H S
Mathematical expressions
Composed mathematical expressions can often seem intimidating or cause confusion.
To gain transparency in them, we firstly recall indexed variables which we define as
subscripted to count them: x1 , x2 , x3 , x4 , . . . , x99999 , x100000 , . . ., and α0 , α1 , α2 , α3 , α4 , . . . .
It is common practice in industrial research to use thousands of variables, so just picking
unindexed characters would be insufficient. Taking our own alphabet as an example, it
would only provide us with 26 characters.
We define finite expressions as composed of (math-
ematical) operations on objects (numbers, variables
or structures). We can for instance analyse the ex-
pression (3a + x)4 by drawing its tree form. This
example reveals a Power having exponent 4 and a
subexpression in its base. The base itself yields a
sum of the variable x Plus another subexpression.
This final subexpression shows the product 3 Times
a.
Let us also evaluate this expression (3a + x)4 . Say
a = 1, then we see our expression partly collapse
to (3 + x)4 . If, on top of this, we assign x = 2, our
expression then finally turns to the numerical value
(3 + 2)4 = 54 = 625.
When we expand this power to its pure sum expression 81a4 + 108a3 x + 54a2 x2 +
12ax3 + x4 , we did nothing but reshape its pure product expression (3a + x)4 .
We warn that trying to solve this expression – which is not a relation – is completely in
vain. Recall that inequalities, equations and systems of equations or inequalities are the
only objects in the universe we can (try to) solve mathematically.
Relational operators
We also refresh the use of correct terms for inequalities and equations.
We define an inequality as any variable expression comparing a left hand side to a right
hand side by applying the ‘is-(strictly)-less-than’ or by applying the ‘is-(strictly)-greater-
than’ operator. For example, we can read (3a + x)4 6 (b + 4)(x + 3) containing variables
a, x, b. Consequently we may solve such inequality for any of the unknown quantities a, x
or b.
We define an equation as any variable expression comparing a left hand side to a right
hand side by applying the ‘is-equal-to’ operator. For example (3a + x)4 = (b + 4)(x + 3)
is an equation containing variables a, x, b. Consequently we also may solve equations for
any of the unknown quantities a, x or b.