Maths Preliminaries

Category: Education

Presentation Description

No description available.


Presentation Transcript

Computer Graphics 2:Maths Preliminaries : 

Computer Graphics 2:Maths Preliminaries

Introduction : 

Introduction Computer graphics is all about maths! None of the maths is hard, but we need to understand it well in order to be able to understand certain techniques Today we’ll look at the following: Coordinate reference frames Points & lines Vectors Matrices

Big Idea : 

Big Idea

Coordinate Reference Frames – 2D : 

Coordinate Reference Frames – 2D When setting up a scene in computer graphics we define the scene using simple geometry For 2D scenes we use simple two dimensional Cartesian coordinates All objects are defined using simple coordinate pairs

Coordinate Reference Frames – 2D (cont…) : 

Coordinate Reference Frames – 2D (cont…)

Coordinate Reference Frames – 3D : 

Coordinate Reference Frames – 3D For three dimensional scenes we simply add an extra coordinate

Left Handed Or Right Handed? : 

Left Handed Or Right Handed? There are two different ways in which we can do 3D coordinates – left handed or right handed Right-Hand Reference System Left-Hand Reference System

Points & Lines : 

Points & Lines Points: A point in two dimensional space is given as an ordered pair (x, y) In three dimensions a point is given as an ordered triple (x, y, z) Lines: A line is defined using a start point and an end-point In 2d: (xstart, ystart) to (xend, yend) In 3d: (xstart, ystart , zstart) to (xend, yend , zend)

Points & Lines (cont…) : 

Points & Lines (cont…) (2, 3) (6, 7) (7, 1) (7, 3) (2, 7) The line from (2, 7) to (7, 3)

The Equation of A Line : 

The Equation of A Line The slope-intercept equation of a line is: where: The equation of the line gives us the corresponding y point for every x point y0 yend xend x0

A Simple Example : 

A Simple Example Let’s draw a portion of the line given by the equation: Just work out the y coordinate for each x coordinate

A Simple Example (cont…) : 

A Simple Example (cont…)

A Simple Example (cont…) : 

A Simple Example (cont…) For each x value just work out the y value:

Vectors : 

Vectors Vectors: A vector is defined as the difference between two points The important thing is that a vector has a direction and a length What are vectors for? A vector shows how to move from one point to another Vectors are very important in graphics - especially for transformations

Vectors (2D) : 

Vectors (2D) To determine the vector between two points simply subtract them P2 (6, 7) P1 (1, 3) V WATCH OUT: Lots of pairs of points share the same vector between them

Vectors (3D) : 

Vectors (3D) In three dimensions a vector is calculated in much the same way So for (2, 1, 3) to (7, 10, 5) we get

Vector Operations : 

Vector Operations There are a number of important operations we need to know how to perform with vectors: Calculation of vector length Vector addition Scalar multiplication of vectors Scalar product Vector product

Vector Operations: Vector Length : 

Vector Operations: Vector Length Vector lengths are easily calculated in two dimensions: and in three dimensions:

Vector Operations: Vector Addition : 

Vector Operations: Vector Addition The sum of two vectors is calculated by simply adding corresponding components Performed similarly in three dimensions

Vector Operations: Scalar Multiplication : 

Vector Operations: Scalar Multiplication Multiplication of a vector by a scalar proceeds by multiplying each of the components of the vector by the scalar

Other Vector Operations : 

Other Vector Operations There are other important vector operations that we will cover as we come to them These include: Scalar product (dot product) Vector product (cross product)

Matrices : 

Matrices A matrix is simply a grid of numbers However, by using matrix operations we can perform a lot of the maths operations required in graphics extremely quickly

Matrix Operations : 

Matrix Operations The important matrix operations for this course are: Scalar multiplication Matrix addition Matrix multiplication Matrix transpose Determinant of a matrix Matrix inverse

Matrix Operations: Scalar Multiplication : 

Matrix Operations: Scalar Multiplication To multiply the elements of a matrix by a scalar simply multiply each one by the scalar Example:

Matrix Operations: Addition : 

Matrix Operations: Addition To add two matrices simply add together all corresponding elements Example: Both matrices have to be the same size

Matrix Operations: Matrix Multiplication : 

Matrix Operations: Matrix Multiplication We can multiply two matrices A and B together as long as the number of columns in A is equal to the number of rows in B So, if we have an m by n matrix A and a p by q matrix B we get the multiplication: C=AB where C is a m by q matrix whose elements are calculated as follows:

Matrix Operations: Matrix Multiplication (cont…) : 

Matrix Operations: Matrix Multiplication (cont…) Examples:

Matrix Operations: Matrix Multiplication (cont…) : 

Matrix Operations: Matrix Multiplication (cont…) Watch Out! Matrix multiplication is not commutative, so:

Matrix Operations: Transpose : 

Matrix Operations: Transpose The transpose of a matrix M, written as MT is obtained by simply interchanging the rows and columns of the matrix For example:

Other Matrix Operations : 

Other Matrix Operations There are some other important matrix operations that we will explain as we need them These include: Determinant of a matrix Matrix inverse

Summary : 

Summary In this lecture we have taken a brief tour through the following: Basic idea The mathematics of points, lines and vectors The mathematics of matrices These tools will equip us to deal with the computer graphics techniques that we will begin to look at, starting next time

Exercises 1 : 

Exercises 1 Plot the line y = ½x + 2 from x = 1 to x = 9

Exercises 2 : 

Exercises 2 Perform the following matrix additions:

Exercises 3 : 

Exercises 3 Perform the following matrix multiplications:

Exercises 4 : 

Exercises 4 Perform the following multiplication of a matrix by a scalar Calculate the transpose of the following matrix

authorStream Live Help