Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square...
Transcript of Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square...
![Page 1: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/1.jpg)
Linear algebra and geometric transformations in 2D
Computer GraphicsCSE 167Lecture 2
![Page 2: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/2.jpg)
CSE 167: Computer Graphics
• Linear algebra– Vectors– Matrices
• Points as vectors• Geometric transformations in 2D
– Homogeneous coordinates
CSE 167, Winter 2018 2
![Page 3: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/3.jpg)
Vectors
• Represent magnitude and direction in multiple dimensions
• Examples– Translation of a point– Surface normal vectors (vectors orthogonal to surface)
CSE 167, Winter 2018 3Based on slides courtesy of Jurgen Schulze
![Page 4: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/4.jpg)
Vectors and arithmetic
CSE 167, Winter 2018 4
Examples using 3‐vectors
Vectors must be the same length
Vectors are column vectors
![Page 5: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/5.jpg)
Magnitude of a vector
• The magnitude of a vector is its norm
• A vector if magnitude 1 is called a unit vector• A vector can be unitized by dividing by its norm
CSE 167, Winter 2018 5
Example using 3‐vector
![Page 6: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/6.jpg)
Dot product of two vectors
CSE 167, Winter 2018 6
Angle between two vectors
![Page 7: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/7.jpg)
Cross product of two 3‐vectors
• The cross product of two 3‐vectors a and bresults in another 3‐vector that is orthogonal (using right hand rule) to the two vectors
CSE 167, Winter 2018 7
![Page 8: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/8.jpg)
Cross product of two 3‐vectors
CSE 167, Winter 2018 8
![Page 9: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/9.jpg)
Matrices
• 2D array of numbers
A =
CSE 167, Winter 2018 9
![Page 10: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/10.jpg)
Matrix addition
• Matrices must be the same size
• Matrix subtraction is similar
CSE 167, Winter 2018 10
![Page 11: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/11.jpg)
Matrix‐scalar multiplication
CSE 167, Winter 2018 11
![Page 12: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/12.jpg)
Matrix‐matrix multiplication
CSE 167, Winter 2018 12
![Page 13: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/13.jpg)
Matrix‐vector multiplication
• Same as matrix‐matrix multiplication– Example: 3x3 matrix multiplied with 3‐vector
CSE 167, Winter 2018 13
![Page 14: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/14.jpg)
Transpose
• 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
![Page 15: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/15.jpg)
The identity matrix
CSE 167, Winter 2018 15
![Page 16: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/16.jpg)
Matrix inverse
• The inverse of a square matrix M is a matrix M‐1 such that
• A square matrix has an inverse if and only if its determinant is nonzero
• The inverse of a product of matrices is
CSE 167, Winter 2018 16
Example using three matrices
![Page 17: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/17.jpg)
Representing points using vectors
• 2D point
• 3D point
CSE 167, Winter 2018 17
![Page 18: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/18.jpg)
Geometric transformations in 2D
• Operations on vectors (or points)– Translation– Linear transformation
• Scale• Shear• Rotation• Any combination of these
– Affine transformation• Linear transformation followed by translation
CSE 167, Winter 2018 18
![Page 19: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/19.jpg)
2D translation
• Translation of vector v to v’ under translation t
CSE 167, Winter 2018 19
![Page 20: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/20.jpg)
2D uniform scale
• Scale x and y the same
CSE 167, Winter 2018 20
![Page 21: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/21.jpg)
2D nonuniform scale
• Scale x and y independently
CSE 167, Winter 2018 21
![Page 22: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/22.jpg)
2D shear
• Shear in x direction (horizontal)
CSE 167, Winter 2018 22
![Page 23: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/23.jpg)
2D rotation
• Positive angles rotate counterclockwise
CSE 167, Winter 2018 23
where
![Page 24: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/24.jpg)
2D rotation about a point
CSE 167, Winter 2018 24
![Page 25: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/25.jpg)
2D rotation about a point
CSE 167, Winter 2018 25
1. Translate point to the origin
2. Rotate about the origin
3. Translate origin back to point
![Page 26: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/26.jpg)
2D rotation about a point
• This can be accomplished with one transformation matrix, 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
![Page 27: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/27.jpg)
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
‐
‐
![Page 28: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/28.jpg)
2D rotation using homogeneous coordinates
• 2D rotation using homogenous coordinates
CSE 167, Winter 2018 28
![Page 29: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/29.jpg)
2D rotation about a pointusing homogeneous coordinates
CSE 167, Winter 2018 29
‐
‐
Important: transformation matrices are applied right to left
![Page 30: Linear algebra and geometric transformations in 2D · Matrix inverse • The inverse of a square matrix M is a matrix M‐1 such that • A square matrix has an inverse if and only](https://reader030.fdocuments.in/reader030/viewer/2022041107/5f0b1b587e708231d42ee1a4/html5/thumbnails/30.jpg)
2D rotation about a pointusing homogeneous coordinates
CSE 167, Winter 2018 30
‐
‐
M
where M‐
‐