23
1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

Embed Size (px)

Citation preview

Page 1: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

1

Math Review

Coordinate systems 2-D, 3-D

VectorsMatrices Matrix operations

Page 2: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

2

Math Review

Cornerstone of graphics Basis for most algorithms Systematic notation Simplifying communication Organizing ideas Compact representation

Page 3: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

3

2-D Coordinate Systems

0 x

yP

yP

0 x

Rectangular or Cartesian

Page 4: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

4

Points and Vectors

A point at (x,y) can be represented by vector P from the

origin (0,0).

0 x

y

PIn general, a vector represents

the difference (directed distance) between two points.

2 1

2 1 2 1,

,x y

x x y y

V V

V P P

0 x

y

P1

P2

V

Page 5: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

5

2-D Vector Representations

Cartesian components

Magnitude and direction angle

,x yV VVVx

Vy

V

|V|

2 2

1tan

x y

y

x

V V

V

V

V

Page 6: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

6

2-D Vector Operations

Addition

1 2 1 2 1 2,x x y y

V V V V V V

V1V2

V1+V2

Subtraction

1 2 1 2 1 2,x x y y

V V V V V V V1

-V2

V1-V2 V2

Page 7: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

7

2-D Vector Operations

Scalar multiply

,x ya aV aVV

Vx

Vy

V

aVx

aVy

aV

Page 8: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

8

2-D Unit Vector

For any vector V, V can also be written as av

2 2

2 2

,

1

x y

x y

x y

av av

a V V

v v

V

VVx

Vy

V

Page 9: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

9

Direction cosines

2 2

cos ,cos

cos cos 1

yxVV

V V

α

β

Vx

Vy

V

Page 10: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

10

3-D Coordinate Systems

z x

y

P

In a Right-handed coordinate system, the z axisdefined by the vector cross product of the x and y axes.

Page 11: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

11

3-D Vector Operations

Addition

Scalar multiply

1 2 1 2 1 2 1 2, ,x x y y z z

V V V V V V V V

, ,x y za aV aV aVV

Page 12: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

12

3-D Vector Representations

Cartesian components

Magnitude and direction cosines

, ,x y zV V VV

2 2 2

2 2 2

cos ,cos ,cos

cos cos cos 1

x y z

yx z

V V V

VV V

V

V V Vx

Vz

y

α

β

γ

Page 13: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

13

3-D Vector Operations

1 2 1 2 1 2 1 2

1 2 cos

x x y y z zV V V V V V

V V

V V

Inner (dot) product

θV1 V2

1

θcosV

VVV

212

2V 1VPortion of in direction

Projections

Page 14: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

14

3-D Vector Cross Product

1 2 1 2

1 2 1 2 1 2

1 2 1 2

1 1 1

2 2 2

,

,y z z y

z x x z

x y y x

x y z

x y z

x y z

V V V V

V V V V

V V V V

V V V

V V V

V V

u u u

“Right-hand rule”

θV1

V2

V1 x V2

Page 15: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

15

Matrices

11 12 1

21 22 2

1 2

n

n

m m mn

a a a

a a a

a a a

A

Rectangular matrix(m x n)(rows x

cols)

1 2 3a a aRRow vector

1

2

3

a

a

a

CColumn vector

Page 16: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

16

Scalar Matrix Multiplication

u v w

x y z

M

au av awa

ax ay az

M

Page 17: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

17

Matrix Addition

u v w

x y z

N

a u b v c w

d x e y f z

M N

a b c

d e f

M

Matrices must have same dimensions

Page 18: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

18

Matrix Transpose

u v w

x y z

M

T

u x

v y

w z

M

Page 19: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

19

Matrix Multiplication

11 12 1

21 22 2

1 2

n

n

m m mn

a a a

a a a

a a a

A

11 12 1

21 22 2

1 2

q

q

p p pq

b b b

b b b

b b b

B

ijc C AB1

n

ij ik kjk

c a b

Matrices must be conformable (n=p)

Page 20: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

20

Matrix Multiplication Example

1 2 3

4 5 6

2 1

3 4

5 7

=

A B C

C row = A row, C column = B column

23

1 2 2 3 3 5 2 6 15 23

66

53

30

Page 21: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

21

Identity Matrix and Inverse

1 1 AA A A IInverse computed by Gaussian elimination,

determinants, or other methods; used directly or indirectly to solve sets of linear equations

1 0 0

0 1 0

0 0 1

I

1

Ax b

x A b

Page 22: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

22

Determinants

  1  

A-1 =             adj(A)

  det(A)  

Page 23: 1 Math Review Coordinate systems 2-D, 3-D Vectors Matrices Matrix operations

CS-321Dr. Mark L. Hornick

23

Determinants

A

A

Gaussian elimination is the best method

Swapping two rows changes the sign of Multiplying a row by s, multiplies by s Adding row multiples has no effect

n

1kkkaA

Only on square matrices For an upper triangular matrix