What You ll See in This Chapter. Word Cloud. Definitions. Matrix Components. Ian Parberry University of North Texas. Fletcher Dunn

Size: px
Start display at page:

Download "What You ll See in This Chapter. Word Cloud. Definitions. Matrix Components. Ian Parberry University of North Texas. Fletcher Dunn"

Transcription

1 What You ll See in This Chapter Chapter 4: Introduction to Matrices Fletcher Dunn Valve Software Ian Parberry University of North Texas 3D Math Primer for Graphics and Game Development This chapter introduces matrices. It is divided into three sections. Section 4.1 discusses some of the basic properties and operations of matrices strictly from a mathematical perspective. Section 4.2 explains how to interpret these properties and operations geometrically. Section 4.3 puts the use of matrices in this book in context within the larger field of linear algebra, and is not covered in these notes. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 2 Word Cloud Section 4.1: Matrix: An Algebraic Definition Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 3 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 4 Definitions Algebraic definition of a matrix: a table of scalars in square brackets. Matrix dimension is the width and height of the table, w x h. Typically we use dimensions 2 x 2 for 2D work, and 3 x 3 for 3D work. We ll find a use for 4 x 4 matrices also. It s a kluge. More later. Matrix Components Entries are numbered by row and column, eg. m ij is the entry in row i, column j. Start numbering at 1, not 0. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 5 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 6

2 Square Matrices Same number as rows as columns. Entries m ii are called the diagonal entries. The others are called nondiagonal entries Diagonal Matrices A diagonal matrix is a square matrix whose nondiagonal elements are zero. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 7 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 8 The Identity Matrix The identity matrix of dimension n, denoted I n, is the n x n matrix with 1s on the diagonal and 0s elsewhere. Vectors as Matrices A row vector is a 1 x n matrix. A column vector is an n x 1 matrix. They were pretty much interchangeable in the lecture on Vectors. They re not once you start treating them as matrices. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 9 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 10 Transpose of a Matrix The transpose of an r x c matrix M is a c x r matrix called M T. Take every row and rewrite it as a column. Equivalently, flip about the diagonal Facts About Transpose Transpose is its own inverse: (M T ) T = M for all matrices M. D T = D for all diagonal matrices D (including the identity matrix I). Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 11 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 12

3 Transpose of a Vector If v is a row vector, v T is a column vector and vice versa Multiplying By a Scalar Can multiply a matrix by a scalar. Result is a matrix of the same dimension. To multiply a matrix by a scalar, multiply each component by the scalar. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 13 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 14 Matrix Multiplication Multiplying an r x n matrix A by an n x c matrix B gives an r x c result AB. Multiplication: Result Multiply an r x n matrix A by an n x c matrix B to give an r x c result C = AB. Then C = [c ij ], where c ij is the dot product of the ith row of A with the jth column of B. That is: Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 15 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 16 Example Another Way of Looking at It Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 17 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 18

4 2 x 2 Case 2 x 2 Example Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 19 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 20 3 x 3 Case 3 x 3 Example Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 21 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 22 Identity Matrix Recall that the identity matrix I (or I n ) is a diagonal matrix whose diagonal entries are all 1. Now that we ve seen the definition of matrix multiplication, we can say that IM = MI = M for all matrices M (dimensions appropriate) Matrix Multiplication Facts Not commutative: in general AB BA. Associative: (AB)C = A(BC) Associates with scalar multiplication: k(ab) = (ka)b =A(kB) (AB) T = B T A T (M 1 M 2 M 3 M n ) T = M n T M 3T M 2T M 1 T Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 23 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 24

5 Row Vector Times Matrix Multiplication Can multiply a row vector times a matrix Matrix Times Column Vector Multiplication Can multiply a matrix times a column vector. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 25 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 26 Row vs. Column Vectors Row vs. column vector matters now. Here s why: Let v be a row vector, M a matrix. vmis legal, Mv is undefined Mv T is legal, v T M is undefined DirectX uses row vectors. OpenGL uses column vectors. Common Mistake Mv T (vm) T, but Mv T = (vm T ) T compare the following two results: Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 27 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 28 Vector Matrix Multiplication Facts 1 Associates with vector multiplication. Let v be a row vector: v(ab) = (va)b Let v be a column vector: (AB)v = A(Bv) Vector Matrix Multiplication Facts 2 Vector matrix multiplication distributes over vector addition: (v + w)m = vm + wm That was for row vectors v, w. Similarly for column vectors. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 29 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 30

6 Matrices and Geometry Section 4.2: Matrix a Geometric Interpretation A square matrix can perform any linear transformation. What s that? Preserves straight lines Preserves parallel lines. No translation: the axes do not move. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 31 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 32 Linear Transformations Rotation Scaling Orthographic projection Reflection Shearing More about these in the next chapter. A Movie Quote Unfortunately, no one can be told what The Matrix is you have to see it for yourself. Actually, it s all about basis vectors. Look back to Chapter 3 if you ve forgotten about those. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 33 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 34 Axial Displacements Can rewrite any vector v = [x y z] as a sum of axial displacements. V = [x y z] = [x 0 0] + [0 y 0] + [0 0 z] = x [1 0 0] + y [0 1 0] + z [0 0 1] Basis Vectors Define three unit vectors along the axes: p = [1 0 0] q = [0 1 0] r = [0 0 1]. Then we can rewrite the axial displacement equation as v = xp +yq +zr p, q, r are known as basis vectors Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 35 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 36

7 Arbitrary Basis Vectors Can use any three linearly independent vectors p = [p x p y p z ] q = [q x q y q z ] r = [r x r y r z ] Linearly independent means that there do not exist scalars a,b,c such that: ap + bq + cr = 0 Orthonormal Basis Vectors Best to use an orthonormal basis Orthonormal means unit vectors that are pairwise orthogonal: p.q = q.r = r.p = 0 Otherwise things can get weird. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 37 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 38 Matrix From Basis Vectors What Does This Matrix Do? Construct a matrix M using p, q, r as the rows of the matrix: Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 39 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 40 Transformation by a Matrix If we interpret the rows of a matrix as the basis vectors of a coordinate space, then multiplication by the matrix performs a coordinate space transformation. If am = b, we say that vector a is transformed by the matrix M into vector b. Conversely See what M does to the original basis vectors [1 0 0], [0 1 0], [0 0 1]. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 41 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 42

8 Visualize The Matrix Each row of a matrix is a basis vector after transformation. Given an arbitrary matrix, visualize the transformation by its effect on the standard basis vectors the rows of the matrix. Given an arbitrary linear transformation, create the matrix by visualizing what it does to the standard basis vectors and using that for the rows of the matrix. 2D Matrix Example What does the following 2D matrix do? Extract the basis vectors (the rows of M) p = [2 1] q = [ 1,2] Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 43 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 44 What s the Transformation? It moves the unit axes [1, 0] and [0, 1] to the new axes. It does the same thing to all vectors. Visualize a box being transformed from one coordinate system to the other. This is called a skew box. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 45 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 46 Before After Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 47 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 48

9 So What Does It Do? 3D Transformation Example Rotates objects counterclockwise by a small amount. Scales them up by a factor of two. Before After Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 49 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 50 What s the Matrix? Get rows of matrix from new basis vectors. So what does it do? Rotates objects clockwise by 45. Scales them up along the y axis. Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 51 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 52 Constructing & Deconstructing Matrices By interpreting the rows of a matrix as basis vectors, we have a tool for deconstructing a matrix. But we also have a tool for constructing one! Given a desired transformation (e.g. rotation, scale, etc.), we can derive a matrix which represents that transformation. All we have to do is figure out what the transformation does to basis vectors, and then place those transformed basis vectors into the rows of a matrix. We'll use this tool repeatedly in Chapter 5 to derive the matrices to perform the linear basic transformations such as rotation, scale, shear, and reflection that we mentioned earlier. That concludes Chapter 4. Next, Chapter 5: Matrices and Linear Transformations Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 53 Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 54

10 What You ll See in This Chapter Chapter 5 Matrices & Linear Transforms Fletcher Dunn Valve Software Ian Parberry University of North Texas This chapter is concerned with expressing linear transformations in 3D using 3 3 matrices. It is divided roughly into two parts. In the first part, Sections , we take the basic tools from previous chapters to derive matrices for primitive linear transformations of rotation, scaling, orthographic projection, reflection, and shearing. The second part of this chapter returns to general principles of transformations. Section 5.6 shows how a sequence of primitive transformations may be combined using matrix multiplication to form a more complicated transformation. Section 5.7 discusses various interesting categories of transformations, including linear, affine, invertible, angle preserving, orthogonal, and rigid body transforms. 3D Math Primer for Graphics & Game Development Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 2 Word Cloud Section 5.1: Rotation Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 3 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 4 Reminder: Visualize The Matrix (Chapter 4) 2D Rotation Around Point Each row of a matrix is a basis vector after transformation. Given an arbitrary matrix, visualize the transformation by its effect on the standard basis vectors the rows of the matrix. Given an arbitrary linear transformation, create the matrix by visualizing what it does to the standard basis vectors and using that for the rows of the matrix. Before After From Chapter 4 Notes 3D Math Primer for Graphics & Game Dev 5 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 6

11 It s All About Rotating Basis Vectors! Construct Matrix from Basis Vectors Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 7 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 8 3D Rotation About Cardinal Axis 3D Rotate About x axis In 3D, rotation occurs about an axis rather than a point as in 2D. The most common type of rotation is a simple rotation about one of the cardinal axes. We'll need to establish which direction of rotation is positive and which is negative. We're going to obey the left hand rule for this (review Chapter 1). Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 9 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 10 Compare to 2D Case 3D Rotate About y axis Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 11 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 12

12 Compare to 2D Case 3D Rotate About z axis Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 13 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 14 Compare to 2D Case 3D Rotation About Noncardinal Axis We can also rotate about an arbitrary axis that passes through the origin. This is more complicated and less common than rotating about a cardinal axis. Game programmers worry less about this because rotation about an arbitrary axis can be expressed as a sum of rotations about cardinal axes (Euler). Details are left to the book. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 15 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 16 Scaling Along Cardinal Axes in 2D Section 5.2: Scale Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 17 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 18

13 Basis Vectors for Scale The basis vectors p and q are independently affected by the corresponding scale factors: 2D Scale Matrix Constructing the 2D scale matrix S(k x, k y ) from these basis vectors: Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 19 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 20 3D Scale Matrix Scale in Arbitrary Direction The math for scaling in an arbitrary direction is intricate, but not too tricky. For game programmers it is not used very often. Details again left to the book. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 21 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 22 Orthographic Projection Section 5.3: Orthographic Projection Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 23 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 24

14 Projecting Onto a Cardinal Axis Projection onto a cardinal axis or plane most frequently occurs not by actual transformation, but by simply discarding one of the dimensions while assigning the data into a variable of lesser dimension. For example, we may turn a 3D object into a 2D object by discarding the z components of the points and copying only x and y. However, we can also project onto a cardinal axis or plane by using a scale value of zero on the perpendicular axis. For completeness, we present the matrices for these transformations: Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 25 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 26 Reflection Section 5.4: Reflection Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 27 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 28 Reflection in 2D Reflection can be accomplished by applying a scale factor of 1. Let n be a 2D unit vector. The following matrix performs a reflection about the axis through the origin perpendicular to n: Reflection in 3D In 3D, we have a reflecting plane instead of an axis. The following matrix reflects about a plane through the origin perpendicular to the unit vector n: Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 29 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 30

15 Shearing Section 5.5: Shearing Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 31 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 32 Shearing in 2D Shearing is a transformation that skews the coordinate space, stretching it non uniformly. Angles are not preserved; however, surprisingly, areas and volumes are. The basic idea is to add a multiple of one coordinate to the other. For example, in 2D, we might take a multiple of y and add it to x, so that x' = x + sy. 2D Shear Matrices Let H x (s) be the shear matrix that shears the x coordinate by the other coordinate, y, by amount s. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 33 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 34 3D Shear Matrices 3D Shear Matrices In 3D, we can take one coordinate and add different multiples of that coordinate to the other two coordinates. The notation H xy indicates that the x and y coordinates are shifted by the other coordinate, z. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 35 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 36

16 Combining Transforms Section 5.6: Combining Transformations Transformation matrices are combined using matrix multiplication. One very common example of this is in rendering. Imagine there is an object at an arbitrary position and orientation in the world. We wish to render this object given a camera in any position and orientation. To do this, we must take the vertices of the object (assuming we are rendering some sort of triangle mesh) and transform them from object space into world space. This transform is known as the model transform, which we'll denote M obj wld From there, we transform world space vertices using the view transform, denoted M wld cam into camera space. The math involved is summarized on the next slide: Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 37 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 38 Render Matrix Example Since matrix multiplication is associative, Thus we can concatenate the matrices outside the loop, and only have one matrix multiplication inside the loop (remember there are many vertices): Geometric Interpretation So we see that matrix concatenation works from an algebraic perspective using the associative property of matrix multiplication. Let's see if we can't get a more geometric interpretation. Recall that that the rows of a matrix contain the basis vectors after transformation. This is true even in the case of multiple transformations. Notice that in the matrix product AB, each resulting row is the product of the corresponding row from A times the matrix B. Let the row vectors a 1, a 2, and a 3 stand for the rows of A. Then matrix multiplication can alternatively be written like this Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 39 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 40 Geometric Interpretation This makes it explicitly clear that the rows of the product of AB are actually the result of transforming the basis vectors in A by B. Classes of Transformations Linear transformations Affine transformations Invertible transformations Angle preserving transformations Orthogonal transformations Rigid body transformations Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 41 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 42

17 Disclaimer When we discuss transformations in general, we make use of the synonymous terms mapping or function. In the most general sense, a mapping is simply a rule that takes an input and produces an output. We denote that the mapping F maps a to b by writing F(a) = b. (Read F of a equals b. ) We are mostly interested in the transformations that can be expressed as matrix multiplication, but others are possible. In this section we use the determinant of a matrix. We're getting a bit ahead of ourselves, since we won't give a full explanation of determinants until Chapter 6. So for now, just know that that the determinant of a matrix is a scalar quantity that is very useful for making certain high level, shall we say, determinations about the matrix. Section 5.7: Classes of Transformations Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 43 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 44 Linear Transformations A mapping F(a) is linear if F(a + b) = F(a) + F(b) and F(ka) = kf(a). The mapping F(a) = am, where M is any square matrix, is a linear transformation, because matrix multiplication satisfies the equations in the first bullet point of this slide: F(a + b) = (a + b)m = am + bm = F(a) + F(b) F(ka) = (ka)m = k(am) = kf(a) The Zero Vector Any linear transformation will transform the zero vector into the zero vector. If F(0) = a and a 0, then F cannot be a linear transformation, since F(k0) = a and therefore F(k0) kf(0). Therefore: Any transformation that can be accomplished with matrix multiplication is a linear transformation. Linear transformations do not include translation. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 45 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 46 Caveats In some literature, a linear transformation is defined as one in which parallel lines remain parallel after transformation. This is almost completely accurate, with two exceptions. First, parallel lines remain parallel after translation, but translation is not a linear transformation. Second, what about projection? When a line is projected and becomes a single point, can we consider that point parallel to anything? Excluding these technicalities, the intuition is correct: a linear transformation may stretch things, but straight lines are not warped and parallel lines remain parallel. Affine Transformations An affine transformation is a linear transformation followed by translation. Thus, the set of affine transformations is a superset of the set of linear transformations: any linear transformation is an affine translation, but not all affine transformations are linear transformations. Since all of the transformations we discussed so far in this chapter are linear transformations, they are all also affine transformations. (Though none of them have a translation portion.) Any transformation of the form v' = vm + b is an affine transformation. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 47 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 48

18 Invertible Transformations A transformation is invertible if there exists an opposite transformation, known as the inverse of F, that undoes the original transformation. In other words, a mapping F(a) is invertible if there exists an inverse mapping F 1 such that for all a, F 1 (F(a)) = F(F 1 (a)) = a. This implies that F 1 is also invertible. There are non affine invertible transformations, but we will not consider them for the moment. Are All Affine Transforms Invertible? An affine transformation is a linear transformation followed by a translation. Obviously, we can always undo the translation portion by simply translating by the opposite amount. So the question becomes whether or not the linear transformation is invertible. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 49 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 50 Are All Linear Transforms Invertible? Intuitively, we know that all of the transformations other than projection can be undone if we rotate, scale, reflect, or skew, we can always unrotate, unscale, unreflect, or unskew. But when an object is projected, we effectively discard one or more dimensions worth of information, and this information cannot be recovered. Thus all of the primitive transformations other than projection are invertible. Are All Matrices Invertible? No. Since any linear transformation can be expressed as multiplication by a matrix, finding the inverse of a linear transformation is equivalent to finding the inverse of a matrix. We will discuss how to do this in Chapter 6. If the matrix has no inverse, we say that it is singular, and the transformation is non invertible. We can use a value called the determinant to determine whether a matrix is invertible. The determinant of an invertible matrix is nonzero. The determinant of a non invertible matrix is zero. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 51 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 52 Singularity and Square Matrices When a square matrix is singular, its basis vectors are not linearly independent. If the basis vectors are linearly independent, then it they have full rank, and coordinates of any given vector in the span are uniquely determined. If the vectors are linearly independent, then there is a portion of the space that is not in the span of the basis. This is known as the null space of the matrix. If we transform vectors in the null space using the matrix, many vectors will be projected into the same vector in the span of the basis, and we won't have any way to differentiate them. Angle Preserving Transformations A transformation is angle preserving if the angle between two vectors is not altered in either magnitude or direction after transformation. Only translation, rotation, and uniform scale are anglepreserving transformations. An angle preserving matrix preserves proportions. We do not consider reflection an angle preserving transformation because even though the magnitude of angle between two vectors is the same after transformation, the direction of angle may be inverted. All angle preserving transformations are affine and invertible. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 53 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 54

19 Orthogonal Transformations Orthogonal is a term that describes a matrix whose rows form an orthonormal basis the axes are perpendicular to each other and have unit length. Orthogonal transformations are interesting because it is easy to compute their inverse, and they arise frequently in practice. We will talk more about orthogonal matrices in Chapter 6. Translation, rotation, and reflection are the only orthogonal transformations. Orthogonal matrices preserve the magnitudes of angles, areas, and volumes, but possibly not the signs. The determinant of an orthogonal matrix is 1. All orthogonal transformations are affine and invertible. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 55 Rigid Body Transformations A rigid body transformation is one that changes the location and orientation of an object, but not its shape. All angles, lengths, areas, and volumes are preserved. Translation and rotation are the only rigid body transformations. Reflection is not considered a rigid body transformation. Rigid body transformations are also known as proper transformations. All rigid body transformations are orthogonal, angle preserving, invertible, and affine. Rigid body transforms are the most restrictive class of transforms discussed in this section, but they are also extremely common in practice. The determinant of a rigid body transformation matrix is 1. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 56 Transformation Summary Next That concludes Chapter 5: Matrices and Linear Transformations. Next will be Chapter 6: More on Matrices. Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 57 Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 58 That concludes Chapter 5. Next, Chapter 6: More on Matrices Chapter 5 Notes 3D Math Primer for Graphics & Game Dev 59

20 What You ll See in This Chapter Chapter 6 More on Matrices Fletcher Dunn Valve Software Ian Parberry University of North Texas This chapter completes our coverage of matrices by discussing a few more interesting and useful matrix operations. It is divided into five sections. Section 6.1 covers the determinant of a matrix. Section 6.2 covers the inverse of a matrix. Section 6.3 discusses orthogonal matrices. Section 6.4 introduces homogeneous vectors and 4 4 matrices, and shows how they can be used to perform affine transformations in 3D. Section 6.5 discusses perspective projection and shows how to do it with a 4 4 matrix. 3D Math Primer for Graphics & Game Development Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 2 Word Cloud Section 6.1: Determinant of a Matrix Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 3 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 4 Determinant 2 x 2 Example Determinant is defined for square matrices. Denoted M or det M. Determinant of a 2x2 matrix is Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 5 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 6

21 3 x 3 Determinant 3 x 3 Example Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 7 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 8 Triple Product If we interpret the rows of a 3x3 matrix as three vectors, then the determinant of the matrix is equivalent to the so called triple product of the three vectors: Minors Let M be an r x c matrix. Consider the matrix obtained by deleting row i and column j from M. This matrix will obviously be r 1 x c 1. The determinant of this submatrix, denoted M {ij} is known as a minor of M. For example, the minor M {12} is the determinant of the 2 x 2 matrix that is the result of deleting the 1st row and 2nd column from M: Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 9 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 10 Cofactors The cofactor of a square matrix M at a given row and column is the same as the corresponding minor, only every alternating minor is negated. We will use the notation C {12} to denote the cofactor of M in row i, column j. Use ( 1) (i+j) term to negate alternating minors. Negating Alternating Minors The ( 1) (i+j) term negates alternating minors in this pattern: Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 11 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 12

22 n x n Determinant The definition we will now consider expresses a determinant in terms of its cofactors. This definition is recursive, since cofactors are themselves signed determinants. First, we arbitrarily select a row or column from the matrix. Now, for each element in the row or column, we multiply this element by the corresponding cofactor. Summing these products yields the determinant of the matrix. n x n Determinant For example, arbitrarily selecting row i, the determinant can be computed by: Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 13 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 14 3 x 3 Determinant 4 x 4 Determinant Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 15 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 16 Expanding Cofactors This Equals Important Determinant Facts The identity matrix has determinant 1: I = 1. The determinant of a matrix product is equal to the product of the determinants: AB = A B. This extends to multiple matrices: M 1 M 2 M n 1 M n = M 1 M 2 M n 1 M n. The determinant of the transpose of a matrix is equal to the original. M T = M. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 17 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 18

23 Zero Row or Column If any row of column in a matrix contains all zeros, then the determinant of that matrix is zero. Exchanging Rows or Columns Exchanging any pair of rows or columns negates the determinant. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 19 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 20 Adding a Multiple of a Row or Column Adding any multiple of a row (or column) to another row (or column) does not change the value of the determinant. This explains why shear matrices from Chapter 5 have a determinant of 1. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 21 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 22 Geometric Interpretation 2 x 2 Determinant as Area In 2D, the determinant is equal to the signed area of the parallelogram or skew box that has the basis vectors as two sides. By signed area, we mean that the area is negative if the skew box is flipped relative to its original orientation. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 23 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 24

24 3 x 3 Determinant as Volume In 3D, the determinant is the volume of the parallelepiped that has the transformed basis vectors as three edges. It will be negative if the object is reflected (turned inside out) as a result of the transformation. Uses of the Determinant The determinant is related to the change in size that results from transforming by the matrix. The absolute value of the determinant is related to the change in area (in 2D) or volume (in 3D) that will occur as a result of transforming an object by the matrix. The determinant of the matrix can also be used to help classify the type of transformation represented by a matrix. If the determinant of a matrix is zero, then the matrix contains a projection. If the determinant of a matrix is negative, then the matrix contains a reflection. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 25 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 26 Inverse of a Matrix Section 6.2: Inverse of a Matrix The inverse of a square matrix M, denoted M 1 is the matrix such that when we multiply by M 1, the result is the identity matrix. M M 1 = M 1 M = I. Not all matrices have an inverse. An obvious example is a matrix with a row or column of zeros: no matter what you multiply this matrix by, you will end up with the zero matrix. If a matrix has an inverse, it is said to be invertible or non singular. A matrix that does not have an inverse is said to be non invertible or singular. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 27 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 28 Invertibility and Linear Independence For any invertible matrix M, the vector equality vm = 0 is true only when v = 0. Furthermore, the rows of an invertible matrix are linearly independent, as are the columns. The rows and columns of a singular matrix are linearly dependent. Determinant and Invertibility The determinant of a singular matrix is zero and the determinant of a non singular matrix is non zero. Checking the magnitude of the determinant is the most commonly used test for invertibility, because it's the easiest and quickest. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 29 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 30

25 The Classical Adjoint Our method for computing the inverse of a matrix is based on the classical adjoint. The classical adjoint of a matrix M, denoted adj M, is defined to be the transpose of the matrix of cofactors of M. For example, let: Computing the Cofactors Compute the cofactors of M: Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 31 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 32 Classical Adjoint of M The classical adjoint of M is the transpose of the matrix of cofactors: Back to the Inverse The inverse of a matrix is its classical adjoint divided by its determinant: M 1 = adj M / M. If the determinant is zero, the division is undefined, which jives with our earlier statement that matrices with a zero determinant are non invertible. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 33 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 34 Example of Matrix Inverse If: Gaussian Elimination There are other techniques that can be used to compute the inverse of a matrix, such as Gaussian elimination. Many linear algebra textbooks incorrectly assert that such techniques are better suited for implementation on a computer because they require fewer arithmetic operations. This is true for large matrices, or for matrices with a structure that can be exploited. However, for arbitrary matrices of smaller order like the 2 x 2, 3 x 3, and 4 x 4 used most often in geometric applications, the classical adjoint method is faster. The reason is that the classical adjoint method provides for a branchless implementation, meaning there are no if statements or loops that cannot be unrolled statically. This is a big win on today's superscalar architectures and vector processors. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 35 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 36

26 Facts About Matrix Inverse The inverse of the inverse of a matrix is the original matrix. If M is nonsingular, (M 1 ) 1 = M. The identity matrix is its own inverse: I 1 = I. Note that there are other matrices that are their own inverse, such as any reflection matrix, or a matrix that rotates 180 about any axis. The inverse of the transpose of a matrix is the transpose of the inverse: (M T ) 1 = (M 1 ) T More Facts About Matrix Inverse The inverse of a product is equal to the product of the inverses in reverse order. (AB) 1 = B 1 A 1 This extends to more than two matrices: (M 1 M 2 M n 1 M n ) 1 = M n 1 M n 1 1. M 2 1 M 1 1 The determinant of the inverse is the inverse of the determinant: M 1 = 1/ M. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 37 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 38 Geometric Interpretation of Inverse The inverse of a matrix is useful geometrically because it allows us to compute the reverse or opposite of a transformation a transformation that undoes another transformation if they are performed in sequence. So, if we take a vector v, transform it by a matrix M, and then transform it by the inverse M 1 of M, then we will get v back. We can easily verify this algebraically: (vm)m 1 = v(mm 1 ) = vi = v Section 6.3: Orthogonal Matrices Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 39 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 40 Orthogonal Matrices A square matrix M is orthogonal if and only if the product of the matrix and its transpose is the identity matrix: MM T = I. If a matrix is orthogonal, its transpose and the inverse are equal: M T = M 1. If we know that our matrix is orthogonal, we can essentially avoid computing the inverse, which is a relatively costly computation. For example, rotation and reflection matrices are orthogonal. Testing Orthogonality Let M be a 3 x 3 matrix. Let's see exactly what it means when MM T = I. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 41 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 42

27 9 Equations This gives us 9 equations, all of which must be true in order for M to be orthogonal: Consider the Rows Let the vectors r 1, r 2, r 3 stand for the rows of M: Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 43 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 44 9 Equations Using Dot Product Now we can re write the 9 equations more compactly: Two Observations First, the dot product of a vector with itself is 1 if and only if the vector is a unit vector. Therefore, the equations with a 1 on the right hand side of the equals sign will only be true when r 1, r 2, and r 3 are unit vectors. Second, the dot product of two vectors is 0 if and only if they are perpendicular. Therefore, the other six equations (with 0 on the right hand side of the equals sign) are true when r 1, r 2, and r 3 are mutually perpendicular. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 45 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 46 Conclusion So, for a matrix to be orthogonal, the following must be true: 1. Each row of the matrix must be a unit vector. 2. The rows of the matrix must be mutually perpendicular. Similar statements can be made regarding the columns of the matrix, since if M is orthogonal, then M T must be orthogonal. Orthonormal Bases Revisited Notice that these criteria are precisely those that we said in Chapter 3 were satisfied by an orthonormal set of basis vectors. There we also noted that an orthonormal basis was particularly useful because we could perform the opposite coordinate transform from the one that is always available, using the dot product. When we say that the transpose of an orthogonal matrix is its inverse, we are just restating this fact in the formal language of linear algebra. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 47 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 48

28 9 is Actually 6 Also notice that 3 of the orthogonality equations are duplicates (since dot product is commutative), and between these 9 equations, we actually have 6 constraints, leaving 3 degrees of freedom. This is interesting, since 3 is the number of degrees of freedom inherent in a rotation matrix. But again note that rotation matrices cannot compute a reflection, so there is slightly more freedom in the set of orthogonal matrices than in the set of orientations in 3D. Caveats When computing a matrix inverse we will usually only take advantage of orthogonality if we know a priori that a matrix is orthogonal. If we don't know in advance, it's probably a waste of time checking. Finally, even matrices which are orthogonal in the abstract may not be exactly orthogonal when represented in floating point, and so we must use tolerances, which have to be tuned. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 49 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 50 A Note on Terminology In linear algebra, we described a set of basis vectors as orthogonal if they are mutually perpendicular. It is not required that they have unit length. If they do have unit length, they are an orthonormal basis. Thus the rows and columns of an orthogonal matrix are orthonormal basis vectors. However, constructing a matrix from a set of orthogonal basis vectors does not necessarily result in an orthogonal matrix (unless the basis vectors are also orthonormal). Scary Monsters (Matrix Creep) Recall that that rotation matrices (and products of them) are orthogonal. Recall that the rows of an orthogonal matrix form an orthonormal basis. Or at least, that s the way we d like them to be. But the world is not perfect. Floating point numbers are subject to numerical instability. Aka matrix creep (apologies to David Bowie) We need to orthogonalize the matrix, resulting in a matrix that has mutually perpendicular unit vector axes and is (hopefully) as close to the original matrix as possible. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 51 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 52 Gramm Schmidt Orthogonalization Here s how to control matrix creep. Go through the rows of the matrix in order. For each, subtract off the component that is parallel to the other rows. More details: let r 1, r 2, r 3 be the rows of a 3 x 3 matrix M. Remember, you can also think of these as the x, y, and z axes of a coordinate space. Then an orthogonal set of row vectors, r 1, r 2, r 3 can be computed as follows: Steps 1 and 2 Step 1: Normalize r 1 to get a new vector r 1 (meaning make its magnitude 1) Step 2: Replace r 2 by r 2 = r 2 (r 1.r 2 ) r 1 r 2 is now perpendicular to r 1 because r 1.r 2 = r 1.(r 2 (r 1.r 2 ) r 1 ) = r 1.r 2 (r 1.r 2 )(r 1.r 1 ) = r 1.r 2 r 1.r 2 = 0 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 53 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 54

29 Steps 3, 4, and 5 Step 3: Normalize r 2 Step 4: Replace r 3 by r 3 = r 3 (r 1.r 3 ) r 1 (r 2.r 3 ) r 2 Step 5: Normalize r 3 Checking r 3 and r 1 r 3 is now perpendicular to r 1 because r 1.r 3 = r 1.(r 3 (r 1.r 3 ) r 1 (r 2.r 3 ) r 2 ) = r 1.r 3 (r 1.r 3 ) (r 1.r 1 ) (r 2.r 3 ) (r 1.r 2 ) = r 1.r 3 r 1.r 3 0 = 0 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 55 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 56 Checking r 3 and r 2 r 3 is now perpendicular to r 2 because r 2.r 3 = r 2.(r 3 (r 1.r 3 ) r 1 (r 2.r 3 ) r 2 ) = r 2.r 3 (r 1.r 3 ) (r 2.r 1 ) (r 2.r 3 ) (r 2.r 2 ) = r 2.r 3 0 r 2.r 3 = 0 Bias This is biased towards r 1, meaning that r 1 doesn t change but the other basis vectors do change. Option: instead of subtracting off the whole amount, subtract off a fraction of the original axis. Let k be a fraction say 1/4 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 57 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 58 Gramm Schmidt in Practice Step 1: normalize r 1, r 2, r 3 Step 2: repeat a dozen or so times: r 1 = r 1 k (r 1.r 2 ) r 2 k (r 1.r 3 ) r 3 r 2 = r 2 k (r 1.r 2 ) r 1 k (r 2.r 3 ) r 3 Section 6.3: 4 4 Homogenous Matrices r 3 = r 3 k (r 1.r 3 ) r 1 k (r 2.r 3 ) r 2 Step 3: Do a vanilla Gramm Schmidt to catch any remaining abnormality Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 59 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 60

30 Homogenous Coordinates Extend 3D into 4D. The 4 th dimension is not time. The 4 th dimension is really just a kluge to help the math work out (later in this lecture). The 4 th dimension is called w. Extending 1D into Homogenous Space Start with 1D, its easier to visualize than 3D. Homogenous 1D coords are of the form (x, w). Imagine the vanilla 1D line lying at w = 1. So the 1D point x has homogenous coords (x, 1). Given a homogenous point (x, w), the corresponding 1D point is its projection onto the line w = 1 along a line to the origin, which turns out to be (x/w, 1). Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 61 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 62 Projecting Onto 1D Space What are the 2D Coords of Homogenous Point (p,q)? Each point x in 1D space corresponds to an infinite number of points in homogenous space, those on the line from the origin through the point (x, 1). The homogenous points on this line project onto its intersection with the line w = 1. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 63 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 64 Simultaneous Equations Equation of line is w = ax + b (p, q) and (0, 0) are on the line. Therefore: q = ap + b 0 = a0 + b, That is, b = 0 and a = q/p. What is r? So equation of line is w = qx/p. Therefore, when w = 1, x = p/q. This means that r = p/q. So the homogenous point (p, q) projects onto the 1D point (p/q, 1). That is, the 1D equivalent of the homogenous point (p, q) is p/q. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 65 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 66

31 Extending 2D into Homogenous Space 2D next, it s still easier to visualize than 3D. Homogenous 2D coordinates are of the form (x, y, w). Imagine the vanilla 2D plane lying at w = 1. So the 2D point (x, y) has homogenous coordinates (x, y, 1). Projecting Onto 2D Space Each point (x, y) in 2D space corresponds to an infinite number of points in homogenous space. Those on the line from the origin thru (x, y, 1). The homogenous points on this line project onto its intersection with the plane w = 1. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 67 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 68 2D Homogenous Coordinates Just like before (argument omitted), the homogenous point (x, y, w) corresponds to the 2D point (x/w, y/w, 1). That is, the 2D equivalent of the homogenous point (p, q, r) is (p/r, q/r). Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 69 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 70 3D Homogenous Coordinates This extends to 3D in the obvious way. The homogenous point (x, y, z, w) corresponds to the 3D point (x/w, y/w, z/w, 1). That is, the 3D equivalent of the homogenous point (p, q, r, s) is (p/s, q/s, r/s). Point at Infinity w can be any value except 0 (divide by zero error). The point (x,y,z,0) can be viewed as a point at infinity Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 71 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 72

32 Why Use Homogenous Space? It will let us handle translation with a matrix transformation. Embed 3D space into homogenous space by basically ignoring the w component. Vector (x, y, z) gets replaced by (x, y, z, 1). Does that 1 at the end sound familiar? Homogenous Matrices Embed 3D transformation matrix into 4D matrix by using the identity in the w row and column. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 73 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 74 3D Matrix Multiplication 4D Matrix Multiplication Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 75 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 76 Translation Matrices Kluge 3D translation matrix by shearing 4D space. Translation vs. Orientation Just like in 3D, compose 4D operations by multiplying the corresponding matrices. The translation and orientation parts of a composite matrix are independent. For example, let R be a rotation matrix and T be a translation matrix. What does M = RT look like? Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 77 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 78

33 Rotate then Translate Then we could rotate and then translate a point v to a new point v using v = vrt. We are rotating first and then translating. The order of transformations is important, and since we use row vectors, the order of transformations coincides with the order that the matrices are multiplied, from left to right. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 79 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 80 M = RT Just as with 3 x 3 matrices, we can concatenate the two matrices into a single transformation matrix, which we'll call M. Let M = RT, so v = vrt = v(rt) = vm Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 81 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 82 In Reverse Applying this information in reverse, we can take a 4 x 4 matrix M and separate it into a linear transformation portion, and a translation portion. We can express this succinctly by letting the translation vector t =[Δx, Δy, Δz]. Points at Infinity Again Points at infinity are actually useful. They orient just like points with w 0: multiply by the orientation matrix. But they don t translate: translation matrices have no effect on them. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 83 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 84

34 Matrix Without Translation Matrix With Translation Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 85 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 86 So What? The translation part of 4D homogenous transformation matrices has no effect on points at infinity. Use points at infinity for things that don t need translating (eg. Surface normals). Use regular points (with w = 1) for things that do need translating (eg. Points that make up game objects). 4x3 Matrices The last column of 4D homogenous transformation matrices is always [0, 0, 0, 1] T. Technically it always needs to be there for the algebra to work out. But we know what it s going to do, so there s no reason to implement it in code. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 87 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 88 General Affine Transformations Armed with 4 x 4 transform matrices, we can now create more general affine transformations that contain translation. For example: Rotation about an axis that does not pass through the origin Scale about a plane that does not pass through the origin Reflection about a plane that does not pass through the origin Orthographic projection onto a plane that does not pass through the origin General Affine Transformations The basic idea is to translate the center of the transformation to the origin, perform the linear transformation using the techniques developed in Chapter 5, and then transform the center back to its original location. We will start with a translation matrix T that translates the point p to the origin, and a linear transform matrix R from Chapter 5 that performs the linear transformation. The final transformation matrix A will be the equal to the matrix product TRT 1. T 1 is of course the translation matrix with the opposite translation amount as T. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 89 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 90

35 Observation Thus, the extra translation in an affine transformation only changes the last row of the 4 x 4 matrix. The upper 3 x 3 portion, which contains the linear transformation, is not affected. Our use of homogenous coordinates so far has really been nothing more than a mathematical kludge to allow us to include translation in our transformations. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 91 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 92 Projections Section 6.4: 4 4 Matrices and Perspective Projection We ve only used w = 1 and w = 0 so far. There s a use for the other values of w too. We ve seen how to do orthographic projection before. Now we ll see how to do perspective projection too. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 93 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 94 Orthographic Projection Orthographic Projection Orthographic projection has parallel projectors. The projected image is the same size no matter how far the object is from the projection plane. We want objects to get smaller with distance. This is known as perspective foreshortening. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 95 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 96

36 Perspective Projection Perspective Foreshortening Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 97 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 98 The Pinhole Camera The math is based on a pinhole camera. Take a closed box that s very dark inside. Make a pinhole. If you point the pinhole at something bright, an image of the object will be projected onto the back of the box. That s kind of how the human eye works too. Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 99 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 100 Projection Geometry Let s project on a plane parallel to the x y plane. Choose a distance d from the pinhole to the projection plane, called the focal distance. The pinhole is called the focal point.. Put the focal point at the origin and the projection plane at z = d. (Remember the concept of camera space?) Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 101 Chapter 6 Notes 3D Math Primer for Graphics & Game Dev 102

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation Chapter 7 Introduction to Matrices This chapter introduces the theory and application of matrices. It is divided into two main sections. Section 7.1 discusses some of the basic properties and operations

More information

Vector Algebra Transformations. Lecture 4

Vector Algebra Transformations. Lecture 4 Vector Algebra Transformations Lecture 4 Cornell CS4620 Fall 2008 Lecture 4 2008 Steve Marschner 1 Geometry A part of mathematics concerned with questions of size, shape, and relative positions of figures

More information

Answers. Chapter 2. 1) Give the coordinates of the following points:

Answers. Chapter 2. 1) Give the coordinates of the following points: Answers Chapter 2 1) Give the coordinates of the following points: a (-2.5, 3) b (1, 2) c (2.5, 2) d (-1, 1) e (0, 0) f (2, -0.5) g (-0.5, -1.5) h (0, -2) j (-3, -2) 1 2) List the 48 different possible

More information

CT5510: Computer Graphics. Transformation BOCHANG MOON

CT5510: Computer Graphics. Transformation BOCHANG MOON CT5510: Computer Graphics Transformation BOCHANG MOON 2D Translation Transformations such as rotation and scale can be represented using a matrix M.., How about translation? No way to express this using

More information

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6 Math background 2D Geometric Transformations CS 4620 Lecture 6 Read: Chapter 2: Miscellaneous Math Chapter 5: Linear Algebra Notation for sets, functions, mappings Linear transformations Matrices Matrix-vector

More information

Linear Algebra Part I - Linear Spaces

Linear Algebra Part I - Linear Spaces Linear Algebra Part I - Linear Spaces Simon Julier Department of Computer Science, UCL S.Julier@cs.ucl.ac.uk http://moodle.ucl.ac.uk/course/view.php?id=11547 GV01 - Mathematical Methods, Algorithms and

More information

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices Computergrafik Matthias Zwicker Universität Bern Herbst 2008 Today Transformations & matrices Introduction Matrices Homogeneous Affine transformations Concatenating transformations Change of Common coordinate

More information

Geometric Transformations

Geometric Transformations Geometric Transformations CS 4620 Lecture 9 2017 Steve Marschner 1 A little quick math background Notation for sets, functions, mappings Linear and affine transformations Matrices Matrix-vector multiplication

More information

Multiple View Geometry in Computer Vision

Multiple View Geometry in Computer Vision Multiple View Geometry in Computer Vision Prasanna Sahoo Department of Mathematics University of Louisville 1 Projective 3D Geometry (Back to Chapter 2) Lecture 6 2 Singular Value Decomposition Given a

More information

2D transformations: An introduction to the maths behind computer graphics

2D transformations: An introduction to the maths behind computer graphics 2D transformations: An introduction to the maths behind computer graphics Lecturer: Dr Dan Cornford d.cornford@aston.ac.uk http://wiki.aston.ac.uk/dancornford CS2150, Computer Graphics, Aston University,

More information

2D/3D Geometric Transformations and Scene Graphs

2D/3D Geometric Transformations and Scene Graphs 2D/3D Geometric Transformations and Scene Graphs Week 4 Acknowledgement: The course slides are adapted from the slides prepared by Steve Marschner of Cornell University 1 A little quick math background

More information

Therefore, after becoming familiar with the Matrix Method, you will be able to solve a system of two linear equations in four different ways.

Therefore, after becoming familiar with the Matrix Method, you will be able to solve a system of two linear equations in four different ways. Grade 9 IGCSE A1: Chapter 9 Matrices and Transformations Materials Needed: Straightedge, Graph Paper Exercise 1: Matrix Operations Matrices are used in Linear Algebra to solve systems of linear equations.

More information

UNIT 2 2D TRANSFORMATIONS

UNIT 2 2D TRANSFORMATIONS UNIT 2 2D TRANSFORMATIONS Introduction With the procedures for displaying output primitives and their attributes, we can create variety of pictures and graphs. In many applications, there is also a need

More information

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE528 Computer Graphics: Theory, Algorithms, and Applications CSE528 Computer Graphics: Theory, Algorithms, and Applications Hong Qin Stony Brook University (SUNY at Stony Brook) Stony Brook, New York 11794-2424 Tel: (631)632-845; Fax: (631)632-8334 qin@cs.stonybrook.edu

More information

Introduction to Homogeneous coordinates

Introduction to Homogeneous coordinates Last class we considered smooth translations and rotations of the camera coordinate system and the resulting motions of points in the image projection plane. These two transformations were expressed mathematically

More information

Vector Calculus: Understanding the Cross Product

Vector Calculus: Understanding the Cross Product University of Babylon College of Engineering Mechanical Engineering Dept. Subject : Mathematics III Class : 2 nd year - first semester Date: / 10 / 2016 2016 \ 2017 Vector Calculus: Understanding the Cross

More information

CSE328 Fundamentals of Computer Graphics

CSE328 Fundamentals of Computer Graphics CSE328 Fundamentals of Computer Graphics Hong Qin State University of New York at Stony Brook (Stony Brook University) Stony Brook, New York 794--44 Tel: (63)632-845; Fax: (63)632-8334 qin@cs.sunysb.edu

More information

AH Matrices.notebook November 28, 2016

AH Matrices.notebook November 28, 2016 Matrices Numbers are put into arrays to help with multiplication, division etc. A Matrix (matrices pl.) is a rectangular array of numbers arranged in rows and columns. Matrices If there are m rows and

More information

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52 cs337 It looks like a matrix Sort of Viewing III Projection in Practice / 52 cs337 Arbitrary 3D views Now that we have familiarity with terms we can say that these view volumes/frusta can be specified

More information

PetShop (BYU Students, SIGGRAPH 2006)

PetShop (BYU Students, SIGGRAPH 2006) Now Playing: PetShop (BYU Students, SIGGRAPH 2006) My Mathematical Mind Spoon From Gimme Fiction Released May 10, 2005 Geometric Objects in Computer Graphics Rick Skarbez, Instructor COMP 575 August 30,

More information

Overview. By end of the week:

Overview. By end of the week: Overview By end of the week: - Know the basics of git - Make sure we can all compile and run a C++/ OpenGL program - Understand the OpenGL rendering pipeline - Understand how matrices are used for geometric

More information

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations CS559 Lecture Polygons, Transformations These are course notes (not used as slides) Written by Mike Gleicher, Oct. 005 With some slides adapted from the notes of Stephen Chenney Final version (after class)

More information

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation and the type of an object. Even simple scaling turns a

More information

Graphics and Interaction Transformation geometry and homogeneous coordinates

Graphics and Interaction Transformation geometry and homogeneous coordinates 433-324 Graphics and Interaction Transformation geometry and homogeneous coordinates Department of Computer Science and Software Engineering The Lecture outline Introduction Vectors and matrices Translation

More information

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates Department of Computer Science and Software Engineering The Lecture outline Introduction Vectors and matrices Translation

More information

(Refer Slide Time: 00:04:20)

(Refer Slide Time: 00:04:20) Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 8 Three Dimensional Graphics Welcome back all of you to the lectures in Computer

More information

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms Chapter IV Spaces and Transforms Scaling 2D scaling with the scaling factors, s x and s y, which are independent. Examples When a polygon is scaled, all of its vertices are processed by the same scaling

More information

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T Copyright 2018 Sung-eui Yoon, KAIST freely available on the internet http://sglab.kaist.ac.kr/~sungeui/render

More information

CS354 Computer Graphics Rotations and Quaternions

CS354 Computer Graphics Rotations and Quaternions Slide Credit: Don Fussell CS354 Computer Graphics Rotations and Quaternions Qixing Huang April 4th 2018 Orientation Position and Orientation The position of an object can be represented as a translation

More information

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations 3D Mathematics Co-ordinate systems, 3D primitives and affine transformations Coordinate Systems 2 3 Primitive Types and Topologies Primitives Primitive Types and Topologies 4 A primitive is the most basic

More information

What You ll See in This Chapter. Word Cloud. René Descartes. Introduction. Ian Parberry University of North Texas. Fletcher Dunn

What You ll See in This Chapter. Word Cloud. René Descartes. Introduction. Ian Parberry University of North Texas. Fletcher Dunn What You ll See in This Chapter Chapter 1: Cartesian Coordinate Systems Fletcher Dunn Valve Software Ian Parberry University of North Texas This chapter describes the basic concepts of 3D math. It is divided

More information

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects Object Representation Affine Transforms Polygonal Representation of Objects Although perceivable the simplest form of representation they can also be the most problematic. To represent an object polygonally,

More information

Transforms. COMP 575/770 Spring 2013

Transforms. COMP 575/770 Spring 2013 Transforms COMP 575/770 Spring 2013 Transforming Geometry Given any set of points S Could be a 2D shape, a 3D object A transform is a function T that modifies all points in S: T S S T v v S Different transforms

More information

GEOMETRIC TRANSFORMATIONS AND VIEWING

GEOMETRIC TRANSFORMATIONS AND VIEWING GEOMETRIC TRANSFORMATIONS AND VIEWING 2D and 3D 1/44 2D TRANSFORMATIONS HOMOGENIZED Transformation Scaling Rotation Translation Matrix s x s y cosθ sinθ sinθ cosθ 1 dx 1 dy These 3 transformations are

More information

0_PreCNotes17 18.notebook May 16, Chapter 12

0_PreCNotes17 18.notebook May 16, Chapter 12 Chapter 12 Notes BASIC MATRIX OPERATIONS Matrix (plural: Matrices) an n x m array of elements element a ij Example 1 a 21 = a 13 = Multiply Matrix by a Scalar Distribute scalar to all elements Addition

More information

2D and 3D Transformations AUI Course Denbigh Starkey

2D and 3D Transformations AUI Course Denbigh Starkey 2D and 3D Transformations AUI Course Denbigh Starkey. Introduction 2 2. 2D transformations using Cartesian coordinates 3 2. Translation 3 2.2 Rotation 4 2.3 Scaling 6 3. Introduction to homogeneous coordinates

More information

Last week. Machiraju/Zhang/Möller/Fuhrmann

Last week. Machiraju/Zhang/Möller/Fuhrmann Last week Machiraju/Zhang/Möller/Fuhrmann 1 Geometry basics Scalar, point, and vector Vector space and affine space Basic point and vector operations Sided-ness test Lines, planes, and triangles Linear

More information

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting Ray Casting COMP 175: Computer Graphics April 26, 2018 1/41 Admin } Assignment 4 posted } Picking new partners today for rest of the assignments } Demo in the works } Mac demo may require a new dylib I

More information

Monday, 12 November 12. Matrices

Monday, 12 November 12. Matrices Matrices Matrices Matrices are convenient way of storing multiple quantities or functions They are stored in a table like structure where each element will contain a numeric value that can be the result

More information

CHAPTER 5 SYSTEMS OF EQUATIONS. x y

CHAPTER 5 SYSTEMS OF EQUATIONS. x y page 1 of Section 5.1 CHAPTER 5 SYSTEMS OF EQUATIONS SECTION 5.1 GAUSSIAN ELIMINATION matrix form of a system of equations The system 2x + 3y + 4z 1 5x + y + 7z 2 can be written as Ax where b 2 3 4 A [

More information

Specifying Complex Scenes

Specifying Complex Scenes Transformations Specifying Complex Scenes (x,y,z) (r x,r y,r z ) 2 (,,) Specifying Complex Scenes Absolute position is not very natural Need a way to describe relative relationship: The lego is on top

More information

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016 Lecture 4: Transforms Computer Graphics CMU 15-462/15-662, Fall 2016 Brief recap from last class How to draw a triangle - Why focus on triangles, and not quads, pentagons, etc? - What was specific to triangles

More information

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES YINGYING REN Abstract. In this paper, the applications of homogeneous coordinates are discussed to obtain an efficient model

More information

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7 MODULE - 7 e-pg Pathshala Subject: Computer Science Paper: Computer Graphics and Visualization Module: Other 2D Transformations Module No: CS/CGV/7 Quadrant e-text Objectives: To get introduced to the

More information

Computer Vision Projective Geometry and Calibration. Pinhole cameras

Computer Vision Projective Geometry and Calibration. Pinhole cameras Computer Vision Projective Geometry and Calibration Professor Hager http://www.cs.jhu.edu/~hager Jason Corso http://www.cs.jhu.edu/~jcorso. Pinhole cameras Abstract camera model - box with a small hole

More information

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects Mathematics 308 Geometry Chapter 9. Drawing three dimensional objects In this chapter we will see how to draw three dimensional objects with PostScript. The task will be made easier by a package of routines

More information

INTRODUCTION TO COMPUTER GRAPHICS. cs123. It looks like a matrix Sort of. Viewing III. Projection in Practice 1 / 52

INTRODUCTION TO COMPUTER GRAPHICS. cs123. It looks like a matrix Sort of. Viewing III. Projection in Practice 1 / 52 It looks like a matrix Sort of Viewing III Projection in Practice 1 / 52 Arbitrary 3D views } view volumes/frusta spec d by placement and shape } Placement: } Position (a point) } look and up vectors }

More information

To Do. Outline. Translation. Homogeneous Coordinates. Foundations of Computer Graphics. Representation of Points (4-Vectors) Start doing HW 1

To Do. Outline. Translation. Homogeneous Coordinates. Foundations of Computer Graphics. Representation of Points (4-Vectors) Start doing HW 1 Foundations of Computer Graphics Homogeneous Coordinates Start doing HW 1 To Do Specifics of HW 1 Last lecture covered basic material on transformations in 2D Likely need this lecture to understand full

More information

Game Engineering CS S-05 Linear Transforms

Game Engineering CS S-05 Linear Transforms Game Engineering CS420-2016S-05 Linear Transforms David Galles Department of Computer Science University of San Francisco 05-0: Matrices as Transforms Recall that Matrices are transforms Transform vectors

More information

CS 4204 Computer Graphics

CS 4204 Computer Graphics CS 4204 Computer Graphics 3D Viewing and Projection Yong Cao Virginia Tech Objective We will develop methods to camera through scenes. We will develop mathematical tools to handle perspective projection.

More information

Basics of Computational Geometry

Basics of Computational Geometry Basics of Computational Geometry Nadeem Mohsin October 12, 2013 1 Contents This handout covers the basic concepts of computational geometry. Rather than exhaustively covering all the algorithms, it deals

More information

CS251 Spring 2014 Lecture 7

CS251 Spring 2014 Lecture 7 CS251 Spring 2014 Lecture 7 Stephanie R Taylor Feb 19, 2014 1 Moving on to 3D Today, we move on to 3D coordinates. But first, let s recap of what we did in 2D: 1. We represented a data point in 2D data

More information

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations Graphics 2009/2010, period 1 Lecture 5 Linear and affine transformations Vector transformation: basic idea Definition Examples Finding matrices Compositions of transformations Transposing normal vectors

More information

Epipolar Geometry and the Essential Matrix

Epipolar Geometry and the Essential Matrix Epipolar Geometry and the Essential Matrix Carlo Tomasi The epipolar geometry of a pair of cameras expresses the fundamental relationship between any two corresponding points in the two image planes, and

More information

IntroductionToRobotics-Lecture02

IntroductionToRobotics-Lecture02 IntroductionToRobotics-Lecture02 Instructor (Oussama Khatib):Okay. Let's get started. So as always, the lecture starts with a video segment, and today's video segment comes from 1991, and from the group

More information

Game Engineering: 2D

Game Engineering: 2D Game Engineering: 2D CS420-2010F-07 Objects in 2D David Galles Department of Computer Science University of San Francisco 07-0: Representing Polygons We want to represent a simple polygon Triangle, rectangle,

More information

CS452/552; EE465/505. Geometry Transformations

CS452/552; EE465/505. Geometry Transformations CS452/552; EE465/505 Geometry Transformations 1-26-15 Outline! Geometry: scalars, points & vectors! Transformations Read: Angel, Chapter 4 (study cube.html/cube.js example) Appendix B: Spaces (vector,

More information

3D Game Engine Programming. Understanding Quaternions. Helping you build your dream game engine. Posted on June 25, 2012 by Jeremiah van Oosten

3D Game Engine Programming. Understanding Quaternions. Helping you build your dream game engine. Posted on June 25, 2012 by Jeremiah van Oosten 3D Game Engine Programming Helping you build your dream game engine. Understanding Quaternions Posted on June 25, 2012 by Jeremiah van Oosten Understanding Quaternions In this article I will attempt to

More information

Game Engineering CS S-07 Homogenous Space and 4x4 Matrices

Game Engineering CS S-07 Homogenous Space and 4x4 Matrices Game Engineering CS420-2014S-07 Homogenous Space and 4x4 Matrices David Galles Department of Computer Science University of San Francisco 07-0: Matrices and Translations Matrices are great for rotations,

More information

MAT 003 Brian Killough s Instructor Notes Saint Leo University

MAT 003 Brian Killough s Instructor Notes Saint Leo University MAT 003 Brian Killough s Instructor Notes Saint Leo University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment Notes on Assignment Notes on Assignment Objects on screen - made of primitives Primitives are points, lines, polygons - watch vertex ordering The main object you need is a box When the MODELVIEW matrix

More information

Hello, welcome to the video lecture series on Digital Image Processing. So in today's lecture

Hello, welcome to the video lecture series on Digital Image Processing. So in today's lecture Digital Image Processing Prof. P. K. Biswas Department of Electronics and Electrical Communications Engineering Indian Institute of Technology, Kharagpur Module 02 Lecture Number 10 Basic Transform (Refer

More information

3D Viewing. CS 4620 Lecture 8

3D Viewing. CS 4620 Lecture 8 3D Viewing CS 46 Lecture 8 13 Steve Marschner 1 Viewing, backward and forward So far have used the backward approach to viewing start from pixel ask what part of scene projects to pixel explicitly construct

More information

Lecture 4. Viewing, Projection and Viewport Transformations

Lecture 4. Viewing, Projection and Viewport Transformations Notes on Assignment Notes on Assignment Hw2 is dependent on hw1 so hw1 and hw2 will be graded together i.e. You have time to finish both by next monday 11:59p Email list issues - please cc: elif@cs.nyu.edu

More information

Visual Recognition: Image Formation

Visual Recognition: Image Formation Visual Recognition: Image Formation Raquel Urtasun TTI Chicago Jan 5, 2012 Raquel Urtasun (TTI-C) Visual Recognition Jan 5, 2012 1 / 61 Today s lecture... Fundamentals of image formation You should know

More information

XPM 2D Transformations Week 2, Lecture 3

XPM 2D Transformations Week 2, Lecture 3 CS 430/585 Computer Graphics I XPM 2D Transformations Week 2, Lecture 3 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory Department of Computer Science Drexel

More information

CMSC 425: Lecture 6 Affine Transformations and Rotations

CMSC 425: Lecture 6 Affine Transformations and Rotations CMSC 45: Lecture 6 Affine Transformations and Rotations Affine Transformations: So far we have been stepping through the basic elements of geometric programming. We have discussed points, vectors, and

More information

Transformations. Questions on Assignment 1? Announcements

Transformations. Questions on Assignment 1? Announcements Announcements Is your account working yet? Watch out for ^M and missing newlines Assignment 1 is due next Thursday at midnight Check the webpage and newsgroup for answers to questions about the assignment

More information

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z Basic Linear Algebra Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ 1 5 ] 7 9 3 11 Often matrices are used to describe in a simpler way a series of linear equations.

More information

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline Computergrafik Today Rendering pipeline s View volumes, clipping Viewport Matthias Zwicker Universität Bern Herbst 2008 Rendering pipeline Rendering pipeline Hardware & software that draws 3D scenes on

More information

DRAFT: Mathematical Background for Three-Dimensional Computer Graphics. Jonathan R. Senning Gordon College

DRAFT: Mathematical Background for Three-Dimensional Computer Graphics. Jonathan R. Senning Gordon College DRAFT: Mathematical Background for Three-Dimensional Computer Graphics Jonathan R. Senning Gordon College September 2006 ii Contents Introduction 2 Affine Geometry 3 2. Affine Space...................................

More information

To do this the end effector of the robot must be correctly positioned relative to the work piece.

To do this the end effector of the robot must be correctly positioned relative to the work piece. Spatial Descriptions and Transformations typical robotic task is to grasp a work piece supplied by a conveyer belt or similar mechanism in an automated manufacturing environment, transfer it to a new position

More information

Viewing and Projection

Viewing and Projection 15-462 Computer Graphics I Lecture 5 Viewing and Projection Shear Transformation Camera Positioning Simple Parallel Projections Simple Perspective Projections [Angel, Ch. 5.2-5.4] January 30, 2003 [Red

More information

Catalan Numbers. Table 1: Balanced Parentheses

Catalan Numbers. Table 1: Balanced Parentheses Catalan Numbers Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 00 We begin with a set of problems that will be shown to be completely equivalent. The solution to each problem

More information

XPM 2D Transformations Week 2, Lecture 3

XPM 2D Transformations Week 2, Lecture 3 CS 430/585 Computer Graphics I XPM 2D Transformations Week 2, Lecture 3 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory Department of Computer Science Drexel

More information

Homework 5: Transformations in geometry

Homework 5: Transformations in geometry Math 21b: Linear Algebra Spring 2018 Homework 5: Transformations in geometry This homework is due on Wednesday, February 7, respectively on Thursday February 8, 2018. 1 a) Find the reflection matrix at

More information

Transforms 1 Christian Miller CS Fall 2011

Transforms 1 Christian Miller CS Fall 2011 Transforms 1 Christian Miller CS 354 - Fall 2011 Transformations What happens if you multiply a square matrix and a vector together? You get a different vector with the same number of coordinates These

More information

An idea which can be used once is a trick. If it can be used more than once it becomes a method

An idea which can be used once is a trick. If it can be used more than once it becomes a method An idea which can be used once is a trick. If it can be used more than once it becomes a method - George Polya and Gabor Szego University of Texas at Arlington Rigid Body Transformations & Generalized

More information

Lecture 3: Linear Classification

Lecture 3: Linear Classification Lecture 3: Linear Classification Roger Grosse 1 Introduction Last week, we saw an example of a learning task called regression. There, the goal was to predict a scalar-valued target from a set of features.

More information

Parallel and perspective projections such as used in representing 3d images.

Parallel and perspective projections such as used in representing 3d images. Chapter 5 Rotations and projections In this chapter we discuss Rotations Parallel and perspective projections such as used in representing 3d images. Using coordinates and matrices, parallel projections

More information

Unit 1, Lesson 1: Moving in the Plane

Unit 1, Lesson 1: Moving in the Plane Unit 1, Lesson 1: Moving in the Plane Let s describe ways figures can move in the plane. 1.1: Which One Doesn t Belong: Diagrams Which one doesn t belong? 1.2: Triangle Square Dance m.openup.org/1/8-1-1-2

More information

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL Chapter 5 Geometric Transformations Somsak Walairacht, Computer Engineering, KMITL 1 Outline Basic Two-Dimensional Geometric Transformations Matrix Representations and Homogeneous Coordinates Inverse Transformations

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

CS231A Course Notes 4: Stereo Systems and Structure from Motion

CS231A Course Notes 4: Stereo Systems and Structure from Motion CS231A Course Notes 4: Stereo Systems and Structure from Motion Kenji Hata and Silvio Savarese 1 Introduction In the previous notes, we covered how adding additional viewpoints of a scene can greatly enhance

More information

Equations of planes in

Equations of planes in Roberto s Notes on Linear Algebra Chapter 6: Lines, planes and other straight objects Section Equations of planes in What you need to know already: What vectors and vector operations are. What linear systems

More information

An Interesting Way to Combine Numbers

An Interesting Way to Combine Numbers An Interesting Way to Combine Numbers Joshua Zucker and Tom Davis October 12, 2016 Abstract This exercise can be used for middle school students and older. The original problem seems almost impossibly

More information

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space Basic Elements Geometry is the study of the relationships among objects in an n-dimensional space In computer graphics, we are interested in objects that exist in three dimensions We want a minimum set

More information

Orientation & Quaternions

Orientation & Quaternions Orientation & Quaternions Orientation Position and Orientation The position of an object can be represented as a translation of the object from the origin The orientation of an object can be represented

More information

1.8 Composition of Transformations

1.8 Composition of Transformations 1.8. Composition of Transformations www.ck12.org 1.8 Composition of Transformations Here you ll learn how to perform a composition of transformations. You ll also learn some common composition of transformations.

More information

Game Mathematics. (12 Week Lesson Plan)

Game Mathematics. (12 Week Lesson Plan) Game Mathematics (12 Week Lesson Plan) Lesson 1: Set Theory Textbook: Chapter One (pgs. 1 15) We begin the course by introducing the student to a new vocabulary and set of rules that will be foundational

More information

COSC579: Scene Geometry. Jeremy Bolton, PhD Assistant Teaching Professor

COSC579: Scene Geometry. Jeremy Bolton, PhD Assistant Teaching Professor COSC579: Scene Geometry Jeremy Bolton, PhD Assistant Teaching Professor Overview Linear Algebra Review Homogeneous vs non-homogeneous representations Projections and Transformations Scene Geometry The

More information

MA 1128: Lecture 02 1/22/2018

MA 1128: Lecture 02 1/22/2018 MA 1128: Lecture 02 1/22/2018 Exponents Scientific Notation 1 Exponents Exponents are used to indicate how many copies of a number are to be multiplied together. For example, I like to deal with the signs

More information

1 Affine and Projective Coordinate Notation

1 Affine and Projective Coordinate Notation CS348a: Computer Graphics Handout #9 Geometric Modeling Original Handout #9 Stanford University Tuesday, 3 November 992 Original Lecture #2: 6 October 992 Topics: Coordinates and Transformations Scribe:

More information

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52 Computer Graphics Three-Dimensional Graphics I Guoying Zhao 1 / 52 Geometry Guoying Zhao 2 / 52 Objectives Introduce the elements of geometry Scalars Vectors Points Develop mathematical operations among

More information

A point is pictured by a dot. While a dot must have some size, the point it represents has no size. Points are named by capital letters..

A point is pictured by a dot. While a dot must have some size, the point it represents has no size. Points are named by capital letters.. Chapter 1 Points, Lines & Planes s we begin any new topic, we have to familiarize ourselves with the language and notation to be successful. My guess that you might already be pretty familiar with many

More information

Section III: TRANSFORMATIONS

Section III: TRANSFORMATIONS Section III: TRANSFORMATIONS in 2-D 2D TRANSFORMATIONS AND MATRICES Representation of Points: 2 x 1 matrix: X Y General Problem: [B] = [T] [A] [T] represents a generic operator to be applied to the points

More information

Chapter 2: Number Systems

Chapter 2: Number Systems Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

More information

3D Geometry and Camera Calibration

3D Geometry and Camera Calibration 3D Geometry and Camera Calibration 3D Coordinate Systems Right-handed vs. left-handed x x y z z y 2D Coordinate Systems 3D Geometry Basics y axis up vs. y axis down Origin at center vs. corner Will often

More information

MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review.

MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review. MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review. 1. The intersection of two non-parallel planes is a line. Find the equation of the line. Give

More information

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9 3D Viewing CS 46 Lecture 9 Cornell CS46 Spring 18 Lecture 9 18 Steve Marschner 1 Viewing, backward and forward So far have used the backward approach to viewing start from pixel ask what part of scene

More information