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

Slides:



Advertisements
Similar presentations
CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
Advertisements

This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Chapter 4 Systems of Linear Equations; Matrices
Chapter 4 Systems of Linear Equations; Matrices
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Chapter 4 Systems of Linear Equations; Matrices Section 2 Systems of Linear Equations and Augmented Matrics.
Matrices: Inverse Matrix
Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce.
1 Copyright © 2015, 2011, 2007 Pearson Education, Inc. Chapter 4-1 Systems of Equations and Inequalities Chapter 4.
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Section 4.2 – Multiplying Matrices Day 2
Maths for Computer Graphics
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
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
MOHAMMAD IMRAN DEPARTMENT OF APPLIED SCIENCES JAHANGIRABAD EDUCATIONAL GROUP OF INSTITUTES.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS 450: Computer Graphics 2D TRANSFORMATIONS
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.
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Game Physics – Part IV Moving to 3D
MATRICES AND DETERMINANTS
MATRICES Adapted from presentation found on the internet. Thank you to the creator of the original presentation!
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Week 2 - Wednesday CS361.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
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.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
1 CO Games Concepts Week 20 Matrices continued Gareth Bellaby.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
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.
4.5 Inverse of a Square Matrix
Direct3D Workshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals.
Computer Graphics Matrices
Section 4.3 – Multiplying Matrices. MATRIX MULTIPLICATION 1. The order makes a difference…AB is different from BA. 2. The number of columns in first matrix.
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.
Essential Question: Why, oh why, didn’t I take the blue pill?
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
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.
Chapter 4 Systems of Linear Equations; Matrices
MTH108 Business Math I Lecture 20.
CO1301: Games ts 2015 Lecture 6 Vectors Dr Nick Mitchell (Room CM 224)
13.4 Product of Two Matrices
Sections 2.4 and 2.5 Matrix Operations
Chapter 7 Matrix Mathematics
CS451Real-time Rendering Pipeline
COMP 175: Computer Graphics February 9, 2016
CorePure1 Chapter 7 :: Linear Transformations
Unit 3: Matrices
Chapter 4 Systems of Linear Equations; Matrices
Linear Vector Space and Matrix Mechanics
CO Games Concepts Week 12 Collision Detection
Game Programming Algorithms and Techniques
Chapter 4 Systems of Linear Equations; Matrices
Presentation transcript:

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

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.

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

Topic 2  Efficiency

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.

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

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:

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.

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.

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.

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.

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.

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 )

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.

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.