CAMPUS HANDBOOK
IVO DE PAUW BIEKE MASSELIS
Animation Maths
Titelpagina.indd 1
1/06/2021 18:44
eCampusLearn
Go to www.ecampuslearn.com.
Fill in the following code: 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.
D/2021/45/69 – ISBN 978 94 014 7495 5 – NUR 918 Cover design: Keppie & Keppie Interior design: Ivo De Pauw, Bieke Masselis ©
Ivo De Pauw, Bieke Masselis & Lannoo Publishers nv, Tielt, 2021.
LannooCampus Publishers is a subsidiary of Lannoo Publishers, the book and multimedia division of Lannoo Publishers nv. All rights reserved. No part of this publication may be reproduced and/or made public, by means of printing, photocopying, microfilm or any other means, without the prior written permission of the publisher. LannooCampus Publishers Vaartkom 41 box 01.02 3000 Leuven Belgium www.lannoocampus.com
P.O. Box 23202 1100 DS Amsterdam Netherlands
This book is dedicated to Malaika.
“Sometimes I’m black, sometimes I’m white it all depends on who is on the other side there are things they cannot see and there are things I can not hide” Bruno Deneckere (Someday, June 2006)
Contents
A c k n ow l e d g e m e n t s
15
Chapter 1 · Arithmetic refresher 1.1
1.2
1.3 1.4
17
Algebra Real numbers Real polynomials Equations in one variable Linear equations Quadratic equations Logarithms Exercises
18 18 23 25 25 26 31 34
C h a p t e r 2 · L i n e ar s y s t e m s 2.1 2.2
2.3
37
Definitions Methods for solving linear systems Solving by substitution Solving by elimination Exercises
38 40 40 41 45
C h a p t e r 3 · Tr i g o n o m e t r y 3.1 3.2 3.3 3.4 3.5
3.6 3.7 3.8 3.9
Angles Triangles Right triangle Unit circle Special angles Trigonometric ratios for an angle of 45°= Trigonometric ratios for an angle of 30°= Trigonometric ratios for an angle of 60°= Overview Pairs of angles Sum identities Inverse trigonometric functions Exercises
47
π 4 π 6 π 3
rad rad rad
48 50 54 55 57 58 58 59 59 60 60 63 65
A N I M AT I O N M AT H S
6
C h a p t e r 4 · Fu n c t i o n s 4.1 4.2
4.3 4.4 4.5 4.6
4.7
4.8 4.9
Basic concepts on real functions Polynomial functions Linear functions Quadratic functions Intersection of functions Logarithmic functions Exponential functions Trigonometric functions Elementary sine function General sine function Transversal oscillations Inverse trigonometric functions arcsine arccosine arctangent atan2 Maclaurin expansions Exercises
67 68 69 69 71 73 75 76 78 78 78 82 82 82 84 84 85 86 89
Chapter 5 · The Golden Section
91
The golden number The golden section The golden triangle The golden rectangle The golden spiral The golden pentagon The golden ellipse Golden arithmetic Golden identities The Fibonacci numbers The golden section worldwide Exercises
92 94 94 95 96 98 98 99 99 100 103 105
5.1 5.2
5.3
5.4 5.5
C h a p t e r 6 · C o or d i n a t e s y s t e m s 6.1 6.2 6.3 6.4 6.5
Cartesian coordinates Parametric curves Polar coordinates Polar curves Exercises
107 108 108 112 115 118
CONTENTS
C h a p t e r 7 · Ve c t or s 7.1
7.2
7.3
7.4
7.5
7.6
7.7
7.8 7.9
The concept of a vector Vectors as arrows Vectors as arrays Free vectors Base vectors Addition of vectors Vectors as arrows Vectors as arrays Vector addition summarised Scalar multiplication of vectors Vectors as arrows Vectors as arrays Scalar multiplication summarised Normalisation Properties Vector subtraction Creating free vectors Euler’s method for trajectories Decomposition of vectors Decomposition of a plane vector Base vectors defined Dot product Definition Geometric interpretation Orthogonality Cross product Definition Geometric interpretation Parallelism Normal vectors Exercises
7
121 122 122 123 126 126 127 127 127 128 129 129 129 130 130 130 131 131 132 133 133 134 135 135 136 139 140 140 142 144 145 147
A N I M AT I O N M AT H S
8
C h a p t e r 8 · Par a m e t e r s 8.1 8.2 8.3 8.4 8.5
Parametric equations Vector equation of a line Intersecting straight lines Vector equation of a plane Exercises
Chapter 9 · Kinematics 9.1 9.2 9.3
9.4
9.5
9.6
9.7
Measures Deltatime Translational motion Rectilinear motion with constant velocity (RMCV) Rectilinear motion with constant acceleration (RMCA) Free fall Summary Circular motion Uniform circular motion (UCM) Nonuniform circular motion (NCM) Summary Planar curvilinear motion Normal-tangential components Radial-angular components Independence of Motion Combined rectilinear motions with constant velocities Projectile motion (PM) Exercises
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 10.1 Collision detection using circles and spheres Circles and spheres Intersecting line and circle Intersecting circles and spheres 10.2 Collision detection using vectors Location of a point with respect to other points Altitude to a straight line Altitude to a plane Frame rate issues Location of a point with respect to a polygon 10.3 Exercises
149 150 151 155 157 161
163 164 165 165 168 168 171 174 176 176 183 186 187 188 191 194 194 195 200
203 204 204 206 208 211 211 212 214 216 217 220
CONTENTS
C h a p t e r 11 · M a t r i c e s 11.1 The concept of a matrix 11.2 Determinant of a square matrix 11.3 Addition and scalar multiplication of matrices Addition of matrices Scalar multiplication of a matrix 11.4 Transpose of a matrix 11.5 Dot product of matrices Introduction Condition Definition Properties 11.6 Inverse of a matrix Introduction Definition Conditions Row reduction Matrix inversion Inverse of a product Solving systems of linear equations 11.7 The Fibonacci operator 11.8 The matrix exponential Structures Matrix exponential 11.9 Exercises
C h a p t e r 12 · B e z i e r c u r v e s 12.1 Vector equation of segments Linear Bezier segment Quadratic Bezier segment Cubic Bezier segment Bezier segments of higher degree 12.2 De Casteljau algorithm 12.3 Bezier curves Concatenation Linear transformations Illustrations 12.4 Matrix representation Linear Bezier segment Quadratic Bezier segment
9
223 224 225 227 227 229 230 230 230 232 232 233 235 235 235 236 236 237 240 241 243 245 245 245 247
249 250 250 251 252 254 255 256 256 258 258 260 260 261
A N I M AT I O N M AT H S
10
Cubic Bezier segment 12.5 B-splines Cubic B-splines Matrix representation De Boor’s algorithm 12.6 Exercises
C h a p t e r 13 · Tr a n s f or m a t i o n s
262 264 264 265 267 269
271
13.1 Translation 13.2 Scaling 13.3 Rotation Rotation in 2D Rotation in 3D 13.4 Reflection 13.5 Shearing 13.6 Combining standard transformations 2D rotation around an arbitrary centre 3D scaling about an arbitrary centre 2D reflection over an axis through the origin 2D reflection over an arbitrary axis 3D combined rotation 13.7 Row-representation 13.8 Exercises
272 277 280 280 282 284 286 288 290 293 294 295 298 299 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
14.1 14.2 14.3 14.4 14.5 14.6
14.7
Typesetting Translation analysis Scaling analysis Rotation analysis Composite transformation analysis Conventions Applications Pivot transformation Orbit transformation Look-at transformation Exercises
304 304 308 311 315 318 319 319 320 322 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 15.2 Bone structures
330 332
CONTENTS
15.3 Solar systems 15.4 Exercises
C h a p t e r 16 · V i e w Tr a n s f or m a t i o n 16.1 The Rendering Pipeline The concept of the pipeline The stages of the pipeline 16.2 Camera transformation 16.3 View transformation 16.4 View operator 16.5 Camera with zoom 16.6 Exercises
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 17.1 Complex numbers 17.2 Complex number arithmetic Complex conjugate Addition and subtraction Multiplication Exponentiation Division 17.3 Complex numbers and transformations Translation Standard rotation Standard scaling Composite transformation 17.4 Complex continuation of the Fibonacci numbers Integer Fibonacci numbers Complex Fibonacci numbers 17.5 Quaternions 17.6 Quaternion arithmetic Addition and subtraction Scalar multiplication Normalisation Quaternion multiplication Quaternion conjugate Inverse quaternion 17.7 Quaternions and rotations Trigonometrical representation of quaternions Euler representation of quaternions
11
336 339
341 342 342 342 344 346 349 351 354
357 358 362 362 362 363 365 366 368 368 369 370 370 371 371 372 374 375 375 376 376 376 378 379 379 380 380
A N I M AT I O N M AT H S
12
Quaternion exponentiation The quest for the quaternion rotation Unit rotation quaternion 17.8 Exercises
Annex A · Real numbers in computers A.1 Scientific notation A.2 The decimal computer A.3 Special values
Annex B · Notations and Conventions B.1 Alphabets Latin alphabet Greek alphabet B.2 Mathematical symbols Sets Mathematical symbols Mathematical keywords Numbers
Annex C · The International System of Units (SI) C.1 C.2 C.3 C.4
SI SI SI SI
Prefixes Base measures Supplementary measure Derived measures
381 382 385 389
391 391 391 392
393 393 393 394 394 394 395 396 396
397 397 398 398 399
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!
Hereby our special thanks to Dick Verkerk for supporting our Wolfram Application Server [25]) server in the Netherlands at can.nl
Chapter 1 · Arithmetic refresher
A N I M AT I O N M AT H S
18
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 backslash, 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
to add
a+b = c
term
term
sum
to subtract
a−b = c
term
term
difference
to multiply
a·b = c
factor
factor
product
to divide
a b
numerator
divisor or denominator
quotient or fraction
to exponentiate
base
exponent
power
to take the root
ab = c √ b a=c
radicand
index
radical
return factorial
n! = c
= c, b 6= 0
n factorial
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 Furthermore we define 1! = 1 and as well 0! = 1. Examples: 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.
A N I M AT I O N M AT H S
20
Now we discuss the distributive law ruling within R, which we define as threading a ‘superior’ operation over an ‘inferior’ operation. In conclusion, distributing requires two different operations. Hence we distribute exponentiating over multiplication as in (a · b)3 = a3 · b3 . Likewise rules multiplying over addition as in 3 · (a + b) = 3 · a + 3 · b. However we should never stumble on this ‘Staircase of Distributivity’ by going too fast: (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 − nt =
−t n
=
t −n .
n
We summarise fractional arithmetic: sum
t n
+ ab =
t·b+n·a n·b
difference
t n
− ab =
t·b−n·a n·b
product
t n
· ab =
division
t n a b
exponentiation singular fractions
t·a n·b
= nt · ab m t m = nt m n
1 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
According to the exponent type we distinguish between: g3 = g · g · g
3 ∈ N,
1 g−3 = g13 = g·g·g 1 √ g 3 = 3 g = w ⇔ w3 = g
−3 ∈ Z,
g0 = 1
g 6= 0.
1 3
∈ Q,
Whilst calculating powers we may have to: multiply
g3 · g2 = g3+2 = g5 ,
divide
g3 g2
exponentiate
= g3 · g−2 = g3−2 = g1 , 2 g3 = g3·2 = g6 them.
p We insist on avoiding typesetting radicals like 7 g3 and strongly recommend their contemporary 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 calculate 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 7 7 3 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 exponent, yielding its correct expression numerically approximated if we wish to. Example: Find x when x2 = 5 by exponentiating this power. x2 = 5 ⇐⇒ x2
21
1
1
= (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 (mathematical) operations on objects (numbers, variables or structures). We can for instance analyse the expression (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)-greaterthan’ 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.