1 CO1301 - Games Concepts Week 20 Matrices continued Gareth Bellaby.

Slides:



Advertisements
Similar presentations
4.1 Introduction to Matrices
Advertisements

Matrices A matrix is a rectangular array of quantities (numbers, expressions or function), arranged in m rows and n columns x 3y.
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
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.
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.
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.
Now Playing: My Mathematical Mind Spoon From Gimme Fiction Released May 10, 2005.
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
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 8 Chapter 8: Transformation Operators.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Matrix Definition A Matrix is an ordered set of numbers, variables or parameters. An example of a matrix can be represented by: The matrix is an ordered.
Matrices The Basics Vocabulary and basic concepts.
Intro to Matrices Don’t be scared….
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
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.
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.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
ECON 1150 Matrix Operations Special Matrices
Presentation on Matrices and some special matrices In partial fulfillment of the subject Vector calculus and linear algebra ( ) Submitted by: Agarwal.
Chapter 4.1 Mathematical Concepts
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Mathematics for Computer Graphics. Lecture Summary Matrices  Some fundamental operations Vectors  Some fundamental operations Geometric Primitives:
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Maths and Technologies for Games Quaternions CO3303 Week 1.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Matrices. A matrix, A, is a rectangular collection of numbers. A matrix with “m” rows and “n” columns is said to have order m x n. Each entry, or element,
Unit 3: Matrices.
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.
Matthew Christian. About Me Introduction to Linear Algebra Vectors Matrices Quaternions Links.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Notes 7.2 – Matrices I. Matrices A.) Def. – A rectangular array of numbers. An m x n matrix is a matrix consisting of m rows and n columns. The element.
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
Meeting 18 Matrix Operations. Matrix If A is an m x n matrix - that is, a matrix with m rows and n columns – then the scalar entry in the i th row and.
1 Graphics CSCI 343, Fall 2015 Lecture 10 Coordinate Transformations.
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
3.4 Solution by Matrices. What is a Matrix? matrix A matrix is a rectangular array of numbers.
Computer Graphics Matrices
Matrices and Determinants
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
MATRIX A set of numbers arranged in rows and columns enclosed in round or square brackets is called a matrix. The order of a matrix gives the number of.
Euler Angles This means, that we can represent an orientation with 3 numbers Assuming we limit ourselves to 3 rotations without successive rotations about.
CS 450: COMPUTER GRAPHICS TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Unit 3: Matrices. Matrix: A rectangular arrangement of data into rows and columns, identified by capital letters. Matrix Dimensions: Number of rows, m,
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
Matrix Algebra Definitions Operations Matrix algebra is a means of making calculations upon arrays of numbers (or data). Most data sets are matrix-type.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices.
MTH108 Business Math I Lecture 20.
Matrices and Vector Concepts
Math Fundamentals Maths revisit.
ECE 1304 Introduction to Electrical and Computer Engineering
Transforms.
Chapter 7 Matrix Mathematics
Matrix Operations.
2.2 Introduction to Matrices
CO Games Concepts Week 12 Collision Detection
Presentation transcript:

1 CO Games Concepts Week 20 Matrices continued Gareth Bellaby

2 Topics 1.Matrices continued 2.Efficiency 3.Numbers

3 Topic 1 Matrices continued

4 Matrices ●A model has an associated 4 x 4 matrix. x-axis y-axis z-axis position

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

6 Matrices ●A matrix is a rectangular table of numbers. ●A matrix is composed of rows and columns. ●In C++ float matrix[4][4] = {{ 0.2, 0.4, 0.1,0 }, { 1, 1, 1,0 }, { 0.3, 0.3, 0.3,0 }, { 10, 3, 7,1 } };

7 Matrix maths reminder ●Size is expressed as rrows by columns. ●Matrix addition. ●Scalar multiplication. ●Matrix multiplication.

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

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

10 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.

11 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.

12 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).

13 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.

14 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".

15 Rotation using a matrix

16 Topic 2 Efficiency

17 Efficiency ●Last week I talked about the need for efficiency. The time available to perform operations within a computer game is small (0.017 to seconds per frame) and so efficiency is a dominant concern within games programming. ●If you have 10,000 trees. You need to perform collision detection for all of the trees. That's a lot of processing.

18 Tree collision Collision is currently being implemented as: ●What could be done in order to reduce the computational cost?

19 Improving efficiency ●Firstly, can the collision detection be made more efficient? ●Examine the calculation. Collision detection depends upon a distance check. The most expensive element of the calculation is the square root. But it can be dispensed with:

20 Improving efficiency ●Rewrite the check so that the square is no longer used. ●Square both sides of the equation. ●Perform the check against the square of the tree radius.

21 Improving efficiency ●The square of the radius can be pre-calculated so it costs nothing. ●A simple rewriting of the calculation has improved matters. ●The use of squares is common within graphics, e.g. for distance tests.

22 Efficiency ●Could anything else be done to improve efficiency? ●Does the program have to check all of the trees? ●Most of the trees are so far away that we can ignore them. It is possible to devise a method so that only likely candidates are checked.

23 Partitioning the world ●Grid out the world. ●Record the trees according to which grid they are in. ●Only check those trees which are in the same grid as the player. ●10 by 10 grid. ●Each grid has 100 trees within it.

24 Partitioning the world ●This example will use clear coordinates and scaling, but note that the principle holds true for all contexts. Each cell of the grid willl be 100 units by 100 units. ●Need an efficient way to derive the current grid of the player. Remember that integer devision within C++ produces an integer result and that the result is always rounded down. Divide the player coordinates (x and z) by 100. The result is the grid reference.

25 Deriviving the grid cell ●player location ( 40, 30 ) => ( 40/100, 30/100 ) => ( 0, 0 ) ●player location ( 140, 130 ) => ( 140/100, 130/100 ) => ( 1, 1 ) ●player location ( 450, 70 ) => ( 450/100, 70/100 ) => ( 4, 0 )

26 Spatial Partitioning ●In programming terms you could create a 2D array which corresponds exactly to the grid coordinates. Each cell could then have the locations of its own trees stored. ●This is an simple example of a technique called "spatial partitioning", i.e. partitioning or sub- dividing space into chunks. Spatial partitioning is used extensively within computer games, e.g. in a game level so that only nearby models or visible models are rendered.

27 Spatial Partitioning ●For example, it is possible to extend the grid approach to include a check to see whether the trees get rendered. ●There's a nice version of this later on in Frank Luna, Introduction to DirectX, in Chapter 18 when he uses a grid to filter out geometry that is not in view of the camera. ●More sophisticated techniques include Binary Space Partioning (BSP) trees and Oct-trees.