CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.

Slides:



Advertisements
Similar presentations
Points, Vectors, Lines, Spheres and Matrices
Advertisements

CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
Further Pure 1 Matrices Introduction. Definitions A matrix is just a rectangle of numbers. It’s a bit like a two-way table. You meet this concept in D1.
Matrix Algebra Matrix algebra is a means of expressing large numbers of calculations made upon ordered sets of numbers. Often referred to as Linear Algebra.
Mathematics. Matrices and Determinants-1 Session.
3_3 An Useful Overview of Matrix Algebra
Maths for Computer Graphics
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Lecture # 9 Matrix Representation of Symmetry Groups
Review of Matrix Algebra
MOHAMMAD IMRAN DEPARTMENT OF APPLIED SCIENCES JAHANGIRABAD EDUCATIONAL GROUP OF INSTITUTES.
Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
Matrices and Determinants
Lecture 7: Matrix-Vector Product; Matrix of a Linear Transformation; Matrix-Matrix Product Sections 2.1, 2.2.1,
Intro to Matrices Don’t be scared….
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
Basics of Linear Algebra A review?. Matrix  Mathematical term essentially corresponding to an array  An arrangement of numbers into rows and columns.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 2: Review of Basic Math
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices.
Mathematical Fundamentals
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
ECON 1150 Matrix Operations Special Matrices
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformations Dr. Amy Zhang.
Mathematics for Computer Graphics. Lecture Summary Matrices  Some fundamental operations Vectors  Some fundamental operations Geometric Primitives:
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 : “shiv rpi” Linear Algebra A gentle introduction Linear Algebra has become as basic and as applicable.
1 What you will learn  We need to review several concepts from Algebra II: Solving a system of equations graphically Solving a system of equations algebraically.
1 CO Games Concepts Week 20 Matrices continued Gareth Bellaby.
Lecture 7 Matrices CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Matrices A matrix is a table or array of numbers arranged in rows and columns The order of a matrix is given by stating its dimensions. This is known as.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Prepared by Deluar Jahan Moloy Lecturer Northern University Bangladesh
Fundamentals of Engineering Analysis
Matrices A matrix is an array of numbers, the size of which is described by its dimensions: An n x m matrix has n rows and m columns Eg write down the.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
1 Graphics CSCI 343, Fall 2015 Lecture 10 Coordinate Transformations.
Chapter 2 … part1 Matrices Linear Algebra S 1. Ch2_2 2.1 Addition, Scalar Multiplication, and Multiplication of Matrices Definition A matrix is a rectangular.
3.4 Solution by Matrices. What is a Matrix? matrix A matrix is a rectangular array of numbers.
Computer Graphics Matrices
Matrices and Determinants
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Mathematics Medicine What is meant by a matrix A matrix is a set of numbers arranged in the form of a rectangle and enclosed in curved brackets.
Graphics Graphics Korea University kucg.korea.ac.kr Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Lecture 1 Linear algebra Vectors, matrices. Linear algebra Encyclopedia Britannica:“a branch of mathematics that is concerned with mathematical structures.
MTH108 Business Math I Lecture 20.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
CO1301: Games ts 2015 Lecture 6 Vectors Dr Nick Mitchell (Room CM 224)
Math Fundamentals Maths revisit.
Transforms.
Linear Algebra Lecture 2.
Chapter 7 Matrix Mathematics
ECON 213 Elements of Mathematics for Economists
L6 matrix operations.
COMP 175: Computer Graphics February 9, 2016
2.2 Introduction to Matrices
Basics of Linear Algebra
Linear Algebra A gentle introduction
MATRICES MATRIX OPERATIONS.
MATRICES MATRIX OPERATIONS.
Presentation transcript:

CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby Lecture 12 Matrices

Reading  Rabin, Introduction to Game Development:  4.1: "Mathematical Concepts"  Van Verthe, Essential Mathematics for Games:  Chapter 2: "Linear Transformations and Matrices"  Chapter 3: "Affine Transformations".  Frank Luna, Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach  Chapter 2: "Matrix Algebra"  Wendy Stahler, Fundamentals of Math and Physcis for Games Programmers, Pearson, Prentice Hall, 2006.

Model Positioning Reminder  Each model has three axes definied: x, y and z.  The axes of the model are local to the model.  The axes are relative to the origin of the model,  i.e. ( 0, 0, 0 ).  Each model also has a position.  The position is in world coordinates.  The position is the location of its local origin.

3D Models in graphics  Recorded as a 4x4 matrix. x-axis y-axis z-axis position

Matrices  Singular: matrix  Plural: matrices  A matrix is a rectangular table of numbers.  A matrix is composed of rows and columns.

Why are matrices important?  A console typically runs at 30 frames per second. A PC game may run at 60 frames per second.  You therefore only have something in the region of between to of a second to perform all of the operations you need to carry out for the game. This includes AI, game logic, physics and, of course, updating and rendering the scene.  Computer games need to be efficient.  Matrices are efficient.

Why are matrices important?  Matrices are an essential part of graphics.  Transformations are carried out using matrices.  Matrices are a key element of linear algebra and hence of computer graphics.  A single matrix can express a complex transformation.  For example, a single matrix can rotate a model in all 3 axes simultaneously, whilst at the same time moving and scaling.  Matrices can be combined together.  The resulting matrix will perform all of the operations of the individual matrices but in one single mathematical operation.

Rendering a model  How is a model rendered on the screen?  A model is made up of polygons. In practice these are triangles.  A triangle is stored using the coordinates of each of its 3 points - the vertices.  (e.g. look at an.x file for vertex lists).  The coordinates of the vertices are in local space- relative to the origin of the model.  Another way of saying this is that the coordinates of the vertices of the triangles are in model space.  The model is also rotated - along 3 different axis.

Rendering a model  So...  Every vertex needs to be transformed into world space (3 rotations, a transformation, possibly scaling).  The screen is 2D...  The model needs projecting from 3D into 2D.  The camera has an imaginary screen somewhere in front of it. The model (now in world coordinates) is converted from 3D space into the 2D space of the screen. The model is projected onto this screen.

Transformation  When you have a go with DirectX over summer you will see that matrices are used to perform this transformation: the world, view and projection matrices.  You will also see that the matrices can be combined into a single matrix that carries out all of the maths in one operation.  There are calls within DirectX to do all of the operations.  You need to understand the background.  You also need to understand the maths because some of the more interesting graphics requires other types of matrix operations.

Matrices  Most important thing to remember with matrices is:  Row - Column  First manifestation of row-column is the size the matrix. You write the numbers of rows first and the number of columns second.  So a 2x3 matrix is composed of 2 rows and 3 columns.

Matrix Sizes  Rows by columns. 2x3: 3x2: 3x1: 1x3: 4x4:

Matrix Addition  Matrices can be summed together.  Addition is done component by component (the same way as vectors).  This only works if the matrices are the same size.

Matrix Addition

 Subtraction is identical to addition.

Scalar multiplication  Scalar multiplication is simply when each component of a matrix is multiplied by a single value, in effect scaling it.

Matrix Multiplication  Matrices can be multiplied together.  Remember with matrices:  Row - Column  The second manifestation of row-column is matrix multiplication: when two matrices are multiplied together the rows of the first matrix are combined with the columns of the second matrix.  The number of columns in the first matrix has to be equal to the number of rows in the second.

Step guide 1. Take a row of the first matrix. 2. Take a column from the second matrix. 3. The row is rotated clockwise so that it sits above the column. 4. The components of each will pair up, row component with column component (if this does not happen then the matrices cannot be multiplied). 5. Multiply the pairs together. 6. Sum all of the results. 7. The final result is one component of the new matrix.

Matrix Multiplication example

Matrix Multiplication  The location of the result in the new matrix is the position where the row and the column intersect.

Matrix Multiplication example

Matrix Multiplication  Anyone notice what operation is being performed here?  Multiplying a matrix by a compatible vector will perform a linear transformation on the vector.  Multiplying matrices together will produce a single matrix that performs their combined linear transformations. ● It is the dot product of row i from A with column j from B.

Matrix Multiplication  The size of the row must be equal to the size of the column in order to do matrix multiplication.  Or to put this the other way around. The number of columns in the first matrix has to be equal to the number of rows in the second.  Examine the dimensions of the matrices. The two inside numbers must be equal:  2x3. 3x1  The size of the resulting matrix will be the two outside numbers. So the result of 2x3. 3x1 will be a 2x1 matrix.

Properties of Matrix Multiplication  (AB)C = A(BC)  (A + B)C = AC + BC ● AB ≠ BA ● This is important in graphics because matrices are multiplied and it is important to get the order right.

Transpose ● The transpose of a matrix simply interchanges the rows and the columns of the matrix. ● It is important because vectors in graphics can be ordered by rows (DirectX) or columns (OpenGL and HLSL). ● Represented by a superscript T. The transpose of matrix A is A T. ● So a n x m matrix becomes an n x m matrix.

The Identity Matrix  The identity matrix is a special matrix. The identity matrix is a square matrix that has zeros for all elements expect along the main diagonal.  Multiplying a matrix by the identity matrix leaves the matrix unchanged.  For example used as a starting point before additional operations are added to a matrix.

Vectors ● A matrix can have just one column or just one row. ● A row or column matrix can be used to represent a vector. vector is:row matrix is: ● DirectX uses row vectors (OpenGL uses column vectors).

Transforming a Vector  If you multiply a row matrix by a 3x3 matrix, the result is another row matrix.  The 3x3 matrix therefore acts to transform the row matrix.  However, a 3x3 matrix can only produce some of the transformations required in 3D graphics.  So another component is added at the end to produce a row matrix with a length of 4. The transformation matrix now be a 4x4 matrix.

Rotation using a matrix  Matrix multiplication is used to perform rotations.  Well start with Euler rotation. In year 3 you'll look at a faster alternative.  Euler is pronounced "oiler".

Rotation using a matrix