<<

Linear and geometric transformations in 2D

Computer Graphics CSE 167 Lecture 2 CSE 167:

– Vectors – Matrices • Points as vectors • Geometric transformations in 2D –

CSE 167, Winter 2018 2 Vectors

• Represent and direction in multiple • Examples – of a point – Surface normal vectors (vectors orthogonal to surface)

CSE 167, Winter 2018 3 Based on slides courtesy of Jurgen Schulze Vectors and arithmetic

Examples using Vectors are 3‐vectors column vectors

Vectors must be the same length

CSE 167, Winter 2018 4 Magnitude of a vector

• The magnitude of a vector is its

Example using 3‐vector

• A vector if magnitude 1 is called a • A vector can be unitized by dividing by its norm

CSE 167, Winter 2018 5 Dot of two vectors

Angle between two vectors

CSE 167, Winter 2018 6 of two 3‐vectors

• The cross product of two 3‐vectors a and b results in another 3‐vector that is orthogonal (using right hand rule) to the two vectors

CSE 167, Winter 2018 7 Cross product of two 3‐vectors

CSE 167, Winter 2018 8 Matrices

• 2D array of

A =

CSE 167, Winter 2018 9 addition

• Matrices must be the same size

• Matrix subtraction is similar

CSE 167, Winter 2018 10 Matrix‐

CSE 167, Winter 2018 11 Matrix‐

CSE 167, Winter 2018 12 Matrix‐vector multiplication

• Same as matrix‐matrix multiplication – Example: 3x3 matrix multiplied with 3‐vector

CSE 167, Winter 2018 13

• AT is the matrix A flipped over its diagonal

– Example

• Vectors can also be transposed to convert between column and row vectors

– Example

CSE 167, Winter 2018 14 The

CSE 167, Winter 2018 15 Matrix inverse

• The inverse of a matrix M is a matrix M‐1 such that

• A has an inverse if and only if its is nonzero • The inverse of a product of matrices is Example using three matrices

CSE 167, Winter 2018 16 Representing points using vectors

• 2D point

• 3D point

CSE 167, Winter 2018 17 Geometric transformations in 2D

• Operations on vectors (or points) – Translation – Linear transformation • Scale • Shear • • Any combination of these – • Linear transformation followed by translation

CSE 167, Winter 2018 18 2D translation

• Translation of vector v to v’ under translation t

CSE 167, Winter 2018 19 2D uniform scale

• Scale x and y the same

CSE 167, Winter 2018 20 2D nonuniform scale

• Scale x and y independently

CSE 167, Winter 2018 21 2D shear

• Shear in x direction (horizontal)

CSE 167, Winter 2018 22 2D rotation

• Positive rotate counterclockwise

where

CSE 167, Winter 2018 23 2D rotation about a point

CSE 167, Winter 2018 24 2D rotation about a point

1. Translate point 2. Rotate about 3. Translate origin to the origin the origin back to point

CSE 167, Winter 2018 25 2D rotation about a point

• This can be accomplished with one , if we use homogeneous coordinates • A 2D point using affine homogeneous coordinates is a 3‐vector with 1 as the last element

CSE 167, Winter 2018 26 2D translation using homogeneous coordinates • 2D translation using a 3x3 matrix

• Inverse of 2D translation is inverse of 3x3 matrix ‐ ‐

CSE 167, Winter 2018 27 2D rotation using homogeneous coordinates • 2D rotation using homogenous coordinates

CSE 167, Winter 2018 28 2D rotation about a point using homogeneous coordinates

‐ ‐

Important: transformation matrices are applied right to left CSE 167, Winter 2018 29 2D rotation about a point using homogeneous coordinates

‐ ‐

M

‐ where M ‐

CSE 167, Winter 2018 30