Docsity

Linear Algebra and Matrix Transformations, Slides of Computer Graphics

Partial preview of the text

Download Linear Algebra and Matrix Transformations and more Slides Computer Graphics in PDF only on Docsity!

Lecture 08:

Transform 1

Geometric Transform

โ€ข Apply transforms to a hierarchy of objects /

verticesโ€ฆ

  • Specifically, translate (T), rotate (R), scale (S)

Vector and Matrix Notation

โ€ข Letโ€™s say I need:

  • 6 apples, 5 cans of soup, 1 box of tissues, 2 bags

of chips

โ€ข 4 Stores, A, B, C, and D (Stop and Shop,

Shawโ€™s, Trader Joeโ€™s, and Whole Foods)

1 apple 1 can of soup 1 box of tissue 1 bag of chips

Stop and Shop $0.20 $0.93 $0.64 $1. Shawโ€™s $0.65 $0.82 $0.75 $1. Trader Joeโ€™s $0.95 $1.10 $0.52 $3. Whole Foods $1.15 $0.20 $1.25 $2.

Shopping Example

  • Which store do you go to?
    • Find the total cost from each store
    • Find the minimum of the four stores
  • More formally, let ๐‘ž๐‘– denote the quantity of item ๐‘–.
  • Let ๐ด๐‘– be the unit price of item ๐‘– at store ๐ด.
  • Then:
    • ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ด = (^4) ๐‘–=1๐ด๐‘–๐‘ž๐‘–

q1 q2 q3 q A $0.20 $0.93 $0.64 $1. B $0.65 $0.82 $0.75 $1. C $0.95 $1.10 $0.52 $3. D $1.15 $0.20 $1.25 $2.

๐‘ž 1 = ๐Ÿ” ๐‘ž 2 = ๐Ÿ“ ๐‘ž 3 = ๐Ÿ ๐‘ž 4 = ๐Ÿ

Total_A = (0.2 * 6) + (0.93 * 5) + (0.64 * 1) + (1.20 * 2) = 8.

Using the Matrix Notation

  • ๐‘ƒ๐‘Ž๐‘™๐‘™ =

๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ด ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ต ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ถ ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ท

=

0.20 0.93 (^) 0.64 1. 0.65 0.82 (^) 0.75 1. 0.95 1.10 (^) 0.52 3. 1.15 0.20 (^) 1.25 2.

6 5 1 2

  • Determine totalCost vector using row-column multiplication
    • Dot product is the sum of the pairwise multiplications
    • Apply this operation to rows of prices and column of quantitities

Reminder: Matrix Multiplication

  • Each entry in the resulting matrix L is the dot product of a row of M with a column of N:

๐ฟ = ๐‘€๐‘

๐‘™๐‘ฅ๐‘ฅ ๐‘™๐‘ฅ๐‘ฆ ๐‘™๐‘ฅ๐‘ง ๐‘™๐‘ฅ๐‘ค ๐‘™๐‘ฆ๐‘ฅ ๐‘™๐‘ฆ๐‘ฆ ๐‘™๐‘ฆ๐‘ง ๐‘™๐‘ฆ๐‘ค ๐‘™๐‘ง๐‘ฅ ๐‘™๐‘ง๐‘ฆ ๐‘™๐‘ง๐‘ง ๐‘™๐‘ง๐‘ค ๐‘™๐‘ค๐‘ฅ ๐‘™๐‘ค๐‘ฆ ๐‘™๐‘ค๐‘ง ๐‘™๐‘ค๐‘ค

=

๐‘š๐‘ฅ๐‘ฅ ๐‘š๐‘ฅ๐‘ฆ ๐‘š๐‘ฅ๐‘ง ๐‘š๐‘ฅ๐‘ค ๐‘š๐‘ฆ๐‘ฅ ๐‘š๐‘ฆ๐‘ฆ ๐‘š๐‘ฆ๐‘ง^ ๐‘š๐‘ฆ๐‘ค ๐‘š๐‘ง๐‘ฅ ๐‘š๐‘ง๐‘ฆ ๐‘š๐‘ง๐‘ง ๐‘š๐‘ง๐‘ค ๐‘š๐‘ค๐‘ฅ ๐‘š๐‘ค๐‘ฆ ๐‘š๐‘ค๐‘ง ๐‘š๐‘ค๐‘ค

๐‘›๐‘ฅ๐‘ฅ ๐‘›๐‘ฅ๐‘ฆ ๐‘›๐‘ฅ๐‘ง ๐‘›๐‘ฅ๐‘ค ๐‘›๐‘ฆ๐‘ฅ ๐‘›๐‘ฆ๐‘ฆ ๐‘›๐‘ฆ๐‘ง^ ๐‘›๐‘ฆ๐‘ค ๐‘›๐‘ง๐‘ฅ ๐‘›๐‘ง๐‘ฆ ๐‘›๐‘ง๐‘ง ๐‘›๐‘ง๐‘ค ๐‘›๐‘ค๐‘ฅ ๐‘›๐‘ค๐‘ฆ ๐‘›๐‘ค๐‘ง ๐‘›๐‘ค๐‘ค

๐‘™๐‘ฅ๐‘ฆ = ๐‘š๐‘ฅ๐‘ฅ๐‘›๐‘ฅ๐‘ฆ + ๐‘š๐‘ฅ๐‘ฆ๐‘›๐‘ฆ๐‘ฆ + ๐‘š๐‘ฅ๐‘ง๐‘›๐‘ง๐‘ฆ + ๐‘š๐‘ฅ๐‘ค๐‘›๐‘ค๐‘ฆ

  • Does ๐ฟ = ๐‘€๐‘ and ๐ฟ = ๐‘๐‘€ the same?

Identity Matrix

  • What if our price matrix is of the following?

(^1 0 0 ) (^0 1 0 ) (^0 0 1 ) (^0 0 0 )

Identity Matrix

  • What if our price matrix is of the following? (^1 0 0 ) (^0 1 0 ) (^0 0 1 ) (^0 0 0 )
  • ๐‘ƒ๐‘Ž๐‘™๐‘™ =

๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ด ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ต ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ถ ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ท

=

(^1 0 0 ) (^0 1 0 ) (^0 0 1 ) (^0 0 0 )

6 5 1 2

=

6 5 1 2

  • We call this matrix the โ€œidentity matrixโ€

Identity Matrix

  • What if our price matrix is of the following? (^2 0 0 ) (^0 2 0 ) (^0 0 2 ) (^0 0 0 )
  • ๐‘ƒ๐‘Ž๐‘™๐‘™ =

๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ด ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ต ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ถ ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™๐ถ๐‘œ๐‘ ๐‘ก๐ท

=

(^2 0 0 ) (^0 2 0 ) (^0 0 2 ) (^0 0 0 )

6 5 1 2

=

12 10 2 4

  • So this is a โ€œscaling matrixโ€

Note!

  • In this example, notice the first column of the matrix is

only affecting the first value of the result

  • Why is this important??

Matrix Multiplication Explained

(Visually)

  • Suppose we have some matrix, like

1 1 1 2

, and we want to know what itโ€™ll do to a 2D point.

  • First, we multiply this matrix by two unit basis

vectors, the x-axis and the y-axis: 1 1 1 2

1 0

=

1 1

1 1 1 2

0 1

=

1 2

  • Notice the results are the two columns of the matrixโ€ฆ
  • So letโ€™s visualize how the x and y axes have been

transformed using our matrix

Matrix Multiplication Explained

(Visually)

  • Original Coordinate

System

  • After we apply the

transform

Transformations in Computer Graphics

  • Elemental Transformations:
    • Translation
    • Rotation
    • Scaling
    • Shearing
  • Of the four, three of them are affine and linear:
    • Rotation, Scaling, and Shearing
  • One is affine but non-linear
    • Translation

Definitions of Transformations

  • Projective โŠƒ Affine โŠƒ Linear
    • Meaning that all linear transforms are also affine transforms, which are also projective transforms.
    • However, not all affine transforms are linear transforms, and not all projective transforms are affine.
  • Definitions:
    • Linear Transform:
      • Preserves all parallel lines
      • Acts on a line to yield either a line or a point
      • The vector [0, 0] is always transformed to [0, 0]
      • Examples: scale and rotate