<<

Appendix A

This appendix surveys some of the important basic concepts in linear algebra that often appear in computer graphics literature. It is not meant to be a complete reference for linear algebra; however, it covers the concepts required to read this book. Skilled readers may skip this appendix.

A.1 Matrices

A is an array of numbers, entries, components, terms or elements. An n × m matrix A consists of n rows and m columns and is expressed as ⎡ ⎤ a11 a12 ... a1m ⎢ ⎥ ⎢ a21 a22 ... a2m ⎥ A = ⎢ . . . . ⎥ . (A.1) ⎣ . . .. . ⎦ an1 an2 ... anm

A matrix is called if the number of rows and the number of columns are equal (i.e., if n = m); otherwise, it is called rectangular (i.e., if n = m). A is orthogonal when the dot (Sect. A.4.3.2)ofanypair of rows or any pair of columns is zero and when the columns and the rows are unit vectors (Sect. A.4.1). Also, the inverse (Sect. A.2.2) and the (Sect. A.2.3) of an orthogonal matrix are equal.

A.1.1 Identity Matrix

An identity matrix I is a square matrix where aij = 1 when i = j and aij = 0 otherwise. Hence, an identity matrix is expressed as

R. Elias, Digital Media, DOI: 10.1007/978-3-319-05137-6, 625 © Springer International Publishing Switzerland 2014 626 Appendix A: Linear Algebra ⎡ ⎤ 10... 0 ⎢ ⎥ ⎢ 01... 0 ⎥ I = ⎢ . . . . ⎥ . (A.2) ⎣ . . .. . ⎦ 00... 1

As a convention, the identity matrix is always referred to by the letter I.

A.1.2 Diagonal Matrix

A diagonal matrix D is a square matrix with zero entries except for those of the main diagonal (i.e., where i = j). In other words, an n × n matrix D is diagonal if aij = 0 | i = j ∀ i, j ∈{1, 2,...,n}. Hence, a diagonal matrix is expressed as ⎡ ⎤ a11 0 ... 0 ⎢ ⎥ ⎢ 0 a22 ... 0 ⎥ D = ⎢ . . . . ⎥ . (A.3) ⎣ . . .. . ⎦ 00... ann

The same diagonal matrix may also be denoted as D = diag(a11, a22,...,ann) where a11, a22,...,ann are the elements of the main diagonal. Matrix diagonalization is converting a square matrix into a diagonal matrix.

A.1.3 Symmetric Matrix

A symmetric matrix is a square matrix where aij = a ji. For an n × n, it can be expressed as ⎡ ⎤ a11 a12 ... a1n ⎢ ⎥ ⎢ a12 a22 ... a2n ⎥ A = ⎢ . . . . ⎥ . (A.4) ⎣ . . .. . ⎦ a1n a2n ... ann

In this case, A = AT . This implies that A−1AT = I.

A.1.4 Anti-Symmetric Matrix

An anti-symmetric or skew symmetric matrix is a square matrix where aij =−a ji. For an n × n, it can be expressed as Appendix A: Linear Algebra 627 ⎡ ⎤ 0 a12 ... a1n ⎢ ⎥ ⎢ −a12 0 ... a2n ⎥ A = ⎢ . . . . ⎥ . (A.5) ⎣ . . .. . ⎦ −a1n −a2n ... 0

An anti-symmetric matrix must have zeros on its diagonal. In this case, A =−AT . This implies that −A−1AT = I.

A.2 Matrix Operations

Some matrix operations are applied to single matrices (e.g., , inverse, transpose and ) while others are applied to pairs of matrices (e.g., addition, subtraction and multiplication). In the following sections, we will talk about some of the most important matrix operations.

A.2.1 Matrix Determinant

A matrix determinant is defined for a square matrix. A 2× 2 matrix determinant |A|  is defined as a11 a12 a11 a12 |A|≡det ≡ a21 a22 a21 a22 (A.6) = a11a22 − a12a21.

A3× 3 matrix determinant |A| is defined as ⎡ ⎤

a11 a12 a13 a11 a12 a13 ⎣ ⎦ |A|≡det a21 a22 a23 ≡ a21 a22 a23

a31 a32 a33 a31 a32 a33

a22 a23 a21 a23 a21 a22 = a11 − a12 + a13 a32 a33 a31 a33 a31 a32

= a11(a22a33 − a23a32) − a12(a21a33 − a23a31) + a13(a21a32 − a22a31). (A.7)

A.2.2 Matrix Inverse

− − The inverse of a square matrix A is another square matrix A 1 such that AA 1 = I. a a If A = 11 12 then the inverse A−1 is calculated as a21 a22 628 Appendix A: Linear Algebra  − −1 = 1 a22 a12 A |A| −a21 a11 − (A.8) = 1 a22 a12 . a a − a a 11 22 12 21 −a21 a11

For a 3 × 3matrixA,theinverseA−1 is defined as ⎡ ⎤

a22 a23 a13 a12 a12 a13 ⎢ ⎥ ⎢ a32 a33 a33 a32 a22 a23 ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − 1 ⎢ a23 a21 a11 a13 a13 a11 ⎥ A 1 = ⎢ ⎥ . (A.9) |A| ⎢ a33 a31 a31 a33 a23 a21 ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ a21 a22 a12 a11 a11 a12

a31 a32 a32 a31 a21 a22

Example A.1 [Matrices–inverse] Compute the inverse for the following matrix: ⎡ ⎤ 111 A = ⎣ 331⎦ . 411

Solution A.1 There are two steps: 1. Get the determinant |A| by applying Eq. (A.7). Thus,

|A|=1 × (3 × 1 − 1 × 1) − 1 × (3 × 1 − 4 × 1) + 1 × (3 × 1 − 3 × 4) =−6.

2. Get the inverse A−1 by applying Eq. (A.9)as ⎡ ⎤

31 11 11 ⎢ ⎥ ⎢ 11 11 31 ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − 1 ⎢ 13 11 11 ⎥ A 1 = ⎢ ⎥ −6 ⎢ 14 41 13 ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ 33 11 11 41 14 33 ⎡ ⎤ 20−2 1 = ⎣ 1 −32⎦ − 6 −93 0 Appendix A: Linear Algebra 629 ⎡ ⎤ − 1 0 1 ⎢ 3 3 ⎥ = ⎢ − 1 1 − 1 ⎥ . ⎣ 6 2 3 ⎦  1 − 1 1 2 2 0

A.2.3 Matrix Transpose

The transpose of a matrix A is the matrix obtained by replacing all elements aij with a ji (i.e., columns become rows and rows become columns). The transpose of A is denoted by AT . Thus, we can write (AT )T = A.

Example A.2 [Matrices–transpose]  123 Get the transpose of A where A = . 456

Solution A.2 The inverse can be expressed as ⎡ ⎤  T 14 123 AT = = ⎣ 25⎦ .  456 36

A.2.4 Addition and Subtraction

Matrices of the same size can be added together (or subtracted from each other) by adding (or subtracting) the corresponding elements. Thus, for two matrices A and B of size n × m, we may have ⎡ ⎤ ⎡ ⎤ a11 a12 ... a1m b11 b12 ... b1m ⎢ ⎥ ⎢ ⎥ ⎢ a21 a22 ... a2m ⎥ ⎢ b21 b22 ... b2m ⎥ A + B = ⎢ . . . . ⎥ + ⎢ . . . . ⎥ ⎣ . . .. . ⎦ ⎣ . . .. . ⎦ an1 an2 ... anm bn1 bn2 ... bnm ⎡ ⎤ (A.10) a11 + b11 a12 + b12 ... a1m + b1m ⎢ ⎥ ⎢ a21 + b21 a22 + b22 ... a2m + b2m ⎥ = ⎢ . . . . ⎥ ⎣ . . .. . ⎦ an1 + bn1 an2 + bn2 ... anm + bnm or 630 Appendix A: Linear Algebra ⎡ ⎤ ⎡ ⎤ a11 a12 ... a1m b11 b12 ... b1m ⎢ ⎥ ⎢ ⎥ ⎢ a21 a22 ... a2m ⎥ ⎢ b21 b22 ... b2m ⎥ A − B = ⎢ . . . . ⎥ − ⎢ . . . . ⎥ ⎣ . . .. . ⎦ ⎣ . . .. . ⎦ an1 an2 ... anm bn1 bn2 ... bnm ⎡ ⎤ (A.11) a11 − b11 a12 − b12 ... a1m − b1m ⎢ ⎥ ⎢ a21 − b21 a22 − b22 ... a2m − b2m ⎥ = ⎢ . . . . ⎥ . ⎣ . . .. . ⎦ an1 − bn1 an2 − bn2 ... anm − bnm

Example A.3 [Matrices–addition and subtraction ]  1234 355 6 Consider two matrices A and B where A = and B = . 5677 78910 Calculate the addition A+B and the subtractions A−B and B−A.

Solution A.3 The addition is performed by adding corresponding terms as   1234 355 6 A + B = + 5677 78910  + + + + = 1 32 53 54 6 5 + 76+ 87+ 97+ 10  = 47810. 12 14 16 17

The subtraction is performed by subtracting corresponding terms as   1234 355 6 A − B = − 5677 78910  − − − − = 1 32 53 54 6 5 − 76− 87− 97− 10  − − − − = 2 3 2 2 −2 −2 −2 −3   355 6 1234 B − A = − 78910 5677  − − − − = 3 15 25 36 4 7 − 58− 69− 710− 7  = 2322 . 2223

Notice that B − A =−[A − B].  Appendix A: Linear Algebra 631

Example A.4 [Matrices–addition and subtraction ]  123 35 Consider two matrices A and B where A = and B = . Calculate 567 78 the addition A+B and the subtractions A−B and B−A.

Solution A.4 Since the sizes of the matrices are different, none of the operations can be performed. 

A.2.5

Scalar multiplication is an operation performed by multiplying each of the elements of a matrix by a scalar value. Thus, for a n × m matrix A and a scalar value s,we can write ⎡ ⎤ ⎡ ⎤ a11 a12 ... a1m sa11 sa12 ... sa1m ⎢ ⎥ ⎢ ⎥ ⎢ a21 a22 ... a2m ⎥ ⎢ sa21 sa22 ... sa2m ⎥ sA = s ⎢ . . . . ⎥ = ⎢ . . . . ⎥ . (A.12) ⎣ . . .. . ⎦ ⎣ . . .. . ⎦ an1 an2 ... anm san1 san2 ... sanm

Example A.5 [Matrices–scalar multiplication ] 123 If a matrix A is defined as A = , get the result of sA where s = 2.5. 456

Solution A.5 The scalar value is multiplied by each matrix term individually. Thus,   123 2.557.5 sA = 2.5 = .  456 10 12.515 Example A.6 [Matrices–scalar multiplication and addition/subtraction  ] 1234 355 6 Consider two matrices A and B where A = and B = . 5677 78910 Calculate A+2B and 2A−B.

Solution A.6   1234 355 6 A + 2B = + 2 5677 78910   = 1234 + 6101012 5677 14 16 18 20  + + + + = 1 62 10 3 10 4 12 5 + 14 6 + 16 7 + 18 7 + 20  = 7121316 . 19 22 25 27 632 Appendix A: Linear Algebra   1234 355 6 2A − B = 2 − 5677 78910   = 2468 − 355 6 10 12 14 14 78910  − − − − = 2 34 56 58 6 10 − 712− 814− 914− 10  − − = 1 112 . 3454 

A.2.6

In order to multiply two matrices A and B, the number of columns of the first matrix A must be equal to the number of rows of the second B. The resulting matrix has the same number of rows as the first and the same number of columns as the second. Thus, if A is of size n × m and B is of size m × k, the resulting matrix C will be of size n × k. This can be written as

AB = ⎡C ⎤ c11 c12 ... c1k ⎢ ⎥ ⎢ c21 c22 ... c2k ⎥ = ⎢ . . . . ⎥ ⎣ . . .. . ⎦ cn1 cn2 ... cnk ⎡ ⎤ i< =m i< =m i< =m ⎢ a i bi a i bi ... a i bik ⎥ (A.13) ⎢ 1 1 1 2 1 ⎥ ⎢ i=1 i=1 i=1 ⎥ ⎢ i< =m i< =m i< =m ⎥ ⎢ ... ⎥ ⎢ a2i bi1 a2i bi2 a2i bik ⎥ = ⎢ i=1 i=1 i=1 ⎥ , ⎢ . . . . ⎥ ⎢ . . .. . ⎥ ⎢ ⎥ ⎣ i< =m i< =m i< =m ⎦ anibi1 anibi2 ... anibik i=1 i=1 i=1 ⎡ ⎤ ⎡ ⎤ a11 a12 ... a1m b11 b12 ... b1k ⎢ ⎥ ⎢ ⎥ ⎢ a21 a22 ... a2m ⎥ ⎢ b21 b22 ... b2k ⎥ where A = ⎢ . . . . ⎥ and B = ⎢ . . . . ⎥. ⎣ . . .. . ⎦ ⎣ . . .. . ⎦ an1 an2 ... anm bm1 bm2 ... bmk Appendix A: Linear Algebra 633

Example A.7 [Matrices–multiplication] ⎡ ⎤  345 123 Consider two matrices A and B where A = and B = ⎣ 678⎦. Calculate 456 123 the (a) AB.(b)BA.(c)BAT .

Solution A.7 (a) The multiplication AB: ⎡ ⎤  345 123 AB = ⎣ 678⎦ 456 123  × + × + × × + × + × × + × + × = 1 3 2 6 3 11 4 2 7 3 21 5 2 8 3 3 4 × 3 + 5 × 6 + 6 × 14× 4 + 5 × 7 + 6 × 24× 5 + 5 × 8 + 6 × 3  = 18 24 30 . 48 63 78

(b) The multiplication BA: This operation cannot be performed since the number of columns of B (i.e. 3) is not equal to the number of rows of A (i.e., 2). (c) The multiplication BAT : ⎡ ⎤  345 T 123 BAT = ⎣ 678⎦ 456 123 ⎡ ⎤ ⎡ ⎤ 345 14 = ⎣ 678⎦ ⎣ 25⎦ 123 36 ⎡ ⎤ 3 × 1 + 4 × 2 + 5 × 33× 4 + 4 × 5 + 5 × 6 = ⎣ 6 × 1 + 7 × 2 + 8 × 36× 4 + 7 × 5 + 8 × 6 ⎦ 1 × 1 + 2 × 2 + 3 × 31× 4 + 2 × 5 + 3 × 6 ⎡ ⎤ 26 62 = ⎣ 44 107 ⎦ . 14 32 

Example A.8 [Matrices–multiplication]   1 0 30 A B A = 3 B = Consider two matrices and where − 2 1 and . Calculate 3 3 63 the multiplications (a) AB.(b)BA. 634 Appendix A: Linear Algebra

Solution A.8 (a) The multiplication AB:   1 0 30 AB = 3 − 2 1 63  3 3 1 × + × 1 × + × = 3 3 0 6 3 0 0 3 − 2 × 3 + 1 × 6 − 2 × 0 + 1 × 3  3 3 3 3 = 10 . 01

(b) The multiplication BA:   30 1 0 BA = 3 63 − 2 1 3 3 3 × 1 + 0 ×−2 3 × 0 + 0 × 1 = 3 3 3 6 × 1 + 3 ×−2 6 × 0 + 3 × 1  3 3 3 = 10 . 01

Notice that AB = BA = I. This implies that A−1 = B and B−1 = A. 

A.3 Vectors

The number of components, terms or elements in a vector determines its (e.g., a 2D vector contains two elements and an nD vector contains n elements). There are two types of vectors; column vectors and row vectors. A column vector v1 is a matrix of one column that contains multiple values. It can be indicated as ⎡ ⎤ v1 ⎣ ⎦ T v1 = v2 =[v1, v2, v3] . v3

A row vector v2 is a matrix of one row that contains multiple values. It can be indicated as

v2 =[v1, v2, v3].

By convention, if the type is not indicated, it is assumed to be a column vector. Two vectors u =[u1, u2, u3] and v =[v1, v2, v3] are equal if their corresponding elements are equal (i.e., u1 = v1, u2 = v2 and u3 = v3). Appendix A: Linear Algebra 635

Example A.9 [Vectors–equal vectors] If the vectors u =[2x, x +z, 3y] and v =[2.5y, 2y, 12] are equal, find the values of x, y and z.

Solution A.9 Since the vectors u and v are equal, their corresponding elements are equal. Thus, we can write 2x = 2.5y, x + z = 2y, 3y = 12.

Solving these three equations yields

x = 5, y = 4, z = 3. 

A.4 Vector Operations

There are many operations that can be performed on vectors. Some of these operations deal with single vectors (e.g., vector normalization and scalar multiplication) while others handle pairs of them (e.g., addition, subtraction, and ).

A.4.1 Normalization and Unit Vectors

The of a vector v indicates its . It is denoted as v. (Some references denote the norm of a vector v as |v|.) The norm is defined as the of the sum of the squares of all elements. For an nD vector, it can be calculated as   = 2 + 2 +···+ 2. v v1 v2 vn (A.14)

Example A.10 [Vectors–norm of a vector] Get the norm of the vector v =[2, 5, 8, 9].

Solution A.10 The norm is obtained using Eq. (A.14)as  √ v= 22 + 52 + 82 + 92 = 174 = 13.1909. 

In case v=1, the vector v is said to be a . A unit vector can be treated as a direction. For example, unit vectors along the x-, y- and z-axes are i =[1, 0, 0]T , j =[0, 1, 0]T and k =[0, 0, 1]T respectively. These are called unit Cartesian vectors. On the other hand, any vector can be converted to a unit vector 636 Appendix A: Linear Algebra through a process that is called normalization. In order to normalize a vector v,divide each of its elements by its norm v to get v vˆ = , (A.15) v where vˆ is a unit vector (i.e., vˆ=1). Throughout this book, the context clarifies whether or not the vector under consideration is a unit vector.

Example A.11 [Vectors–normalization of a vector] Normalize the vector v =[2, 5, 8, 9]. √ Solution A.11 The norm of v, v,is 174 as computed in Example A.10. Hence, vˆ is computed using Eq. (A.15)as

ˆ = v v v = [2√,5,8,9]  174  = √2 , √5 , √8 , √9 174 174 174 174 =[0.1516, 0.3790, 0.6065, 0.6823]. 

A.4.2 Addition and Subtraction

Vectors of the same size can be added together (or subtracted from each other) by adding (or subtracting) the corresponding elements. Thus, for two vectors u and v of size n,wehave ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ u1 v1 u1 ± v1 ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ u2 ⎥ ⎢ v2 ⎥ ⎢ u2 ± v2 ⎥ u ± v = ⎢ . ⎥ ± ⎢ . ⎥ = ⎢ . ⎥ . (A.16) ⎣ . ⎦ ⎣ . ⎦ ⎣ . ⎦ un vn un ± vn

˙ T ˙ T Given two 3D points P1 =[x1, y1, z1] and P2 =[x2, y2, z2] , vector subtraction ˙ ˙ can be used to define a direction vector u from P1 to P2 as ⎡ ⎤ x2 − x1 ⎣ ⎦ u = y2 − y1 . (A.17) z2 − z1

Example A.12 [Vectors–addition and subtraction] Consider two vectors u =[5, 6, 7, 8]T and v =[9, 3, 8, 1]T . Calculate the addi- tion u+v and the subtractions u−v and v−u. Appendix A: Linear Algebra 637

Solution A.12 The addition is performed by adding corresponding terms as ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ 5 9 5 + 9 14 ⎢ 6 ⎥ ⎢ 3 ⎥ ⎢ 6 + 3 ⎥ ⎢ 9 ⎥ u + v = ⎢ ⎥ + ⎢ ⎥ = ⎢ ⎥ = ⎢ ⎥ . ⎣ 7 ⎦ ⎣ 8 ⎦ ⎣ 7 + 8 ⎦ ⎣ 15 ⎦ 8 1 8 + 1 9

The subtraction is performed by subtracting corresponding terms as ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ 5 9 5 − 9 −4 ⎢ 6 ⎥ ⎢ 3 ⎥ ⎢ 6 − 3 ⎥ ⎢ 3 ⎥ u − v = ⎢ ⎥ − ⎢ ⎥ = ⎢ ⎥ = ⎢ ⎥ . ⎣ 7 ⎦ ⎣ 8 ⎦ ⎣ 7 − 8 ⎦ ⎣ −1 ⎦ 8 1 8 − 1 7 ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ 9 5 9 − 5 4 ⎢ 3 ⎥ ⎢ 6 ⎥ ⎢ 3 − 6 ⎥ ⎢ −3 ⎥ v − u = ⎢ ⎥ − ⎢ ⎥ = ⎢ ⎥ = ⎢ ⎥ . ⎣ 8 ⎦ ⎣ 7 ⎦ ⎣ 8 − 7 ⎦ ⎣ 1 ⎦ 1 8 1 − 8 −7

Notice that u − v =−[v − u]. 

A.4.3 Multiplication

There are different types of multiplication operations that can be applied to vectors.

A.4.3.1 Scalar Multiplication

Scalar multiplication or vector scaling is an operation performed by multiplying each of the elements of a vector by a scalar value. Thus, for an nD vector v and a scalar value s, we can write ⎡ ⎤ ⎡ ⎤ v1 sv1 ⎢ ⎥ ⎢ ⎥ ⎢ v2 ⎥ ⎢ sv2 ⎥ sv = s ⎢ . ⎥ = ⎢ . ⎥ . (A.18) ⎣ . ⎦ ⎣ . ⎦ vn svn

Note that if the scalar s is positive, the vector sv is in the same direction as the vector v; however, its length is s times the length of v. On the other hand, if the scalar s is negative, the vector sv is in the opposite direction with respect to the vector v and its length is s times the length of v. (This implies that the vectors −v and v in opposite directions with respect to each other although they have the same length; i.e., v=−v.) 638 Appendix A: Linear Algebra

Vector scaling and addition can be used with unit Cartesian vectors to define the position vector of any 3D point P˙ =[x, y, z]T as

P˙ = xi + yj + zk, (A.19) where i =[1, 0, 0]T , j =[0, 1, 0]T and k =[0, 0, 1]T are the unit vectors along the x-, y- and z-axes (i.e., unit Cartesian vectors) respectively.

Example A.13 [Vectors–scalar multiplication] Consider the vector u =[5, 6, 7, 8]T . Get the result of su where s = 2.5.

Solution A.13 The scalar value is multiplied by each vector term individually. Thus, ⎡ ⎤ ⎡ ⎤ 5 12.5 ⎢ 6 ⎥ ⎢ 15 ⎥ su = 2.5 ⎢ ⎥ = ⎢ ⎥ . ⎣ 7 ⎦ ⎣ 17.5 ⎦ 8 20  Example A.14 [Vectors–scalar multiplication and addition/subtraction] Consider two vectors u =[5, 6, 7, 8]T and v =[9, 3, 8, 1]T . Calculate 2u+3v and 3u−2v.

Solution A.14 The operations are performed as ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ 5 9 10 27 10 + 27 37 ⎢ 6 ⎥ ⎢ 3 ⎥ ⎢ 12 ⎥ ⎢ 9 ⎥ ⎢ 12 + 9 ⎥ ⎢ 21 ⎥ 2u + 3v = 2 ⎢ ⎥ + 3 ⎢ ⎥ = ⎢ ⎥ + ⎢ ⎥ = ⎢ ⎥ = ⎢ ⎥ ⎣ 7 ⎦ ⎣ 8 ⎦ ⎣ 14 ⎦ ⎣ 24 ⎦ ⎣ 14 + 24 ⎦ ⎣ 38 ⎦ 8 1 16 3 16 + 3 19 and ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ 5 9 15 18 15 − 18 −3 ⎢ 6 ⎥ ⎢ 3 ⎥ ⎢ 18 ⎥ ⎢ 6 ⎥ ⎢ 18 − 6 ⎥ ⎢ 12 ⎥ 3u − 2v = 3 ⎢ ⎥ − 2 ⎢ ⎥ = ⎢ ⎥ − ⎢ ⎥ = ⎢ ⎥ = ⎢ ⎥ . ⎣ 7 ⎦ ⎣ 8 ⎦ ⎣ 21 ⎦ ⎣ 16 ⎦ ⎣ 21 − 16 ⎦ ⎣ 5 ⎦ 8 1 24 2 24 − 2 22 

A.4.3.2 Dot Product

The dot product or scalar product is an operation performed on two vectors of the same dimension. The symbol ‘·’ is used to denote this operation. It results in a single scalar value. The dot product may be calculated as the sum of the component- wise products of the vectors. Thus, if the two vectors are u =[u1, u2, u3] and v =[v1, v2, v3], the dot product is computed as

u · v = u1v1 + u2v2 + u3v3. (A.20) Appendix A: Linear Algebra 639

Fig. A.1 The dot product of two vectors can be used to compute the projection of one vector onto the other

√ Note that the u= u · u. Alternatively, the dot product can be computed as the product of of the two vectors times the cosine of the between them. In other words, u · v =uv cos(θ), (A.21) where θ is the angle between the two vectors. Notice that if the two vectors u and v are parallel (i.e., θ = 0◦ or θ = 180◦), the dot product will be the product of their lengths with the saying whether they are oriented in the same or opposite directions since cos(0) = 1 and cos(180) =−1. If vectors are orthogonal (i.e., θ = 90◦), the dot product will be 0 since cos(90) = 0. If the angle between the vectors is acute, then the dot product will be positive, no matter what orientations of the vectors are, because the cosine of any angle between −90◦ and 90◦ is positive. On the other hand, if the angle between them is obtuse, then the dot product will be negative. Also, Eq. (A.21) implies that the angle between two vectors can be computed if the norms and the dot product are known. It can be estimated as   − u · v θ = cos 1 . (A.22) uv

Moreover, Eq. (A.21) lets us compute the projection of one vector onto the other. Consider Fig. A.1, which shows two vectors u and v. Construct a right in which one side is the vector u. It is obvious that the projection of u onto v equals to u cos(θ). This can be written as u · v |proj u|=u cos(θ) = . (A.23) v v

Example A.15 [Dot product and vector norm] T 2 Given a vector u =[u1, u2, u3] , show that u · u =u . 640 Appendix A: Linear Algebra

Solution A.15

· = + + = 2 + 2 + 2 = 2.  u u u1u1 u2u2 u3u3 u1 u2 u3 u Example A.16 [Dot product–orthogonal vectors] If the vectors u =[−3, 3s, 10]T and v =[2s, 5, 1.8]T are orthogonal, estimate the value of s.

Solution A.16 Since the dot product of two orthogonal vectors is 0, then

u · v = 0 −3 × 2s + 3s × 5 + 10 × 1.8 = 0 9s =−18.

Hence, s =−2. 

Example A.17 [Dot product–vector projection] Suppose that two vectors u and v are emitted from the [0, 0, 0]T to the points [2, −4, 0]T and [5, −3, 0]T respectively. Using the dot product, determine the length of the projection of u onto v.

Solution A.17 We can follow these steps: 1. Calculate the dot product using Eq. (A.20)as

u · v = 2 × 5 + (−4) × (−3) + 0 × 0 = 22.

2. Get the norm of the second vector using Eq. (A.14)as  √ v= 52 + (−3)2 + 02 = 34 = 5.8310.

3. Get the projection of u unto v using Eq. (A.23). Thus, we have u · v |proj u|= = 3.7730.  v v

Example A.18 [Dot product–vector projection] Consider the column vectors a =[2, 2, 1]T , b =[5, 4, 2]T . Calculate the pro- jection of a unto b. Appendix A: Linear Algebra 641

Solution A.18 We follow the same steps as in Example A.17: 1. Calculate the dot product using Eq. (A.20)as

a · b = 2 × 5 + 2 × 4 + 1 × 2 = 20.

2. Get the norm of vector b using Eq. (A.14)as  √ b= 52 + 42 + 22 = 3 5 = 6.7082.

3. Get the projection of a unto b using Eq. (A.23). Thus, we have

a · b |proj a|= = 2.9814.  b b

Example A.19 [Dot product–angle between vectors] In Example A.18, calculate the angle between the vectors a and b. Solution A.19 The norm of vector a is calculated as  a= 22 + 22 + 12 = 3.

Using the values of a · b and b from Example A.18, the angle between the vectors can be calculated using Eq. (A.22)as     − a · b − 20 ◦ θ = cos 1 = cos 1 √ = 6.3794 .  ab 9 5 Example A.20 [Vectors–normalization and dot product] Consider two vectors u =[1, 2, 5]T and v =[7, 8, 6]T . Normalize them. Calcu- late the angle between the normalized vectors and the projection of u onto v after normalization. Solution A.20 Using Eq. (A.14), the norms of the vectors are  √ u= 12 + 22 + 52 = 30 = 5.4772 and  √ v= 72 + 82 + 62 = 149 = 12.2066.

Using Eq. (A.15), the normalized vectors are ⎡ ⎤ 1 ⎡ ⎤ √ . u ⎢ 30 ⎥ 0 1826 uˆ = = ⎣ √2 ⎦ = ⎣ 0.3651 ⎦ u 30 √5 0.9129 30 642 Appendix A: Linear Algebra

Fig. A.2 The cross product of two vectors results in a third vector to their

and ⎡ ⎤ 7 ⎡ ⎤ √ . v ⎢ 149 ⎥ 0 5735 vˆ = = ⎣ √8 ⎦ = ⎣ 0.6554 ⎦ . v 149 √6 0.4915 149

Calculate the dot product of the unit vectors using Eq. (A.20)as

1 7 2 8 5 6 53 uˆ · vˆ = √ × √ + √ × √ + √ × √ = √ = 0.7927. 30 149 30 149 30 149 4470

The angle between the vectors can be calculated using Eq. (A.22)as     − − 53 ◦ θ = cos 1 uˆ · vˆ = cos 1 √ = 37.5592 . 4470

Finally, the projection of uˆ onto vˆ is calculated using Eq. (A.23)as

| ˆ|=ˆ · ˆ = . .  projvˆ u u v 0 7927

A.4.3.3 Cross Product of 3D Vectors

The cross product or vector product is an operation performed on two 3D vectors. The symbol ‘×’ is used to denote this operation. It results in another 3D vector that is perpendicular to both vectors (i.e., normal/orthogonal to their plane) as shown in Fig. A.2. Notice that there are two directions for two normals depending on the order of multiplication. To get the correct direction in a right-handed (Sect. B.1.1), curl the fingers of your right hand from the first vector to the second, your right thumb will point in the direction of the cross product. Thus, given the vectors u =[u1, u2, u3] and v =[v1, v2, v3], the following cross products are equivalent: u × v =−u ×−v =−v × u = v ×−u. Appendix A: Linear Algebra 643

Similarly, the following cross products are equivalent:

v × u =−v ×−u =−u × v = u ×−v.

In order to calculate the cross product u × v, assume that the unit vectors along the x-, y- and z-axes are i =[1, 0, 0]T , j =[0, 1, 0]T and k =[0, 0, 1]T , then the cross product can be calculated as ⎡ ⎤ ijk ⎣ ⎦ u × v = det u1 u2 u3 v1 v2 v3

u2 u3 u1 u3 u1 u2 = i − j + k (A.24) v2 v3 v1 v3 v1 v2 ⎡ ⎤ u2v3 − v2u3 ⎣ ⎦ = v1u3 − u1v3 . u1v2 − v1u2

The same cross product can be obtained through matrix multiplication by con- structing an anti-symmetric matrix [u]× from the first vector u and multiplying it by the second v as ⎡ ⎤ ⎡ ⎤ 0 −u3 u2 v1 ⎣ ⎦ ⎣ ⎦ u × v = u3 0 −u1 v2 −u u 0 v  2 1   3  (A.25) ⎡ [u]× ⎤ v u2v3 − v2u3 ⎣ ⎦ = v1u3 − u1v3 . u1v2 − v1u2

Considering two 3D vectors u and v, the length of the resulting vector u × v is the product of the two vector lengths times the of the angle between them. This can be written as

u × v=uv sin(θ), (A.26) where θ is the angle between the two vectors. Notice that if the two vectors u and v are parallel (i.e., θ = 0◦ or θ = 180◦), the length of their cross product will be 0 since sin(0) = sin(180) = 0. This implies that u ×v = 0 =[0, 0, 0]T where 0 is the null vector or zero vector. If they are orthogonal (i.e., θ = 90◦), their cross product will have a length equal to the product of the two lengths (i.e., u × v=uv) since sin(90) = 1. If u and v are both unit vectors, the length of their cross product is the sine of the enclosed angle (i.e., u × v=sin(θ)). 644 Appendix A: Linear Algebra

Fig. A.3 A pyramid with a normal vector u × v perpendicular to the face A˙ B˙ D˙

The cross product may be used to obtain the of a triangle. Given a triangle A˙ B˙ C˙ , its area A is calculated as

1   A = [B˙ − A˙ ]×[C˙ − A˙ ] . (A.27) 2 Example A.21 [Cross product–normal vector to a plane] Consider a pyramid whose vertices are A˙ =[2, 2, 1]T , B˙ =[5, 4, 1]T , C˙ = [3, 7, 1]T and D˙ =[3, 3, 5]T . What is the normal to the face A˙ B˙ D˙ ?

Solution A.21 Figure A.3 illustrates the problem. We start by obtaining the direction vectors emitting from A˙ as ˙ ˙ u = B⎡ −⎤A ⎡ ⎤ ⎡ ⎤ 5 2 3 = ⎣ 4 ⎦ − ⎣ 2 ⎦ = ⎣ 2 ⎦ 1 1 0 and ˙ ˙ v = D⎡ −⎤A ⎡ ⎤ ⎡ ⎤ 3 2 1 = ⎣ 3 ⎦ − ⎣ 2 ⎦ = ⎣ 1 ⎦ . 5 1 4

The normal to the face A˙ B˙ D˙ is the cross product u × v, which can be calculated using Eq. (A.24)as Appendix A: Linear Algebra 645 ⎡ ⎤ ijk ⎣ ⎦ u × v = det u1 u2 u3 v1 v2 v3

u2 u3 u1 u3 u1 u2 = i − j + k v2 v3 v1 v3 v1 v2 ⎡ ⎤ u2v3 − v2u3 ⎣ ⎦ = v1u3 − u1v3 u1v2 − v1u2 ⎡ ⎤ ⎡ ⎤ 2 × 4 − 1 × 0 8 = ⎣ 1 × 0 − 3 × 4 ⎦ = ⎣ −12 ⎦ . 3 × 1 − 1 × 2 1

The same vector can be calculated using Eq. (A.25)as ⎡ ⎤ ⎡ ⎤ 0 −u3 u2 v1 ⎣ ⎦ ⎣ ⎦ u × v = u3 0 −u1 v2 −u u 0 v  2 1   3  ⎡ [u]× ⎤ v u2v3 − v2u3 ⎣ ⎦ = v1u3 − u1v3 u1v2 − v1u2 ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ 002 1 8 ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ = 00−3 1 = −12 .  −23 0 4 1

Example A.22 [Cross product–equation of a plane] Building on Example A.21, estimate the plane equation of the face A˙ B˙ D˙ .

Solution A.22 The general equation of a plane is

ax + by + cz = d, where [a, b, c]T is the normal to the plane; and d is the perpendicular from the origin to the plane when the normal vector [a, b, c]T is normalized. According to Example A.21, the normal to the plane is [8, −12, 1]T . Substituting the values of a, b and c, we get 8x − 12y + z = d.

Since point A˙ =[2, 2, 1]T is on the plane, d is estimated as

d = 8 × 2 − 12 × 2 + 1 × 1 =−7. 646 Appendix A: Linear Algebra

Hence, the equation of the plane is expressed as

8x − 12y + z + 7 = 0. 

A.4.3.4 Cross Product of 2D Vectors

Although less frequently used, we sometimes need to calculate the cross product of two 2D vectors u =[u1, u2] and v =[v1, v2]. In this case, these vectors lie on a single plane (e.g., xy-plane); thus, we can write them as u =[u1, u2, 0] and v =[v1, v2, 0]. By applying Eq. (A.24), we may have ⎡ ⎤ ijk ⎣ ⎦ u × v = det u1 u2 0 v1 v2 0

u2 0 u1 0 u1 u2 = i − j + k (A.28) v2 0 v1 0 v1 v2 ⎡ ⎤ 0 = ⎣ 0 ⎦ . u1v2 − v1u2

Thus, in order to obtain the cross product of two 2D vectors, calculate the determinant

u1 u2 u1 v1 of the 2 × 2 matrix composed of the two vectors. Note that = = v1 v2 u2 v2 u1v2 − u2v1.

A.5 Problems

Problem A.1 [Matrices–determinant] Compute the determinant for the following matrix: ⎡ ⎤ 345 A = ⎣ 167⎦ . 189

Problem A.2 [Matrices–inverse] Compute the inverse for matrix A that is defined in Problem A.1.

Problem A.3 [Matrices–addition and subtraction] Consider the matrices A and B where Appendix A: Linear Algebra 647 ⎡ ⎤ 345 A = ⎣ 167⎦ 189 and ⎡ ⎤ 140 B = ⎣ 160⎦ . 184

Calculate A+B, A−B and B−A.

Problem A.4 [Matrices–multiplication] Consider matrices A and B of Problem A.3. Determine whether or not AB=BA.

Problem A.5 [Matrices–multiplication] Assume that a matrix B is defined to be ⎡ ⎤ 14 B = ⎣ 16⎦ . 18

If matrix A keeps all its elements as in Problem A.3, calculate AB and BA.Ifthe multiplications cannot be performed, mention the reason.

Problem A.6 [Vectors–vector normalization] Normalize the vector v =[7, 3, 6].

Problem A.7 [Vectors–angle between vectors] Suppose that two 3D segments are extended from [1, 5, 0]T to [2, 3, 0]T to [4, 4, 0]T . What is the angle between them at [2, 3, 0]T ?

Problem A.8 [Vectors–angle between vectors] Suppose that two 3D line segments are extended from [1, 5, 0]T to [2, 3, 0]T to [4, 4, 0]T . Without calculating its value, determine whether the angle between them is acute or obtuse.

Problem A.9 [Vectors–orthogonal vectors] Suppose that two 3D line segments are extended from [0, 0, 0]T to [3, 3, 0]T and from [2, 2, 0]T to [2, 2, 4]T . Show that their direction vectors are orthogonal.

Problem A.10 [Vectors–dot and cross products] Consider two parallel vectors each of length 3.5. Determine their dot product. Also, determine the of their cross product.

Problem A.11 [Vectors–dot and cross products] Consider two orthogonal vectors each of length 3.5. Determine their dot product. Also, determine the magnitude of their cross product. 648 Appendix A: Linear Algebra

Problem A.12 [Vectors–vector projection] Suppose that two vectors u and v are emitted from the origin [0, 0, 0]T to the points [2, −4, 0]T and [5, −3, 0]T respectively. Using the dot product, determine the length of the projection of u onto v.

Problem A.13 [Vectors–plane normal vectors] Consider the tetrahedron whose vertices are located at [1, 1, 1]T , [0, 1, 1]T , [0, 0, 1]T and [0, 0, 0]T . What are the normals to the four that bound the tetrahedron where each normal is pointing to the outside?

Problem A.14 [Vectors–plane equations] Consider the tetrahedron whose vertices are located at [1, 1, 1]T , [0, 1, 1]T , [0, 0, 1]T and [0, 0, 0]T . Determine the plane equation for each of its faces. Appendix B Coordinate Systems

There are many coordinate systems that appear in computer graphics literature. These systems include the most usable Cartesian coordinate system both in 2D and 3D spaces with its perpendicular axes. Other coordinate systems include parametric and barycentric that are usually used with triangles. Coordinates do not have to be represented by straight axes. On the contrary, may be used to represent separate coordinates as in polar, cylindrical and spherical coordinates. Homogeneous coordinates are very important in computer graphics to facilitate operations like transformations. This appendix gives a short description for each of those coordinate systems, which are important for the reader of this book to know. In addition to the descrip- tions of the coordinate systems, we will discuss how to convert from the Cartesian coordinates to each of these systems and vice versa. Skilled readers may skip this appendix.

B.1 Cartesian Coordinate Systems

A Cartesian coordinate system may be specified in 2D space or in 3D space. In 2D space, the system is split into four quadrants by two axes (i.e., the x- and y-axes). Points are represented by two real numbers (e.g., p˙ =[x, y]T ); each representing the distance from the origin to that point along the x- and y-axes as shown in Fig. B.1a. This can be written as    x 1 0 = x + y , (B.1) y 0 1    p˙ i j

R. Elias, Digital Media, DOI: 10.1007/978-3-319-05137-6, 649 © Springer International Publishing Switzerland 2014 650 Appendix B: Coordinate Systems

Fig. B.1 Right-handed coordinate systems. a 2D Cartesian coordinate system showing a point p˙ specified as [x, y]T . b 3D Cartesian coordinate system showing a point P˙ specified as [x, y, z]T where i =[1, 0]T and j =[0, 1]T are the unit vectors along the x- and y-axes respectively. Each of the four quadrants contains points with the same algebraic signs in each component. In 3D space, the system is split into eight octants by three axes (i.e., the x-, y- and z-axes). Points are represented by three real numbers (e.g., P˙ =[x, y, z]T ); each representing the distance from the origin to that point along the x-, y- and z-axes as shown in Fig. B.1b. As done in Eq. (B.1), this can be written as ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ x 1 0 0 ⎣ y ⎦ = x ⎣ 0 ⎦ + y ⎣ 1 ⎦ + z ⎣ 0 ⎦, (B.2) z 0 0 1             P˙ i j k where i =[1, 0, 0]T , j =[0, 1, 0]T and k =[0, 0, 1]T are the unit vectors along the x-, y- and z-axes respectively. Each of the eight octants contains points with the same algebraic signs in each component.

B.1.1 Right-Versus Left-Handed Coordinate Systems

A coordinate system may be either right-handed or left-handed (Vince 2008).

B.1.1.1 Right-Handed Coordinate Systems

In 2D right-handed system, the x-axis coincides with the y-axis if it rotates through an angle of 90◦ about the origin in a counter-clockwise direction as in Fig. B.1a. In 3D right-handed system, if you hold your right hand in space with your fingers along the x-axis and curl your fingers towards the y-axis, your thumb will point in Appendix B: Coordinate Systems 651

Fig. B.2 Left-handed coordi- nate systems. a 2D Cartesian coordinate system showing a point p˙ specified as [x, y]T . b 3D Cartesian coordinate system showing a point P˙ specified as [x, y, z]T

the z-axis direction, which is perpendicular to both the x- and y-axes. Figure B.1b illustrates the 3D right-handed coordinate systems.

B.1.1.2 Left-Handed Coordinate Systems

The above concepts hold for the left-handed coordinate systems. In 2D left-handed system, the x-axis coincides with the y-axis if it rotates through an angle of 90◦ about theorigininaclockwise direction as shown in Fig. B.2a. In 3D left-handed system, if you hold your left hand in space with your fingers along the x-axis and curl your fingers towards the y-axis, your thumb will point in the z-axis direction, which is perpendicular to both the x- and y-axes as illustrated in Fig. B.2b.

B.1.1.3 Right-/Left-Handed Coordinate Systems Transformations

Switching between right- and left-handed coordinate systems in 2D space is per- formed by switching signs along the y-coordinates to get

x = x , l r (B.3) yl =−yr ,

T where [xl , yl ] is a 2D point expressed in 2D left-handed coordinate system and T [xr , yr ] is the same 2D point expressed in 2D right-handed coordinate system. This relationship can be expressed in matrix form as    x 10 x l = r . (B.4) yl 0 −1 yr

Note that turning between right- and left-handed coordinate systems in 2D space is equivalent to reflecting about the x-axis. (More discussion about 2D reflection can be found in Chap. 3.) 652 Appendix B: Coordinate Systems

The same idea is extended to 3D space. Thus, transformation between right- and left-handed coordinate systems in 3D space is performed by switching signs along the z-coordinates to get xl = xr , yl = yr , (B.5) zl =−zr ,

T where [xl , yl , zl ] is a 3D point expressed in 3D left-handed coordinate system and T [xr , yr , zr ] is the same 3D point expressed in 3D right-handed coordinate system. This relationship can be expressed in matrix form as ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ xl 10 0 xr ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ yl = 01 0 yr . (B.6) zl 00−1 zr

Similar to the 2D version of the transformation, switching between right- and left- handed coordinate systems in 3D space is equivalent to reflecting about the xy-plane. (More discussion about 3D reflection can be found in Chap. 5.)

B.1.1.4 Images and Coordinate Systems

The 2D left-handed coordinate system is usually used with raster images. In this case, the origin is located at the upper left corner of the image and the y-axis is pointing downwards. Converting between these systems is done using the following formula:   x x r = l , (B.7) yr ymax − yl

T T where [xl , yl ] is a pixel expressed in 2D left-handed coordinate system; [xr , yr ] is the same pixel expressed in 2D right-handed coordinate system; and ymax is the height of the image in pixels.

B.1.2

T T The distance d(p˙ 1, p˙ 2) between two 2D points p˙ 1 =[x1, y1] and p˙ 2 =[x2, y2] is given by  2 2 d(p˙ 1, p˙ 2) = (x2 − x1) + (y2 − y1) . (B.8)

˙ ˙ ˙ T Similarly, the distance d(P1, P2) between two 3D points P1 =[x1, y1, z1] and ˙ T P2 =[x2, y2, z2] is given by Appendix B: Coordinate Systems 653  ˙ ˙ 2 2 2 d(P1, P2) = (x2 − x1) + (y2 − y1) + (z2 − z1) . (B.9)

˙ ˙ d(p˙ 1, p˙ 2) and d(P1, P2) are referred to as Euclidean distances in 2D and 3D spaces respectively. Note that the between two vectors v1 and v2 represents the norm of the direction vector v2 − v1 and it is denoted as v2 − v1. More is discussed in Sect. A.4.1.

Example B.1 [Euclidean distance–2D points] T T Determine the Euclidean distance between points p˙ 1 =[4, 7] and p˙ 2 =[7, 8] .

Solution B.1 Equation (B.8) is used to get the distance from p˙ 1 to p˙ 2 as  2 2 d(p˙ 1, p˙ 2) = (x2 − x1) + (y2 − y1) = ( − )2 + ( − )2 √ 7 4 8 7  = 10.

Example B.2 [Euclidean distance–3D points] ˙ T ˙ Determine the Euclidean distance between points P1 =[4, 7, 6] and P2 = [7, 8, 3]T . ˙ ˙ Solution B.2 Equation (B.9) is used to get the distance from P1 to P2 as  ˙ ˙ 2 2 2 d(P1, P2) = (x2 − x1) + (y2 − y1) + (z2 − z1) = √(7 − 4)2 + (8 − 7)2 + (3 − 6)2 = 19. 

B.2 Parametric Coordinate System

Parametric coordinates can be regarded as a generalization of Cartesian coordinates. In a parametric coordinates system, axes do not have to be orthogonal to each other as shown in Fig. B.3. In 2D space, points are represented by two real numbers (e.g., p˙ =[u, v]T ); each representing the distance from the origin [0, 0]T to that point along the u- and v-axes. In other words, you start at the origin and walk u distance along u then walk v distance in the direction v. This can be written as    u 1 0 = u + v , (B.10) v 0 1    p˙ u v where u =[1, 0]T and v =[0, 1]T are unit vectors along the u- and v-axes respectively. 654 Appendix B: Coordinate Systems

Fig. B.3 Parametric coordinates

B.2.1 Cartesian-Parametric Transformation

A point [x, y]T in Cartesian coordinates can be expressed in parametric coordinates [u, v]T as u = b˙ − a˙, v = c˙ − a˙, w = p˙ − a˙, ⎡ ⎤ (B.11)  (u · v)(w · v) − (v · v)(w · u) u ⎢ ( · )2 − ( · )( · ) ⎥ = ⎣ u v u u v v ⎦ , v (u · v)(w · u) − (u · u)(w · v) (u · v)2 − (u · u)(v · v) where a˙, b˙, c˙ and p˙ are expressed in Cartesian coordinates; · indicates the dot product; and u and v are the parametric coordinates of the point.

Example B.3 [Cartesian-parametric transformation] Consider a triangle a˙b˙c˙ where a˙ =[1, 1]T , b˙ =[10, 2]T and c˙ =[6, 5]T .Also, consider a point p˙ =[7, 3]T inside the triangle. Express p˙ in parametric coordinates if the u- and v-axes go along a˙b˙ and a˙c˙ respectively.

Solution B.3 To do this conversion, Eq. (B.11) is used. Thus, ˙ u = b − a ˙   = 10 − 1 = 9 , 2 1 1

v = c˙ − a˙    = 6 − 1 = 5 , 5 1 4 Appendix B: Coordinate Systems 655

w = p˙ − a˙    = 7 − 1 = 6 . 3 1 2

Hence, ⎡ ⎤  (u · v)(w · v) − (v · v)(w · u) u ⎢ ( · )2 − ( · )( · ) ⎥ = ⎣ u v u u v v ⎦ v (u · v)(w · u) − (u · u)(w · v) (u · v)2 − (u · u)(v · v) ⎡       ⎤ 9 5 6 5 5 5 6 9 ⎢ · · − · · ⎥ ⎢ 1 4 2 4 4 4 2 1 ⎥ ⎢      ⎥ ⎢ 9 5 2 9 9 5 5 ⎥ ⎢ · − · · ⎥ ⎢ ⎥ = ⎢  1  4 1  1 4  4  ⎥ ⎢ 9 5 6 9 9 9 6 5 ⎥ ⎢ · · − · · ⎥ ⎢ 1 4 2 1 1 1 2 4 ⎥ ⎢      ⎥ ⎣ 2 ⎦ 9 · 5 − 9 · 9 5 · 5 1 4 1 1 4 4  . = 0 4516 . 0.3871 

B.2.2 Parametric-Cartesian Transformation

A point [u, v]T in parametric coordinates can be expressed in Cartesian coordinates [x, y]T as  x = a˙ + u[b˙ − a˙]+v[c˙ − a˙], (B.12) y where a˙, b˙ and c˙ are expressed in Cartesian coordinates; u and v are the parametric coordinates; and x and y are the Cartesian coordinates of the point.

Example B.4 [Parametric-Cartesian transformation] Consider a triangle a˙b˙c˙ where a˙ =[1, 1]T , b˙ =[10, 2]T and c˙ =[6, 5]T . If a parametric coordinate system is defined such that the u- and v-axes go along a˙b˙ and a˙c˙ respectively, express the parametric point [0.4516, 0.3871]T in Cartesian coordinates.

Solution B.4 This transformation is performed using Eq. (B.12). Thus, 656 Appendix B: Coordinate Systems  x = a˙ + u[b˙ − a˙]+v[c˙ − a˙] y      1 10 1 6 1 = + 0.4516 − + 0.3871 − 1 2 1 5 1  = 7 , 3 which is the same point of Example B.3. 

B.3 Barycentric Coordinate System

[ , , ]T Barycentric coordinates are triplets of numbers ta˙ tb˙ tc˙ corresponding to masses placed at the vertices a˙, b˙ and c˙ of a triangle a˙b˙c˙. A point inside the triangle can be treated as the geometric centroid of the three masses (Vince 2010). This point is [ , , ]T identified with coordinates ta˙ tb˙ tc˙ . Figure B.4 shows a point p˙ that lies inside the triangle a˙b˙c˙. The barycentric ˙ [ , , ]T coordinates of p are represented as a triplet ta˙ tb˙ tc˙ where ta˙ , tb˙ and tc˙ are pro- portional to the three of the sub-triangles created by point p˙ and the vertices a˙, b˙ and c˙ respectively.

B.3.1 Cartesian-Barycentric Transformation

[ , , ]T ˙ ˙ ˙ ˙ The barycentric coordinates ta˙ tb˙ tc˙ of point p that lies inside the triangle abc (Fig. B.4) can be expressed as ⎡ ⎤ ⎡ ⎤ t˙ A˙ a 1 a ⎣ t˙ ⎦ = ⎣ A ˙ ⎦ , (B.13) b A b tc˙ Ac˙

˙ where Aa˙ is the area of the sub-triangle p˙bc˙; A ˙ is the area of the sub-triangle ˙ b p˙c˙a˙; Ac˙ is the area of the sub-triangle p˙a˙b; and A is the area of the triangle ˙ ˙ ˙ + + + + = abc, which is equal to Aa˙ Ab˙ Ac˙. Note that ta˙ tb˙ tc˙ 1. Example B.5 [Cartesian-barycentric transformation] Consider a triangle a˙b˙c˙ where a˙ =[1, 1]T , b˙ =[10, 2]T and c˙ =[6, 5]T .Also, consider a point p˙ =[7, 3]T inside the triangle. Express p˙ in barycentric coordinates.

˙ Solution B.5 Let us assume that Aa˙ represents the area of the triangle p˙bc˙, ˙ ˙ ˙ Ab˙ represents the area of the triangle pca, Ac˙ represents the area of the tri- angle p˙a˙b˙ and A represents the whole area of the triangle a˙b˙c˙. Many equa- tions may be used to obtain the area of a triangle. Equation (A.27) can be utilized. Appendix B: Coordinate Systems 657

Fig. B.4 Barycentric coordi- nates. The barycentric values ta˙ , tb˙ and tc˙ are proportional to the three areas Aa˙ , Ab˙ and Ac˙ of the sub-triangles created by point p˙ and the vertices a˙, b˙ and c˙

Thus,   A = 1 [b˙ − a˙]×[c˙ − a˙] 2        = 1  10 − 1 × 6 − 1  . 2  2 1 5 1 

Notice that the cross product of 2D vectors is the determinant as discussed in Sect. A.4.3.4 and the norm of a scalar value is its . Thus,

1 95 A = = 15.5. 2 14

Similarly, we have   1  ˙  Aa˙ = [b − p˙]×[c˙ − p˙] 2        = 1  10 − 7 × 6 − 7   2 3 5 3  2

1 3 −1 = = 2.5, 2 −12

= 1 [˙ − ˙]×[˙ − ˙] Ab˙ c p a p 2        = 1  6 − 7 × 1 − 7   5 3 1 3  2

1 −1 −6 = = 7 2 2 −2 658 Appendix B: Coordinate Systems and   1  ˙  A˙ = [a˙ − p˙]×[b − p˙] c 2        = 1  1 − 7 × 10 − 7   1 3 2 3  2

1 −63 = = 6. 2 −2 −1 + + = Notice that Aa˙ Ab˙ Ac˙ A. The barycentric coordinates can be expressed using Eq. (B.13)as ⎡ ⎤ ⎡ ⎤ t˙ A˙ a 1 a ⎣ t˙ ⎦ = ⎣ A ˙ ⎦ b A b t˙ A˙ c ⎡c ⎤ ⎡ ⎤ 2.5 0.1613 1 = ⎣ 7 ⎦ = ⎣ 0.4516 ⎦ . .  15 5 6 0.3871

Example B.6 [Cartesian-barycentric transformation] If the area of the triangle a˙b˙c˙ is obtained as

1     A =  b˙ − a˙ × c˙ − a˙  2 and a point p˙ inside this triangle is expressed in Cartesian coordinates, write down a single equation to express p˙ in barycentric coordinates given the Cartesian points a˙, b˙, c˙ and p˙.

Solution B.6 The total area of the triangle can be written as

1        A =  b˙ − a˙ × c˙ − a˙  = 1 b˙ − a˙ c˙ − a˙ , 2 2     where |.| denotes the determinant of the 2× 2matrix b˙ − a˙ | c˙ − a˙ . Similarly, we can write    = 1 ˙ − ˙ ˙ − ˙ , Aa˙ 2 b p c p   

˙ = 1 ˙ − ˙ ˙ − ˙ , Ab 2 c p a p    = 1 ˙ − ˙ ˙ − ˙ . Ac˙ 2 a p b p Appendix B: Coordinate Systems 659

Fig. B.5 Barycentric coordinates

By substituting in Eq. (B.13), we get ⎡ ⎤ ⎡ ⎤ ta˙ Aa˙ ⎣ ˙ ⎦ = 1 ⎣ ˙ ⎦ tb A Ab t˙ A˙ c c ⎡    ⎤ (B.14) b˙ − p˙ c˙ − p˙ 1    =   ⎣ c˙ − p˙ a˙ − p˙ ⎦ . ˙ − ˙ ˙ − ˙     b a [c a] a˙ − p˙ b˙ − p˙

B.3.2 Barycentric-Cartesian Transformation

Consider Fig. B.5 where a point p˙ lies inside a triangle a˙b˙c˙. If you draw a line ˙ from a˙ to p˙ and extend it to q˙ that lies on bc˙, ta˙ will represent the distance p˙ − q˙ ˙ − ˙ ˙ − ˙ ˙ − ˙ while tb˙ + tc˙ will represent the distance p a (i.e., p q + p a = 1 in terms of barycentric coordinates). At the same time, t˙ will represent the distance c˙ − q˙ ˙ b while tc˙ will represent the distance b − q˙. Utilizing the above relations, the Cartesian coordinates of point q˙ can be obtained ˙ ˙ using linear interpolation if b, c, tb˙ and tc˙ are known. So,

t˙ t˙ q˙ = b b˙ + c c˙, + + (B.15) tb˙ tc˙ tb˙ tc˙

˙ ˙ ˙ where q, b and c are represented in Cartesian coordinates; and ta˙ , tb˙ and tc˙ are scalars representing the barycentric coordinates. Consequently, the Cartesian coordinates [ , ]T ˙ ˙ ˙ x y of point p can be obtained as a, q, ta˙ , tb˙ and tc˙ are known. This can be written as 660 Appendix B: Coordinate Systems

˙ = ˙ + ( + ) ˙. p ta˙ a tb˙ tc˙ q

Substituting the location of q˙ from Eq. (B.15), we get  x ˙ = t˙ a˙ + t˙ b + t˙ c˙, (B.16) y a b c

˙ ˙ ˙ [ , , ]T where a, b and c are the Cartesian coordinates of the triangle vertices; ta˙ tb˙ tc˙ are the barycentric coordinates of point p˙ and [x, y]T are the Cartesian coordinates of the same point p˙. Note that the same coordinates must be obtained if you extend b˙p˙ to intersect c˙a˙ or if you extend c˙p˙ to intersect a˙b˙.

Example B.7 [Barycentric-Cartesian transformation] Consider a triangle a˙b˙c˙ where a˙ =[1, 1]T , b˙ =[10, 2]T and c˙ =[6, 5]T .If ˙ [ , , ]T a point p inside the triangle is expressed in barycentric coordinates ta˙ tb˙ tc˙ as [0.1613, 0.4516, 0.3871]T , express the same point in Cartesian coordinates. ˙ ˙ ˙ ˙ Solution B.7 Since a, b, c, ta˙ , tb˙ and tc˙ are known, point p can be expressed in Cartesian coordinates by applying Eq. (B.16)as  x ˙ = ta˙ a˙ + t˙ b + tc˙ c˙ y b    1 10 6 7 = 0.1613 + 0.4516 + 0.3871 = .  1 2 5 3

Example B.8 [Barycentric-parametric transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in barycentric [ , , ]T coordinates as ta˙ tb˙ tc˙ , express the same point in parametric coordinates if the parametric u- and v-axes are along a˙b˙ and a˙c˙ respectively.

Solution B.8 As depicted in Fig. B.6, this problem can be solved in two steps: 1. Transform from barycentric coordinates to Cartesian coordinates. By applying ˙ =[ , , ]T Eq. (B.16), point p ta˙ tb˙ tc˙ is expressed in Cartesian coordinates as  x ˙ p˙ = = t˙ a˙ + t˙ b + t˙ c˙. y a b c

2. Transform from Cartesian coordinates to parametric coordinates. The vector w is obtained as w = p˙ − a˙.

From Step 1, w is expressed as

= ˙ + ˙ + ˙ − ˙ w ta˙ a tb˙ b tc˙ c a = ( − )˙ + ˙ + ˙. ta˙ 1 a tb˙ b tc˙ c Appendix B: Coordinate Systems 661

Fig. B.6 Barycentric to parametric coordinate transformation may be done in two steps by transforming to Cartesian coordinates as a middle step. The same may be applied to the oppo- site transformation. Other transformations may be applied the same way

Hence, to transform from barycentric to parametric coordinates, we substitute the value of w Eq. (B.11). Thus, we have

u = b˙ − a˙ v = c˙ − a˙ = ( − )˙ + ˙ + ˙ w ⎡ta˙ 1 a tb˙ b tc˙ c ⎤ (u · v)(w · v) − (v · v)(w · u)  (B.17) ⎢ ⎥ u ⎢ (u · v)2 − (u · u)(v · v) ⎥ = ⎣ ⎦ . v (u · v)(w · u) − (u · u)(w · v)  (u · v)2 − (u · u)(v · v)

Example B.9 [Barycentric-parametric transformation] Consider a triangle a˙b˙c˙ where a˙ =[1, 1]T , b˙ =[10, 2]T and c˙ =[6, 5]T . Also, consider a barycentric point p˙ =[0.1613, 0.4516, 0.3871]T inside the trian- gle. Express p˙ in parametric coordinates if the u- and v-axes go along a˙b˙ and a˙c˙ respectively.

Solution B.9 To do this conversion, Eq. (B.17) is used. Thus, 662 Appendix B: Coordinate Systems ˙ u = b − a ˙   = 10 − 1 = 9 , 2 1 1

v = c˙ − a˙   = 6 − 1 = 5 , 5 1 4

= ( − )˙ + ˙ + ˙ w ta˙ 1 a tb˙b tc˙ c   1 10 6 = (0.1613 − 1) + 0.4516 + 0.3871  1 2 5 = 6 . 2

Hence, ⎡ ⎤  (u · v)(w · v) − (v · v)(w · u) u ⎢ ( · )2 − ( · )( · ) ⎥ = ⎣ u v u u v v ⎦ v (u · v)(w · u) − (u · u)(w · v) (u · v)2 − (u · u)(v · v) ⎡       ⎤ 9 5 6 5 5 5 6 9 ⎢ · · − · · ⎥ ⎢ 1 4 2 4 4 4 2 1 ⎥ ⎢      ⎥ ⎢ 9 5 2 9 9 5 5 ⎥ ⎢ · − · · ⎥ ⎢ ⎥ = ⎢  1  4 1  1 4  4  ⎥ ⎢ 9 5 6 9 9 9 6 5 ⎥ ⎢ · · − · · ⎥ ⎢ 1 4 2 1 1 1 2 4 ⎥ ⎢      ⎥ ⎣ 2 ⎦ 9 · 5 − 9 · 9 5 · 5 1 4 1 1 4 4  . = 0 4516 .  0.3871

Example B.10 [Parametric-barycentric transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in parametric coordinates as [u, v]T where the parametric u- and v-axes are along a˙b˙ and a˙c˙ [ , , ]T respectively, get its barycentric coordinates ta˙ tb˙ tc˙ . Solution B.10 This problem can be solved in two steps as illustrated in Fig. B.6: 1. Transform from parametric coordinates to Cartesian coordinates. 2. Transform from Cartesian coordinates to barycentric coordinates. The details of the solution are left as an exercise.  Appendix B: Coordinate Systems 663

Fig. B.7 Polar coordinates

B.4

In polar coordinate system, a point is defined by a polar coordinate (or radial coordi- nate) r and a polar angle (or angular coordinate) θ. This is shown in Fig. B.7. Thus, a point p˙ in polar system is defined as [r,θ]T .

B.4.1 Cartesian-Polar Transformation

A point p˙ =[x, y]T in Cartesian system can be expressed in polar coordinates [r,θ]T as    2 + 2 r = x  y , θ −1 y (B.18) tan x where r is the radial coordinate and θ is the angular coordinate. Example B.11 [Cartesian-polar transformation] Express the Cartesian point [3, 4]T in polar coordinates such that the origin of the polar system coincides with the origin of the Cartesian system and the x-axis corresponds to θ = 0◦. Solution B.11 Applying Eq. (B.18), [3, 4]T is expressed in polar coordinates as    2 + 2 r = x  y θ tan−1 y  √ x  2 + 2 = 3  4 = 5 .  −1 4 53.1301◦ tan 3

B.4.2 Polar-Cartesian Transformation

A point p˙ =[r,θ]T in polar system can be expressed in Cartesian coordinates [x, y]T as 664 Appendix B: Coordinate Systems   x r cos(θ) = . (B.19) y r sin(θ)

Example B.12 [Polar-Cartesian transformation] The point [5, 53.1301◦]T is expressed in polar coordinates. Transform this point to Cartesian coordinates such that the origin of the Cartesian system coincides with the origin of the polar system and the x-axis corresponds to θ = 0◦. Solution B.12 Applying Eq. (B.19), we get   (θ) x = r cos y r sin(θ)   ( . ) = 5 cos 53 1301 = 3 .  5sin(53.1301) 4

Example B.13 [Barycentric-polar transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in barycentric [ , , ]T coordinates as ta˙ tb˙ tc˙ , express the same point in polar coordinates if 1. the origin of the Cartesian system expressing the vertices a˙, b˙ and c˙ is the same as the origin of the polar system; and 2. the x-axis of the Cartesian system has an angular coordinate of 0◦. Solution B.13 Similar to Example B.8, this problem can be solved in two steps: 1. Transform from barycentric coordinates to Cartesian coordinates. By applying ˙ =[ , , ]T Eq. (B.16), point p ta˙ tb˙ tc˙ is expressed in Cartesian coordinates as  x ˙ p˙ = = ta˙ a˙ + t˙ b + tc˙ c˙ y  b   = xa˙ + xb˙ + xc˙ . ta˙ tb˙ tc˙ ya˙ yb˙ yc˙

2. Transform from Cartesian coordinates to polar coordinates by substituting the value of [x, y]T obtained from Step 1 in Eq. (B.18). So, ⎡ ⎤ ˙  t˙ a˙ + t˙ b + t˙ c˙ r a b c  = ⎣ t˙ y˙ + t˙ y˙ + t˙ y˙ ⎦ . θ −1 a a b b c c (B.20) tan + + ta˙ xa˙ tb˙ xb˙ tc˙ xc˙ 

Example B.14 [Polar-barycentric transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in polar coordinates as [r,θ]T where 1. the origin of the Cartesian system expressing the vertices a˙, b˙ and c˙ is the same as the origin of the polar system; and Appendix B: Coordinate Systems 665

2. the x-axis of the Cartesian system has an angular coordinate of 0◦,   , , T express the same point in barycentric coordinates ta˙ tb˙ tc˙ . Solution B.14 Also, this problem can be solved in two steps: 1. Transform from polar coordinates to Cartesian coordinates. 2. Transform from Cartesian coordinates to barycentric coordinates. The details of the solution are left as an exercise. 

Example B.15 [Parametric-polar transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in parametric coordinates as [u, v]T such that the u- and v-axes are along a˙b˙ and a˙c˙ respectively, express the same point in polar coordinates if 1. the origin of the Cartesian system expressing the vertices a˙, b˙ and c˙ is the same as the origin of the polar system; and 2. the x-axis of the Cartesian system has an angular coordinate of 0◦.

Solution B.15 The problem can be solved in two steps: 1. Transform from parametric coordinates to Cartesian coordinates. By applying Eq. (B.12), point p˙ =[u, v]T is expressed in Cartesian coordinates as  x = a˙ + u[b˙ − a˙]+v[c˙ − a˙] y    − − = xa˙ + xb˙ xa˙ + xc˙ xa˙ . u − v − ya˙ yb˙ ya˙ yc˙ ya˙

2. Transform from Cartesian coordinates to polar coordinates by substituting the value of [x, y]T obtained from Step 1 in Eq. (B.18). Therefore, ⎡ ⎤  a˙ + u[b˙ − a˙]+v[c˙ − a˙] r   = ⎣ (1 − u − v)y˙ + uy˙ + vy˙ ⎦ . θ −1 a b c (B.21) tan ( − − ) + + 1 u v xa˙ uxb˙ vxc˙ 

Example B.16 [Polar-parametric transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in polar coordinates as [r,θ]T where 1. the origin of the Cartesian system expressing the vertices a˙, b˙ and c˙ is the same as the origin of the polar system; and 2. the x-axis of the Cartesian system has an angular coordinate of 0◦, express the same point in parametric coordinates [u, v]T such that the u- and v-axes are along a˙b˙ and a˙c˙ respectively. 666 Appendix B: Coordinate Systems

Fig. B.8 Two polar coordinate systems

Solution B.16 Like similar problems, this problem can be solved in two steps: 1. Transform from polar coordinates to Cartesian coordinates. 2. Transform from Cartesian coordinates to parametric coordinates. The details of the solution are left as an exercise.  Example B.17 [Polar-polar transformation] Consider Fig. B.8 where a point p˙ is expressed in Cartesian coordinates as[x, y]T [ ,θ]T = 2 + 2 θ = −1 y and in polar coordinates as r such that r x y and tan x .Ifa new polar system is defined using a extending from a point a˙ to another point b˙ where point a˙ is the origin and point b˙ has angular coordinate of 0◦ in the new polar coordinate system. Express point p˙ in the new polar coordinate system as [r ,θ ]T where 1 r unit = 1 r unit.

Solution B.17 The new radial coordinate r represents the distance from the new origin a˙ to point p˙ (as depicted in Fig. B.8) and it can be determined as a Euclidean distance (Sect. B.1.2). Using Eq. (B.8), r is expressed as  2 2 r = d(a˙, p˙) = (xp˙ − xa˙ ) + (yp˙ − ya˙ ) or equivalently by the norm (Sect. A.4.1)asinEq.(A.14):  2 2 r =p˙ − a˙= (xp˙ − xa˙ ) + (yp˙ − ya˙ ) .

The angular coordinate θ is obtained as the angle enclosed between a˙b˙ and a˙p˙ (refer to Fig. B.8). Using the dot product (Sect. A.4.3.2)asinEq.(A.22), this angle can be obtained as   ˙ − [b − a˙] · [p˙ − a˙] θ = cos 1 . b˙ − a˙p˙ − a˙

Thus, the new polar coordinates of point p˙ is expressed as  ˙ − ˙ r p a = [˙−˙]·[˙−˙] .  θ cos−1 b a p a b˙−a˙p˙−a˙ Appendix B: Coordinate Systems 667

Fig. B.9 Cylindrical coordinates. a The cylin- der height is considered along the z-axis. b The cylinder height is considered along the y-axis

B.5 Cylindrical Coordinate System

Cylindrical coordinates are used to describe a point on a cylindrical surface. The cylindrical coordinate system is an extension to the polar coordinate system in 3D space by adding another dimension representing the height as the z-axis. In cylindrical coordinate system, a point is defined by a polar coordinate (or radial coordinate) r and a polar angle (or angular coordinate) θ (also known as the angle) in addition to a height coordinate z. This is shown in Fig. B.9a. Thus, a point P˙ in polar system is defined as [r,θ,z]T . Some systems consider the height as being along the y-axis and the base as residing on the zx-plane. This is shown in Fig. B.9b.

B.5.1 Cartesian-Cylindrical Transformation

A point P˙ =[x, y, z]T in Cartesian system can be expressed in cylindrical coordi- nates [r,θ,z]T as ⎡ ⎤ ⎡  ⎤ r x2 + y2 ⎣ θ ⎦ = ⎣ −1 y ⎦ . tan x (B.22) z z

If the height of the cylinder is along the y-axis, point P˙ =[x, y, z]T in Cartesian system can be expressed in cylindrical coordinates [r, y,θ]T as ⎡ ⎤ ⎡ √ ⎤ r z2 + x2 ⎣ ⎦ ⎣ ⎦ y = y   . (B.23) θ −1 z tan x 668 Appendix B: Coordinate Systems

Example B.18 [Cartesian-cylindrical transformation] Express the Cartesian point [3, 4, 5]T in cylindrical coordinates such that the origin of the cylindrical system coincides with the origin of the Cartesian system, the x-axis corresponds to θ = 0◦ and the height is along the z-axis.

Solution B.18 Applying Eq. (B.22), [3, 4, 5]T is expressed in cylindrical coordi- nates as ⎡ ⎤ ⎡  ⎤ r x2 + y2 ⎣ θ ⎦ = ⎣ −1 y ⎦ tan x z z ⎡ √ ⎤ ⎡ ⎤ 32 + 42 5 = ⎣ −1 4 ⎦ = ⎣ 53.1301◦ ⎦ .  tan 3 5 5

B.5.2 Cylindrical-Cartesian Transformation

A point P˙ =[r,θ,z]T in cylindrical system can be expressed in Cartesian coordinates [x, y, z]T as ⎡ ⎤ ⎡ ⎤ x r cos(θ) ⎣ y ⎦ = ⎣ r sin(θ) ⎦ . (B.24) z z

If the height of the cylinder is along the y-axis, point P˙ =[r, y,θ]T in cylindrical system can be expressed in Cartesian coordinates [x, y, z]T as ⎡ ⎤ ⎡ ⎤ x r sin(θ) ⎣ y ⎦ = ⎣ y ⎦ . (B.25) z r cos(θ)

Example B.19 [Cylindrical-Cartesian transformation] The point [5, 53.1301, 5]T is defined in cylindrical coordinates. Express it in Cartesian coordinates such that the origin of the cylindrical system coincides with the origin of the Cartesian system, the x-axis corresponds to θ = 0◦ and the height is along the z-axis.

Solution B.19 Applying Eq. (B.24), [5, 53.1301, 5]T is expressed in Cartesian coordinates as ⎡ ⎤ ⎡ ⎤ x r cos(θ) ⎣ y ⎦ = ⎣ r sin(θ) ⎦ z z ⎡ ⎤ ⎡ ⎤ 5 cos(53.1301) 3 = ⎣ ( . ) ⎦ = ⎣ ⎦ . 5sin53 1301 4  5 5 Appendix B: Coordinate Systems 669

Fig. B.10 Spherical coordinates. a θ is the angle in the xy-plane from the positive x-axis, φ is the angle from the positive z-axis. b θ is the angle in the zx-plane from the positive z-axis, φ is the angle from the positive y-axis. c Cartesian components for a. d Cartesian components for b

B.6 Spherical Coordinate System

Spherical coordinates are used to describe a point on a spherical surface as depicted in Fig. B.10a. In this system, a point P˙ =[r,θ,φ]T is described using two angles θ and φ in addition to a radial distance r. Considering a centered at the origin, θ is the azimuth angle in the xy-plane from the positive x-axis, φ is the zenith angle from the positive z-axis while r is the radial distance from the origin to the point. Some systems consider the azimuth angle θ as being the angle in the zx-plane from the positive z-axis and the zenith angle φ as being the angle from the positive y-axis. This is shown in Fig. B.10b. 670 Appendix B: Coordinate Systems

B.6.1 Cartesian-Spherical Transformation

A point P˙ =[x, y, z]T in Cartesian system can be expressed in spherical coordinates [ ,θ,φ]T r as ⎡ ⎤ ⎡  ⎤ x2 + y2 + z2 r ⎢   ⎥ ⎣ θ ⎦ = ⎣ tan−1 y ⎦ . x  (B.26) φ −1 z cos r

If the angle θ is measured about the y-axis and φ is measured from the positive y-axis as in Fig. B.10b, point P˙ =[x, y, z]T in Cartesian system can be expressed in spherical coordinates [r,φ,θ]T as ⎡  ⎤ ⎡ ⎤ x2 + y2 + z2 r ⎢   ⎥ ⎣ ⎦ ⎢ cos−1 y ⎥ φ = ⎣ r ⎦ . (B.27) θ −1 x tan z

Example B.20 [Cartesian-spherical transformation] Express the Cartesian point [3, 4, 5]T in spherical coordinates such that the origin of the spherical system coincides with the origin of the Cartesian system, θ is mea- sured in the xy-plane from the positive x-axis and φ is measured from the positive z-axis.

Solution B.20 Applying Eq. (B.26), [3, 4, 5]T is expressed in spherical coordi- nates as ⎡ ⎤ ⎡  ⎤ x2 + y2 + z2 r ⎢   ⎥ ⎣ θ ⎦ = ⎣ tan−1 y ⎦ x  φ −1 z cos r ⎡ √ ⎤ ⎡ ⎤ 32 + 42 + 52 7.0711 ⎢ −1 4 ⎥ ⎣ ◦ ⎦ = ⎣ tan 3 ⎦ = 53.1301 . ◦  cos−1 √5 45 5 2

B.6.2 Spherical-Cartesian Transformation

A point P˙ =[r,θ,φ]T in spherical system can be expressed in Cartesian coordinates [x, y, z]T as ⎡ ⎤ ⎡ ⎤ x r cos(θ) sin(φ) ⎣ y ⎦ = ⎣ r sin(θ) sin(φ) ⎦ . (B.28) z r cos(φ) Appendix B: Coordinate Systems 671

These Cartesian coordinates are shown in Fig. B.10c. If the azimuth angle θ is measured about the y-axis and the zenith angle φ is measured from the positive y-axis as in Fig. B.10b, point P˙ =[r,φ,θ]T in spherical system can be expressed in Cartesian coordinates [x, y, z]T as ⎡ ⎤ ⎡ ⎤ x r sin(θ) sin(φ) ⎣ y ⎦ = ⎣ r cos(φ) ⎦ . (B.29) z r cos(θ) sin(φ)

These Cartesian coordinates are shown in Fig. B.10d.

Example B.21 √[Spherical-Cartesian transformation] The point [5 2, 53.1301, 45]T is defined in spherical coordinates. Express it in Cartesian coordinates such that the origin of the spherical system coincides with the origin of the Cartesian system, θ is measured in the xy-plane from the positive x-axis and φ is measured from the positive z-axis. √ Solution B.21 Applying Eq. (B.28), [5 2, 53.1301, 45]T is expressed in Cartesian coordinates as ⎡ ⎤ ⎡ ⎤ x r cos(θ) sin(φ) ⎣ y ⎦ = ⎣ r sin(θ) sin(φ) ⎦ z r cos(φ) ⎡ √ ⎤ ⎡ ⎤ 5√2 cos(53.1301) sin(45) 3 ⎣ ⎦ ⎣ ⎦ = 5 2sin√(53.1301) sin(45) = 4 .  5 2 cos(45) 5

B.7 Homogeneous Coordinates

In order to express a 2D point in homogeneous coordinates, simply add a third term whose value is 1 to the point vector (i.e., a 2D point is represented as a 3D vector in homogeneous coordinates). For example, the point [3, 4]T is represented homo- T T T geneously as [3, 4, 1] . In general, a 2D point [x, y] is expressed as [a1, a2, a3] such that a = 0, x = a1 and y = a2 . Hence, the overall scaling a of the homo- 3 a3 a3 3 geneous coordinates is not important. Thus, the homogeneous 2D points [3, 4, 1]T , T T T [6, 8, 2] and [1.5, 2, 0.5] are the same. Two homogeneous points [a1, a2, a3] T and [b1, b2, b3] are identical if and only if

a2 a3 a3 a1 a1 a2 = = = 0, (B.30) b2 b3 b3 b1 b1 b2 where |.| indicates the determinant (Sect. A.2.1). Thus,

a2b3 − a3b2 = a3b1 − a1b3 = a1b2 − a2b1 = 0. (B.31) 672 Appendix B: Coordinate Systems

If the third term of a homogeneous point is zero, this point is a point at infinity or a direction (Elias 2008, 2012). We can use such points to get the vanishing point of a group of parallel lines as explained in Chap. 8. Similarly, to express a 3D point in homogeneous coordinates, simply add a fourth term whose value is 1 to the point vector (i.e., a 3D point is represented as a 4D vector in homogeneous coordinates). For example, the point [3, 4, 2]T is represented homogeneously as [3, 4, 2, 1]T . In general, a 3D point [x, y, z]T is expressed as [a , a , a , a ]T such that a = 0, x = a1 , y = a2 and z = a3 . (If a = 0, the 1 2 3 4 4 a4 a4 a4 4 point becomes a point at infinity or a direction.) Hence, the overall scaling a4 of the homogeneous coordinates is not important. Thus, the homogeneous 3D points [3, 4, 2, 1]T , [6, 8, 4, 2]T and [1.5, 2, 1, 0.5]T are the same.

Example B.22 [Homogeneous coordinates–points] Determine if the following homogeneous points are the same: [2, 3, 1]T and [4, 6, 3]T .

Solution B.22 The homogeneous coordinates refer to the same point when the pro- portions are maintained; i.e., when there is a single number to be multiplied by all the components of one point to get the other. Since no single number exists in this problem, the points [2, 3, 1]T and [4, 6, 3]T are different. The same conclusion can be obtained using Eq. (B.30)or(B.31). The determi- nants are a2 a3 = a2b3 − a3b2 = 3 × 3 − 1 × 6 = 3, b2 b3

a3 a1 = a3b1 − a1b3 = 1 × 4 − 2 × 3 =−2 b3 b1

and a1 a2 = a1b2 − a2b1 = 2 × 6 − 3 × 4 = 0. b1 b2

Since a2b3 − a3b2 = a3b1 − a1b3 = 0, the points not identical. (You may stop calculating once a determinant results in a value other than 0.) 

B.8 Problems

Problem B.1 [Cartesian-barycentric transformation] A triangle is given by the vertices [1, 0]T , [3, 1]T and [0, 3]T . Determine the barycentric coordinates of the points [1, 2]T and [2, 1]T . Appendix B: Coordinate Systems 673

Problem B.2 [Barycentric-Cartesian transformation] Consider the triangle with vertices [2, 0]T , [4, 2]T and [0, 4]T . Determine the Cartesian coordinates of the barycentric point [0.4, 0.3, 0.3]T .

Problem B.3 [Barycentric-Cartesian transformation] The vertices of a triangle are placed at the positions [0, 0, 0]T , [2, 3, 0]T and [ , , ]T 3 1 0 . Determine the points represented  by the following set of barycentric [ , , ]T 2 , 1 , T 1 , 1 , 1 T [ . , . , . ]T 4 , 2 , − T coordinates: 0 1 0 , 3 3 0 , 3 3 3 , 0 8 0 1 0 1 and 3 3 1 . Problem B.4 [Cartesian-parametric transformation] A triangle is given by the vertices [1, 0]T , [3, 1]T and [0, 3]T . Determine the parametric coordinates of the points [1, 2]T and [2, 1]T if [1, 0]T is considered as the origin of the system and the u- and v-axes are passing through [3, 1]T and [0, 3]T respectively.

Problem B.5 [Parametric-Cartesian transformation] Consider a triangle a˙b˙c˙ where a˙ =[1, 0]T , b˙ =[3, 1]T and c˙ =[0, 3]T .Ifa parametric coordinate system is defined such that the u- and v-axes go along a˙b˙ and a˙c˙ respectively, express the parametric points [0.2857, 0.5714]T , [0.5714, 0.1429]T and [0, 0]T in Cartesian coordinates.

Problem B.6 [Parametric-barycentric transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in para- coordinates as [u, v]T where the parametric u- and v-axes are along a˙b˙ and ˙ ˙ [ , , ]T ac respectively, get its barycentric coordinates ta˙ tb˙ tc˙ . Hint: You may refer to Example B.10 for steps.

Problem B.7 [Barycentric-polar transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in barycentric [ , , ]T coordinates as ta˙ tb˙ tc˙ , express the same point in polar coordinates if the origin of the polar system is at a˙ and point b˙ has an angular coordinate of 0◦.

Problem B.8 [Polar-barycentric transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in polar coordinates as [r,θ]T where 1. the origin of the Cartesian system expressing the vertices a˙, b˙ and c˙ is the same as the origin of the polar system; and 2. the x-axis of the Cartesian system has an angular coordinate of 0◦, [ , , ]T express the same point in barycentric coordinates ta˙ tb˙ tc˙ . Hint: You may refer to Example B.14 for steps.

Problem B.9 [Polar-barycentric transformation] Consider a triangle a˙b˙c˙ such that the vertices a˙, b˙ and c˙ are expressed in Carte- sian coordinates. If a point p˙ inside the triangle is expressed in polar coordinates as [r,θ]T where 674 Appendix B: Coordinate Systems

1. the origin of the polar system is at vertex a˙; and 2. the edge a˙b˙ has an angular coordinate of 0◦, [ , , ]T express the same point in barycentric coordinates ta˙ tb˙ tc˙ . Problem B.10 [Polar-parametric transformation] Consider a triangle a˙b˙c˙. If a point p˙ inside the triangle is expressed in polar coordinates as [r,θ]T where 1. the origin of the Cartesian system expressing the vertices a˙, b˙ and c˙ is the same as the origin of the polar system; and 2. the x-axis of the Cartesian system has an angular coordinate of 0◦, express the same point in parametric coordinates [u, v]T such that the u- and v-axes are along a˙b˙ and a˙c˙ respectively. Hint: You may refer to Example B.16 for steps. Problem B.11 [Polar-parametric transformation] Consider a triangle a˙b˙c˙ such that the vertices a˙, b˙ and c˙ are expressed in Carte- sian coordinates. If a point p˙ inside the triangle is expressed in polar coordinates as [r,θ]T where 1. the origin of the polar system is at vertex a˙; and 2. the edge a˙b˙ has an angular coordinate of 0◦, express the same point in parametric coordinates [u, v]T if the parametric u- and v-axes are along a˙b˙ and a˙c˙. Problem B.12 [Barycentric coordinates–3D space] The following equation determines the barycentric coordinates of a point p˙ inside a 2D triangle bounded by the vertices a˙, b˙ and c˙: ⎡ ⎤ ⎡    ⎤ b˙ − p˙ c˙ − p˙ ta˙    ⎢ ⎥ ⎣ t˙ ⎦ =  1 ⎣ c˙ − p˙ a˙ − p˙ ⎦ . b b˙−a˙ [c˙−a˙]    tc˙ a˙ − p˙ b˙ − p˙

Can we use the same equation to obtain the barycentric coordinates of a 3D point P˙ inside a 3D triangle bounded by the vertices A˙ , B˙ and C˙ ? If no, write down the correct equation. Problem B.13 [Cartesian-cylindrical transformation] Express the Cartesian point [3, 4, 5]T in cylindrical coordinates such that the origin of the cylindrical system coincides with the origin of the Cartesian system, θ = 0◦ corresponds to the z-axis and the height is along the y-axis. Problem B.14 [Cylindrical-Cartesian transformation] The point [5, 53.13, 5]T is defined in cylindrical coordinates. Express it in Carte- sian coordinates such that the origin of the cylindrical system coincides with the origin of the Cartesian system, θ = 0◦ corresponds to the z-axis and the height is along the y-axis. Appendix B: Coordinate Systems 675

Problem B.15 [Cartesian-spherical transformation] Express the Cartesian point [3, 4, 5]T in spherical coordinates such that the origin of the spherical system coincides with the origin of the Cartesian system, θ is mea- suredinthezx-plane from the positive z-axis and φ is measured from the positive y-axis.

Problem B.16 √[Spherical-Cartesian transformation] The point [5 2, 53.13, 45]T is defined in spherical coordinates. Express it in Cartesian coordinates such that the origin of the spherical system coincides with the origin of the Cartesian system, θ is measured in the zx-plane from the positive z-axis and φ is measured from the positive y-axis.

Problem B.17 [Homogeneous coordinates–points] Determine if the following homogeneous points are the same: [2, 3, 1]T and [4, 6, 2]T .

References

Elias, R. 2008. Geometric modeling in computer vision: An introduction to projective geometry. In Wiley encyclopedia of computer science and engineering, ed. B.W. Wah, 1400Ð1416. New Jersey: Wiley. Elias, R. 2012. 3D surface geometry and reconstruction: Developing concepts and applications, chapter projective geometry for 3D modeling of objects. Hershey, PA, USA: IGI Global. Vince, J. 2008. for computer graphics. Berlin: Springer. Vince, J. 2010. Mathematics for computer graphics, 3rd edn. Undergraduate Topics in Computer Science. Springer Index

Symbols yz-plane, 173 1-point perspective projection, 347 zx-plane, 174 2-point perspective projection, 360 3D reflection matrix, 173Ð175, 652 2-way , 22 3D , 144 2D axes reflection, 107 x-axis, 145 2D axes rotation, 102 y-axis, 147 2D axes scaling, 105 z-axis, 148 2D axes translation, 101 3D rotation matrix, 146Ð148 2D left-handed coordinate system, 651 3D scaling, 169 2D line clipping, 35 3D scaling matrix, 169, 170, 180Ð182 2D point clipping, 36 3D shearing, 180 2D polygon clipping, 52 x-axis, 180 2D reflection, 78, 79 y-axis, 181 2D reflection matrix, 78, 79, 651 z-axis, 182 2D right-handed coordinate system, 650 3D shearing matrix, 424 2D rotation, 67, 69 3D transformation, 143 2D rotation matrix, 68 3D translation, 143 2D scaling, 74, 75 3D translation matrix, 144 matrix, 74, 75 4-way symmetry, 24 non-uniform, 75 8-way symmetry, 26 uniform, 75 2D shape, 9 2D shearing, 87 A 2D shearing matrix, 87Ð89 Adjacency list, 137 2D transformations, 65 Affine transformation, 215, 233, 585 2D translation, 65 Ambient light, 526 2D translation matrix, 66, 98 Ambient mapping, 601 3-point perspective projection, 368 Ambient reflectance, 537 3D Shearing, 182 Ambient reflection, 536 3D axes reflection, 192 Ambient reflection coefficient, 537 3D axes rotation, 188 Angular coordinate, 593, 663, 667 3D axes scaling, 191 API, 446 3D axes translation, 187 Application programming interface, 446 3D line clipping, 439 AV C , 2 3D modeling, 113 Axes reflection, 107, 192 3D reflection, 172, 175 Axes rotation, 102, 188 xy-plane, 172 Axes scaling, 105, 191

R. Elias, Digital Media, DOI: 10.1007/978-3-319-05137-6, 677 © Springer International Publishing Switzerland 2014 678 Index

Axes translation, 101, 187 CAGD, 199 Axis of revolution, 135 Camera coordinate system, 387 Axonometric projection, 327 Canonical view volume, 387, 413 dimetric, 335 parallel projection, 417 isometric, 330 perspective projection, 431 trimetric, 338 Cartesian coordinate system, 649 Azimuth angle, 327, 333, 597, 667, 669 Cavalier projection, 340 Cell decomposition, 125 Center of projection, 319, 320, 346, 405 B , 21 B-reps, 116 2-way symmetry, 22 B-spline, 236 4-way symmetry, 24 B-spline curve, 236 8-way symmetry, 26 Bézier curve, 224 Circle midpoint algorithm, 28 Bézier polygon, 225, 228 Clip polygon, 53 Bézier surface, 296 Clipper Back clipping plane, 409 line, 35, 439 Back view projection, 321 point, 36 Back-face culling, 463 polygon, 52 Backward ray tracing, 512 Clipping, 4, 35, 439 Barycentric coordinate system, 656 Cohen-Sutherland algorithm, 42, 442 Barycentric coordinates, 565, 571 Cyrus-Beck algorithm, 42 , 236, 239 Liang-Barsky algorithm, 41 Basis matrix, 263, 270 line, 35, 439 Basis spline, 236 Nicholl-Lee-Nicholl algorithm, 42 Baumgart’s winged-edge, 116, 136 point, 36 Bernstein polynomial, 230, 296 polygon, 52 Bernstein. polynomial, 226 Weiler-Atherton algorithm, 53 Bicubic Bézier surface, 302 Clipping window, 53 Bilinear interpolation, 561, 567, 583, 588 CMY color space, 610 Binary space partitioning, 131, 468, 499 Codec, 2 Binomial coefficient, 226, 296 Cohen-Sutherland clipping algorithm, 42, Bintree, 129 442 Blinn-Phong reflection model, 549 Color channel Boolean operation, 118 blue, 607 difference, 119 brightness, 612 intersection, 119 cyan, 610 subtraction, 119 green, 607 union, 118 hue, 612, 617, 618 Bottom view projection, 325 lightness, 617 Boundary representations, 116 luminance, 617 Bounding volume, 499 magenta, 610 Box , 592 red, 607 Bresenham’s algorithm, 13 saturation, 612, 617, 618 Brightness, 612 value, 612 BSP tree, 131, 468, 499 yellow, 610 Buffer, 465 Color model, 607, 610, 612, 617 Bump mapping, 601 CMY, 610 HLS, 617 HSB, 612 C HSL, 617 Cabinet projection, 341 HSV, 612 CAD, 3 RGB, 607 Index 679

Color space, 607, 610, 612, 617 3D, 642 CMY, 610 CSG, 118 HLS, 617 CSG expression, 120 HSB, 612 CSG tree, 120 HSL, 617 Cubic HSV, 612 Bézier curve, 228 RGB, 607 Bézier surface, 302 Commutative, 73, 92 NURBS surface, 310 Complementary colors, 610, 613, 618 Cubic B-spline, 268 Composite transformations, 92, 185 Cubic polynomial, 200 2D, 92 Curve, 199, 200 3D, 185 C1 continuous, 223 Computer aided design, 3 C1 parametric continuity, 223 Computer aided geometric design, 199 C2 continuous, 223 Computer graphics, 2 C2 parametric continuity, 223 Computer vision, 2 G0 continuous, 223 Concave polygon, 32 G0 geometric continuity, 223 Concavity, 32 G1 continuous, 223 , 203 G1 geometric continuity, 223 Constant shading, 560 G2 continuous, 223 Constructive solid geometry, 118 G2 geometric continuity, 223 Control hull, 274 appoximating, 223 Control point, 224, 225, 228 B-spline, 236 Control polygon, 225, 228, 274 Bézier, 224 Convex hull, 225, 260, 269, 297 basis function, 239 Convex polygon, 32 continuity, 222 Convexity, 32 cubic B-spline, 268 Coordinate cubic Bézier, 228 angular, 593, 663, 667 cubic NURBS, 285 polar, 663, 667 cubic parametric, 217 radial, 593, 663, 667 , 200, 236 Coordinate system explicit representation, 200 barycentric, 488, 656 , 224 camera, 387 higher order Bézier, 236 Cartesian, 649 higher order parametric, 221 cylindrical, 667 implicit representation, 205 eye, 387 interpolating, 223 left-handed, 391, 651 knot, 236 normalized device, 429 knot value, 236 normalized viewing, 429, 438 knot vector, 236, 237, 275 parametric, 489, 653 linear Bézier, 224 polar, 663 linear parametric, 206 right-handed, 390, 650 multiplicity, 239 spherical, 669 non-uniform rational B-spline, 274 view reference, 387, 389 NURBS, 273, 276, 285 world, 387 order, 201, 236 Coordinates parametric representation, 206 device, 452 patch, 224 homogeneous, 452, 671 quadratic B-spline, 258 COP, 319, 405 quadratic Bézier, 225 CoxÐde Boor formula, 239 quadratic NURBS, 276 Cross product, 484, 574, 642 quadratic parametric, 207 2D, 646 rational, 273 680 Index

rational Bézier, 274 F span, 224 Face, 116 Curve degree, 200, 236 Face table, 117, 136 Curve order, 201, 236 Faceted shading, 560 Cut-off angle, 530 Far clipping plane, 409 Cylindrical coordinate system, 667 Far plane, 461 Cylindrical map projection, 592 Field of view, 409, 415, 477 Cyrus-Beck algorithm, 42 Filter color mapping, 601 Finite view volume, 409 First degree polynomial, 200 shading, 560 D Focal length, 347, 411 DDA algorithm, 10 Forward ray tracing, 512 Degree of freedom, 584, 585 Four-way symmetry, 24 Depth buffer, 465 FOV, 409, 415, 477 Determinant, 627, 671 Front clipping plane, 409 Device coordinates, 452 Front view projection, 321 Diffuse intensity, 538 Diffuse mapping, 601 Diffuse reflection, 537 G Diffuse reflection coefficient, 538 Geometric continuity 0 Digital differential analyzer algorithm, 10 G , 223 G1, 223 Digital image, 2 2 Dimetric projection, 335 G , 223 Geometry matrix, 224, 226, 230, 298, 299, Direct illumination, 525 302 Direction of extrusion, 135 Global illumination, 552 Direction of projection, 339, 400, 404 Gouraud shading, 561 Directional light, 526 Graphics pipeline, 3 Displacement mapping, 602 Divide-and-conquer, 127, 129 DOF, 584, 585 H DOP, 339, 400, 404 Half-open , 21, 236 Dot product, 206, 391, 482, 638 Heron’s formula, 488 DVB, 2 Hexagon, 612 Hexcone, 612, 617 Hidden-surface elimination, 4, 461 Hidden-surface removal, 4, 461 E Hierarchy, 499 Edge, 32, 113 Hither, 409, 461 Edge table, 113, 116 HLS color space, 617 Eight-way symmetry, 26 Homogeneous coordinates, 452, 671 Elevation angle, 327 2D, 66, 671 Environment mapping, 603 3D, 143, 672 Euclidean distance, 333, 653 Homogeneous point Explicit edge listing, 113 2D, 66, 671 Explicit form 3D, 143, 672 circle, 22 Homography matrix, 583 Explicit representation Homography transformation, 583 curve, 200 HSB color space, 612 surface, 295 HSL color space, 617 Extrusion, 134 HSV color space, 612 Eye coordinate system, 387 HSV hexcone, 612 Eye ray tracing, 512 Hue, 612, 618 Index 681

Hyperplane, 468 spot, 530 Light ray tracing, 512 Lighting, 3, 525 I Lightness, 617 IFS, 136 Line, 10 Illumination, 3, 525 Line clipping, 35, 439 direct, 525 Line midpoint algorithm, 17 global, 552 Linear indirect, 552 Bézier curve, 224 Image processing, 2 Bézier surface, 297 Implicit form Linear polynomial, 200 circle, 29 Luminance, 617 line, 18 Implicit representation curve, 205 M surface, 295 Map, 582 Incidence angle, 513, 515, 539, 553 uv-, 582 Independent face, 136 Map projection, 592 Index of refraction, 516, 556 box, 592 Indexed face set, 136 cylindrical, 592 Indirect illumination, 552 planar, 592 Infinite view volume, 400 spherical, 597 Interpolation matrix, 209, 219 Mapping, 4, 581 Intersection, 119 ambient, 601 Inverse, 627 bump, 601 Inversion of transformation, 99 diffuse, 601 Isometric projection, 330 displacement, 602 Isoparametric curve, 298 environment, 603 filter color, 601 J opacity, 605 JPEG, 2 reflection, 603 refraction, 604 self-illumination, 601 K shininess, 601 Knot, 236 specular, 601 Knot multiplicity, 239 Matrix, 625 Knot span, 236 2D reflection, 78, 79, 651 Knot value, 236 2D rotation, 68 Knot vector, 236, 237, 275 2D scaling, 74, 75 2D shearing, 87Ð89 2D translation, 66, 98 L 3D reflection, 173Ð175, 652 Lambert’s law, 538 3D rotation, 146Ð148 Lambertian reflection, 537 3D scaling, 169, 170 Lathing, 135 3D shearing, 180Ð182, 424 Law of reflection, 513, 539 3D translation, 144 Least-significant bit, 42, 442, 444 affine transformation, 585 Left-handed system, 650 anti-symmetric, 626 Liang-Barsky algorithm, 41 basis, 263 Light determinant, 149, 627 ambient, 526 diagonal, 626 directional, 526 geometry, 224, 226, 230, 298, 299, 302 point, 527 homography, 583 682 Index

homography transformation, 583 NURBS curve, 273 identity, 625 NURBS surface, 305 interpolation, 209, 219 inverse, 149, 627 normalized, 149 O orthogonal, 149, 625 Oblique projection, 321, 339 plane projective transformation, 583 cabinet, 341 skew symmetric, 626 cavalier, 340 symmetric, 626 Octant, 26, 28, 650 transpose, 149, 629 Octree, 129, 499, 508 Matrix addition, 629 One-point perspective projection, 347 Matrix multiplication, 632 Opacity mapping, 605 Matrix subtraction, 629 Open uniform knot vector, 237 Mesh, 135 Orthographic projection, 321 Midpoint algorithm axonometric, 327 circle, 28 multi-view, 321 line, 17 Outcode, 42, 442 Model B-reps, 116 CSG, 118 P spatial, 125 Painter’s algorithm, 462 sweep, 132 Parallel projection, 320 wireframe, 113 oblique, 339 Modeling transformation, 3 orthographic, 321 Most-significant bit, 42, 442, 444 Parallelepiped view volume, 320, 346 MPEG, 2 Parametric continuity Multi-view projection, 321 C1, 223 front view, 321 C2, 223 side view, 323 Parametric coordinate system, 653 top view, 325 Parametric coordinates, 564, 569 Multiplicity, 239, 254 Parametric form circle, 21 line, 36 N Parametric representation NDC, 429 curve, 206 Near clipping plane, 409 surface, 296 Near plane, 461 Parametric tangent vector, 222 Nicholl-Lee-Nicholl algorithm, 42 Partitioning Node, 121 binary space, 131, 468, 499 Non-periodic knot vector, 238 octree, 499, 508 Non-planar projection, 319 quadtree, 127, 468, 499, 504 Non-uniform knot vector, 238 regular grid, 503 Non-uniform rational B-spline curve, 274 Patch Non-uniform rational B-spline surface, 305 Bézier, 296 Norm, 635, 653 bicubic Bézier, 302 Normal vector, 389, 567 cubic Bézier, 302 Normalization, 567, 635 cubic NURBS, 310 Normalized device coordinate system, 429 NURBS, 305 Normalized viewing coordinate system, 429, planar, 297 438 quadratic Bézier, 298 Normalizing transformation, 413 quadratic NURBS, 305 Null vector, 643 Patrick-Gilles Maillot algorithm, 53 NURBS, 276, 285 Penumbra, 534 Index 683

Periodic knot vector, 237 dimetric, 335 Perspective normalization, 446 front view, 321 Perspective projection, 346 isometric, 330 one-point, 347 multi-view, 321 three-point, 368 non-planar, 319 two-point, 360 oblique, 339 Phong exponent, 540 one-point perspective, 347 Phong reflection model, 526, 542, 567 orthographic, 321 Phong shading, 567 parallel, 320 Pixel, 3 perspective, 346 Planar map projection, 592 planar, 319 Planar projection, 319 side view, 323 parallel, 320 three-point perspective, 368 perspective, 346 top view, 325 Planar surface, 297 trimetric, 338 Pointatinfinity,672 two-point perspective, 360 Point clipping, 36 Projection plane, 319 Point in triangle, 482, 484, 488, 489, 491 Projection reference point, 400 Point light, 527 Projection transformation, 4, 319, 387 Polar angle, 663, 667 Projective transformation, 583 Polar coordinate system, 663 Projector, 319Ð321, 339, 346 Polygon, 32 PRP, 400 Bézier, 225, 228 Pyramidal view volume, 346 concave, 32 control, 225, 228 convex, 32 Q Polygon clipping, 52 QoS, 2 Polygon concavity, 32 Quadrant, 24, 26, 649 Polygon convexity, 32 Quadratic Polygonal mesh, 135 Bézier curve, 225 Polygonal modeling, 135 Bézier surface, 298 Polyline, 32 NURBS surface, 305 Polynomial, 200 Quadratic B-spline, 258 Bernstein, 226, 230, 296 Quadratic polynomial, 200 cubic, 200 Quadtree, 127, 468, 499, 504 degree, 200 first degree, 200 linear, 200 R quadratic, 200 Radial coordinate, 593, 663, 667 second degree, 200 Radiance for reflection, 554 third degree, 200 Radiance for refraction, 557 Position vector, 638 Raster graphics, 9 Product Rasterization, 4 cross, 642, 646 Rational Bézier curve, 274 dot, 638 Rational curve, 273 scalar, 638 Rational surface, 305 vector, 642 Ray Projection reflected, 512, 553 axonometric, 327 reflection, 513, 553 back view, 321 refracted, 512, 556 bottom view, 325 refraction, 515, 555 cabinet, 341 shadow, 512, 552 cavalier, 340 transmitted, 512 684 Index

Ray casting, 475 Scaling Ray intersections 2D, 74, 75 ray-plane, 479 3D, 169 ray-sphere, 493 axes, 105, 191 ray-triangle, 481 Scan conversion, 4, 9 Ray tracing, 512 Second degree polynomial, 200 backward, 512 Self-illumination mapping, 601 eye, 512 Set theory, 118 forward, 512 Shading, 3, 4, 559 light, 512 constant, 560 recursive, 517 faceted, 560 Ray tree, 518 flat, 560 Ray-plane intersections, 479 Gouraud, 561 Ray-sphere intersections, 493 Phong, 567 Ray-triangle intersections, 481 Shading model, 559 Recursive ray tracing, 517 Shadow, 572 Reflectance model, 536 Shadow ray, 512, 552 Reflected ray, 512, 553 Shadowing, 572 Reflection Shape, 9 2D, 78, 79 Shearing 3D, 172 2D, 87 ambient, 536 3D, 180 axes, 107, 192 Shininess mapping, 601 diffuse, 537 Side, 32 Lambertian, 537 Side view projection, 323 specular, 539 Sign bit, 43, 442, 444 Reflection angle, 513, 539, 553 , 11 Reflection mapping, 603 Snell’s law, 515, 555 Reflection model, 567 Solid Blinn, 549 closure, 123 Blinn-Phong, 549 difference, 119 Phong, 542 exterior, 123 Reflection ray, 513, 553 interior, 123 Refracted ray, 512, 556 intersection, 119 Refraction angle, 515, 555 modeling, 118 Refraction mapping, 604 primitive, 118 Refraction ray, 515, 555 subtraction, 119 Regularized operation, 123 union, 118 Rendering pipeline, 3 Space partitioning, 468, 503 Revolution, 135 Space partitioning tree, 468 RGB color space, 607 Spatial representation, 125 Right-handed system, 650 Specular highlight, 539, 567 Rotation Specular intensity, 540 2D, 67, 69 Specular mapping, 601 3D, 144 Specular reflection, 539 axes, 102, 188 Specular reflection coefficient, 540 Rotational sweep, 135 Spherical coordinate system, 669 Spherical map projection, 597 Spotlight, 530 S Subject polygon, 53 Saturation, 612, 618 Surface Scalar multiplication, 631, 637 approximating, 296 Scalar product, 638 Bézier, 296 Index 685

bicubic Bézier, 302 Tree cubic Bézier, 302 binary space partitioning, 131, 468 cubic NURBS, 310 bintree, 129 explicit representation, 295 BSP, 131, 468, 499 implicit representation, 295 CSG, 120 interpolating, 296 octree, 129, 499, 508 linear Bézier, 297 quadtree, 127, 468, 499, 504 non-uniform rational B-spline, 305 ray, 518 NURBS, 305 Triangle mesh, 137 parametric representation, 296 Trimetric projection, 338 planar, 297 Trimming, 9 quadratic Bézier, 298 Two-point perspective projection, 360 quadratic NURBS, 305 Two-way symmetry, 22 rational, 305 Surface patch, 116 Sutherland-Hodgman algorithm, 53 U Sweep, 132 Umbra, 534 rotational, 135 Uniform knot vector, 237 translational, 134 Union, 118 Symmetry Unit Cartesian vectors, 635 2-way, 22 Unit vector, 389, 390, 635 4-way, 24 UV-map, 582 8-way, 26

V T Value, color, 612 Tangent vector, 222 Vanishing point, 347, 360, 368, 672 Tessellation, 136 Vector, 634 Texel, 582 addition, 636 Texture elements, 582 multiplication, 637 Texturing, 4 norm, 635, 653 Third degree polynomial, 200 normalization, 389, 635 Three-point perspective projection, 368 product, 642 Top view projection, 325 scaling, 637 Trace point, 347 subtraction, 390, 636 Transformation Vector graphics, 9 2D, 65 Vector product, 642 3D, 140 Vertex, 32, 113 affine, 215, 233, 585 Vertex table, 113, 117, 136 homography, 583 View plane, 319, 389 inversion, 99 View reference coordinate system, 387, 389 normalizing, 413 n-axis, 389 projective, 583 u-axis, 390 , 585 v-axis, 390 Transformations View reference point, 389, 392 composite, 92, 185 View transformation, 3, 387 Translation View volume, 319, 320, 399 2D, 65 canonical, 413 3D, 143 parallelepiped, 320, 346 axes, 101, 187 pyramidal, 346 Translational sweep, 134 Viewing frustum, 4, 409, 461, 477 Transmitted ray, 512 Viewing pipeline, 387, 388, 452 Transpose, 629 Viewpoint, 319, 320, 346 686 Index

Viewport, 452 Winged-edge, 116, 136 Visibility problem, 5, 462 Winged-edge data structure, 116 Visible-surface determination, 461 Wireframe, 113 Visual computing, 2 World coordinate system, 387 Visualization, 2 Volume element, 125 Voxel, 125 Y Voxel occupancy, 127 Yon, 409, 461 VRC, 387 VRP, 389

Z W Z-buffer, 465 WCS, 387 Zenith angle, 597, 669 Weiler-Atherton algorithm, 53 Zero vector, 643