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

1 3D Vector & Matrix Chapter 2. 2 Vector Definition: Vector is a line segment that has the direction. The length of the line segment is called the magnitude.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
General Physics (PHYS101)
Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.
Maths for Computer Graphics
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
CMPE 466 COMPUTER GRAPHICS
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 : “shiv rpi” Linear Algebra A gentle introduction Linear Algebra has become as basic and as applicable.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CS 4731: Computer Graphics Lecture 6: Points, Scalars and Vectors Emmanuel Agu.
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.
CS 4731: Computer Graphics Lecture 8: 3D Affine transforms Emmanuel Agu.
Vectors.
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.
PHYS 218 sec Review Chap. 1. Caution This presentation is to help you understand the contents of the textbook. Do not rely on this review for.
Lecture 7: Matrix-Vector Product; Matrix of a Linear Transformation; Matrix-Matrix Product Sections 2.1, 2.2.1,
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
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
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.
Chapter 3 Vectors.
1 CO Games Development 1 Week 5 Deriving a "look at" function + Graph Theory Gareth Bellaby.
Mathematical Fundamentals
CSE 381 – Advanced Game Programming 3D Mathematics
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Chapter 10 Review: Matrix Algebra
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
Chapter 4.1 Mathematical Concepts
REVIEW OF MATHEMATICS. Review of Vectors Analysis GivenMagnitude of vector: Example: Dot product:  is the angle between the two vectors. Example:
Introduction and Vectors
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Geometric Transformations Jehee Lee Seoul National University.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 : “shiv rpi” Linear Algebra A gentle introduction Linear Algebra has become as basic and as applicable.
Mathematics for Graphics. 1 Objectives Introduce the elements of geometry  Scalars  Vectors  Points Develop mathematical operations among them in a.
Transformations Jehee Lee Seoul National University.
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.
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.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
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.
The Camera Course Information CVG: Programming 4 My Name: Mark Walsh Website: Recommended Reading.
Chapter 3 Vectors. Vector quantities  Physical quantities that have both numerical and directional properties Mathematical operations of vectors in this.
Chun-Yuan Lin Mathematics for Computer Graphics 2015/12/15 1 CG.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Math Review.
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
Composite 3D Transformations. Example of Composite 3D Transformations Try to transform the line segments P 1 P 2 and P 1 P 3 from their start position.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Affine Geometry.
Computer Graphics Matrices
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Graphics Lecture 2: Slide 1 Lecture 2 Transformations for animation.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
Lecture 1 Linear algebra Vectors, matrices. Linear algebra Encyclopedia Britannica:“a branch of mathematics that is concerned with mathematical structures.
CO1301: Games ts 2015 Lecture 6 Vectors Dr Nick Mitchell (Room CM 224)
Transforms.
COMP 175: Computer Graphics February 9, 2016
CO1301: Games Concepts Lecture 13 Basic Trigonometry
Linear Algebra A gentle introduction
Game Programming Algorithms and Techniques
Presentation transcript:

CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby Lecture 11 Cross Product & the Model Matrix

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 1: "Vector Algebra"

Vectors & Dot Product (revision) Cross Product

Vectors  A vector is a directed edge. In 3 dimensions a vector has three components: v(x, y, z) For example the vector a = (2, 2, 0)

Length of a vector  The length of a vector can be calculated from its components.

The normalised vector  A normalised vector is a vector whose length is 1.  Also known as the unit vector.  A vector can be normalised by dividing each of its components by its length:

Dot product  The dot product of two vectors v and w is:  The relationship between two vectors can be calculated using the dot product.  The dot product of two vectors expresses the angle between the vectors:

Cross Product  The cross product (like the dot product) takes its name from the symbol used: a single cross between two vectors.  Pronounced "The cross product of v and w ", or just the shorthand of "the cross of v and w ".  The cross product takes two vectors and produces a single vector as its result.

Cross Product Illustration Vector v Vector w Cross Product v×w

Cross Product  The cross product of two vectors is the vector which are orthogonal (perpendicular or at right-angles) to both of the vectors.  There will always be two vectors which are orthogonal to our original two vectors: one sticking upwards and the other downwards (relative to the original vectors). The cross product is not commutative. The order of the vectors produces the direction.

Why is it important to you?  What is interesting about the cross product?  The cross product of two vectors v and w would produce the local axis of rotation between the two vectors.  For example the cross product is used to construct a LookAt() function and to implement shader techniques such as normal mapping and parallax mapping.

Introducing Transformations

Model Positioning Reminder  A 3D model has its own local space:  Three 3D vectors X,Y & Z  These are the local axes of the model.  So when you move a model according to its local z axis you are calling up the local axes of the model in order to do the movement.

Model Positioning  These local axes define the local rotation of the model, e.g. rotating around its local y-axis, etc.  The following terms are less commonly used nowadays but just in case you come across them:  rotation around the local X is pitch (up and down)  rotation around the local Y is yaw (side to side)  rotation around the local Z is roll

3D Models in graphics  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 ).  The position of the model are its coordinates in world space. The position is the location of its local origin.

3D Models in graphics  Every model has 4 items of data:  Vector representing the x-axis (relative to model origin)  Vector representing the y-axis (relative to model origin)  Vector representing the z-axis (relative to model origin)  Vector containing the coordinates of the model (relative to the world origin)  Why is it done in this way?  Is it possible to do this any other way?

3D Models in graphics  Each model within the TL-Engine has a floating point array associated with it. The array is actually a matrix and we'll talk about matrices in a while.  It can be considered to be a 4 by 4 array: float matrix[4][4];

3D Models in graphics  The first row of the array is the model's local x-axis.  The second row of the array is the model's local y-axis.  The third row of the array is the model's local z-axis.  The final row of the array are the model's coordinates. Ignore the final component of the vectors for now.

3D Models in graphics  As a 4x4 array:  Initialisation in C++: float matrix[4][4] = { { 0.2, 0.4, 0.1, 0.0 }, { 1.0, 1.0, 1.0, 0.0 }, { 0.3, 0.3, 0.3, 0.0 }, { 10.0, 3.0, 7.0, 1.0 } };

Transforming the model  The matrix can be obtained using the GetMatrix() method. float matrix[4][4]; box->GetMatrix( &matrix[0][0] );  The fourth row of the array are the coordinates of the model. The fourth row is accessed by setting the first subscript of the array to 3. matrix[3][0]; // Px matrix[3][1]; // Py matrix[3][2]; // Pz

Transforming the model  So doing the following would set the coordinates of the model to ( 4, 6, 3 ) matrix[3][0] = 4.0f; matrix[3][1] = 6.0f; matrix[3][2] = 3.0f;  The matrix can be set using the SetMatrix() method. box->SetMatrix( &matrix[0][0] );  And the box (in this case) would move to location ( 4, 6, 3 ).

Scaling  The axes also provide a scaling. The length of the vectors X, Y & Z can define the scaling in that axis  1.0 = normal, 2.0 = double size etc.  Effectively scaling local space  So if you obtain the matrix of the model and multiply the components of the first row by 2, you will double the size of the model along the x-axis.

Scaling  To scale the model in all of its axes, you would need to multiply the second and third rows of the array in the same way as the first, the effect of this would be to reproduce the Scale() method: float matrix[4][4]; box->GetMatrix( &matrix[0][0] ); matrix[0][1] *= 2.0f; matrix[0][2] *= 2.0f; matrix[0][3] *= 2.0f; box->SetMatrix( &matrix[0][0] );

Introduction to Matrices

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 to you?  Matrices are an essential part of graphics.  Transformations are carried out using matrices.  Matrices are key element of linear algebra and hence of computer graphics.

Matrices  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.