[ ] vector a a a ... a = column vectors 1 - - PowerPoint PPT Presentation

vector a a a a column vectors 1 important 2 3 trig 2 4
SMART_READER_LITE
LIVE PREVIEW

[ ] vector a a a ... a = column vectors 1 - - PowerPoint PPT Presentation

University of British Columbia Review: Computer Graphics Defined Review: Rendering Capabilities Readings CPSC 314 Computer Graphics CG uses Mon (last time) Jan-Apr 2008 movies, games, art/design, ads, VR, FCG Chap 1 Tamara


slide-1
SLIDE 1

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner http://www.ugrad.cs.ubc.ca/~cs314/Vjan2008

Math Review Guest Lecturer: Michiel van de Panne Week 1, Wed Jan 9

2

Review: Computer Graphics Defined

  • CG uses
  • movies, games, art/design, ads, VR,

visualization

  • CG state of the art
  • photorealism achievable (in some cases)

http://www.alias.com/eng/etc/fakeorfoto/quiz.html

3

Review: Rendering Capabilities

www.siggraph.org/education/materials/HyperGraph/shutbug.htm

4

Readings

  • Mon (last time)
  • FCG Chap 1
  • Wed (this time)
  • FCG Chap 2
  • except 2.5.1, 2.5.3, 2.7.1, 2.7.3, 2.8, 2.9, 2.11.
  • FCG Chap 5.1-5.2.5
  • except 5.2.3, 5.2.4

5

Today’s Readings

  • FCG Chapter 2: Miscellaneous Math
  • skim 2.2 (sets and maps), 2.3 (quadratic eqns)
  • important: 2.3 (trig), 2.4 (vectors), 2.5-6 (lines)

2.10 (linear interpolation)

  • skip 2.5.1, 2.5.3, 2.7.1, 2.7.3, 2.8, 2.9
  • skip 2.11 now (covered later)
  • FCG Chapter 5.1-5.25: Linear Algebra
  • skim 5.1 (determinants)
  • important: 5.2.1-5.2.2, 5.2.5 (matrices)
  • skip 5.2.3-4, 5.2.6-7 (matrix numerical analysis)

6

Notation: Scalars, Vectors, Matrices

  • scalar
  • (lower case, italic)
  • vector
  • (lower case, bold)
  • matrix
  • (upper case, bold)

a

[ ]

n

a a a ...

2 1

= a

  • =

33 32 31 23 22 21 13 12 11

a a a a a a a a a A

7

Vectors

  • arrow: length and direction
  • oriented segment in nD space
  • offset / displacement
  • location if given origin

8

Column vs. Row Vectors

  • row vectors
  • column vectors
  • switch back and forth with transpose
  • =

n col

a a a ...

2 1

a

row T col

a a =

[ ]

n row

a a a ...

2 1

= a

9

Vector-Vector Addition

  • add: vector + vector = vector
  • parallelogram rule
  • tail to head, complete the triangle
  • +

+ + = +

3 3 2 2 1 1

v u v u v u v u ) , 6 , 5 ( ) 1 , 1 , 3 ( ) 1 , 5 , 2 ( ) 6 , 9 ( ) 4 , 6 ( ) 2 , 3 ( =

  • +

= + v u + u v

geometric algebraic examples:

10

Vector-Vector Subtraction

  • subtract: vector - vector = vector
  • =
  • 3

3 2 2 1 1

v u v u v u v u ) 2 , 4 , 1 ( ) 1 , 1 , 3 ( ) 1 , 5 , 2 ( ) 2 , 3 ( ) 4 , 6 ( ) 2 , 3 (

  • =
  • =
  • =

v u u v v

  • )

( v u

  • +

11

Vector-Vector Subtraction

  • subtract: vector - vector = vector
  • =
  • 3

3 2 2 1 1

v u v u v u v u ) 2 , 4 , 1 ( ) 1 , 1 , 3 ( ) 1 , 5 , 2 ( ) 2 , 3 ( ) 4 , 6 ( ) 2 , 3 (

  • =
  • =
  • =

v u u v v

  • )

( v u

  • +

v u + v u u v v u

argument reversal

12

Scalar-Vector Multiplication

  • multiply: scalar * vector = vector
  • vector is scaled

) * , * , * ( *

3 2 1

u a u a u a a = u ) 5 ,. 5 . 2 , 1 ( ) 1 , 5 , 2 ( * 5 . ) 4 , 6 ( ) 2 , 3 ( * 2 = = u * a u

13

Vector-Vector Multiplication

  • multiply: vector * vector = scalar
  • dot product, aka inner product

v u• ( ) ( ) ( )

3 3 2 2 1 1 3 2 1 3 2 1

v u v u v u v v v u u u

  • +
  • +
  • =
  • 14

Vector-Vector Multiplication

  • multiply: vector * vector = scalar
  • dot product, aka inner product

v u• ( ) ( ) ( )

3 3 2 2 1 1 3 2 1 3 2 1

v u v u v u v v v u u u

  • +
  • +
  • =
  • (

) ( ) ( )

3 3 2 2 1 1 3 2 1 3 2 1

v u v u v u v v v u u u

  • +
  • +
  • =
  • 15

Vector-Vector Multiplication

  • multiply: vector * vector = scalar
  • dot product, aka inner product

u1 u2 u3

  • v1

v2 v3

  • = u1 v1

( ) + u2 v2 ( ) + u3 v3 ( )

v u•

  • cos

v u v u =

  • u

v

  • geometric interpretation
  • lengths, angles
  • can find angle between two

vectors

16

Dot Product Geometry

  • can find length of projection of u onto v
  • as lines become perpendicular,
  • cos

v u v u =

  • u

v

  • cos

u

  • v

u v v u u

  • =
  • cos
slide-2
SLIDE 2

17

Dot Product Example

19 6 7 6 ) 3 * 2 ( ) 7 * 1 ( ) 1 * 6 ( 3 7 1 2 1 6 = + + = + + =

  • u1

u2 u3

  • v1

v2 v3

  • = u1 v1

( ) + u2 v2 ( ) + u3 v3 ( )

18

Vector-Vector Multiplication, The Sequel

  • multiply: vector * vector = vector
  • cross product
  • algebraic
  • =
  • 1

2 2 1 3 1 1 3 2 3 3 2 3 2 1 3 2 1

v u v u v u v u v u v u v v v u u u

19

Vector-Vector Multiplication, The Sequel

  • multiply: vector * vector = vector
  • cross product
  • algebraic
  • =
  • 1

2 2 1 3 1 1 3 2 3 3 2 3 2 1 3 2 1

v u v u v u v u v u v u v v v u u u

20

Vector-Vector Multiplication, The Sequel

  • multiply: vector * vector = vector
  • cross product
  • algebraic
  • =
  • 1

2 2 1 3 1 1 3 2 3 3 2 3 2 1 3 2 1

v u v u v u v u v u v u v v v u u u

blah blah

3 1 2

21

Vector-Vector Multiplication, The Sequel

  • multiply: vector * vector = vector
  • cross product
  • algebraic
  • geometric
  • parallelogram

area

  • perpendicular

to parallelogram

  • =
  • 1

2 2 1 3 1 1 3 2 3 3 2 3 2 1 3 2 1

v u v u v u v u v u v u v v v u u u

b a b a

  • sin

v u b a =

  • 22

RHS vs. LHS Coordinate Systems

  • right-handed coordinate system
  • left-handed coordinate system

x y z x y z

right hand rule: index finger x, second finger y; right thumb points up left hand rule: index finger x, second finger y; left thumb points down

y x z

  • =

y x z

  • =

convention

23

Basis Vectors

  • take any two vectors that are linearly

independent (nonzero and nonparallel)

  • can use linear combination of these to define

any other vector:

b a c

2 1

w w + =

24

Orthonormal Basis Vectors

  • if basis vectors are orthonormal (orthogonal

(mutually perpendicular) and unit length)

  • we have Cartesian coordinate system
  • familiar Pythagorean definition of distance

, 1 =

  • =

= y x y x

  • rthonormal algebraic properties

25

Basis Vectors and Origins j i

  • p

y x + + =

  • p

i j

  • coordinate system: just basis vectors
  • can only specify offset: vectors
  • coordinate frame: basis vectors and origin
  • can specify location as well as offset: points

26

Working with Frames

p

F F1

1

F F1

1

i j

  • j

i

  • p

y x + + =

27

Working with Frames

p

F F1

1

F F1

1

p = (3,-1) p = (3,-1)

i j

  • j

i

  • p

y x + + =

28

Working with Frames

p

F F1

1

F F1

1

p = (3,-1) p = (3,-1) F F2

2

i j

  • j

i

  • p

y x + + =

F F2

2

i j

  • 29

Working with Frames

p

F F1

1

F F1

1

p = (3,-1) p = (3,-1) F F2

2

p = (-1.5,2) p = (-1.5,2)

i j

  • j

i

  • p

y x + + =

F F2

2

i j

  • 30

Working with Frames

p

F F1

1

F F1

1

p = (3,-1) p = (3,-1) F F2

2

p = (-1.5,2) p = (-1.5,2) F F3

3

i j

F F2

2

i j

  • F

F3

3

i j

  • j

i

  • p

y x + + =

31

Working with Frames

p

F F1

1

F F1

1

p = (3,-1) p = (3,-1) F F2

2

p = (-1.5,2) p = (-1.5,2) F F3

3

p = (1,2) p = (1,2)

i j

F F2

2

i j

  • F

F3

3

i j

  • j

i

  • p

y x + + =

32

Named Coordinate Frames

  • origin and basis vectors
  • pick canonical frame of reference
  • then don’t have to store origin, basis vectors
  • just
  • convention: Cartesian orthonormal one on

previous slide

  • handy to specify others as needed
  • airplane nose, looking over your shoulder, ...
  • really common ones given names in CG
  • object, world, camera, screen, ...

) , , ( c b a = p z y x

  • p

c b a + + + =

slide-3
SLIDE 3

33

Lines

  • slope-intercept form
  • y = mx + b
  • implicit form
  • y – mx – b = 0
  • Ax + By + C = 0
  • f(x,y) = 0

34

Implicit Functions

  • find where function is 0
  • plug in (x,y), check if
  • 0: on line
  • < 0: inside
  • > 0: outside
  • analogy: terrain
  • sea level: f=0
  • altitude: function value
  • topo map: equal-value

contours (level sets)

35

Implicit Circles

  • circle is points (x,y) where f(x,y) = 0
  • points p on circle have property that vector

from c to p dotted with itself has value r2

  • points points p on the circle have property

that squared distance from c to p is r2

  • points p on circle are those a distance r from

center point c

2 2 2

) ( ) ( ) , ( r y y x x y x f

c c

  • +
  • =

) ( ) ( : ) , ( ), , (

2 =

  • =

= r y x c y x p

c c

c p c p

2 2

=

  • r

c p =

  • r

c p

36

Parametric Curves

  • parameter: index that changes continuously
  • (x,y): point on curve
  • t: parameter
  • vector form
  • =
  • )

( ) ( t h t g y x ) (t f = p

37

2D Parametric Lines

  • start at point p0,

go towards p1, according to parameter t

  • p(0) = p0, p(1) = p1

x y

  • = x0 + t(x1 x0)

y0 + t(y1 y0)

  • )

( ) (

1

p p p p

  • +

= t t ) ( ) ( d

  • p

t t + =

38

Linear Interpolation

  • parametric line is example of general concept
  • interpolation
  • p goes through a at t = 0
  • p goes through b at t = 1
  • linear
  • weights t, (1-t) are linear polynomials in t

) ( ) (

1

p p p p

  • +

= t t

39

Matrix-Matrix Addition

  • add: matrix + matrix = matrix
  • example
  • +

+ + + =

  • +
  • 22

22 21 21 12 12 11 11 22 21 12 11 22 21 12 11

m n m n m n m n n n n n m m m m

  • =
  • +

+ +

  • +

=

  • +
  • 5

9 8 1 1 4 7 2 5 3 ) 2 ( 1 1 7 5 2 4 2 3 1

40

Scalar-Matrix Multiplication

  • multiply: scalar * matrix = matrix
  • example
  • =
  • 22

21 12 11 22 21 12 11

* * * * m a m a m a m a m m m m a

  • =
  • =
  • 15

3 12 6 5 * 3 1 * 3 4 * 3 2 * 3 5 1 4 2 3

41

Matrix-Matrix Multiplication

  • can only multiply (n,k) by (k,m):

number of left cols = number of right rows

  • legal
  • undefined
  • m

l k j i h g f e c b a

  • k

j i h q g p f

  • e

c b a

42

Matrix-Matrix Multiplication

  • row by column
  • =
  • 22

21 12 11 22 21 12 11 22 21 12 11

p p p p n n n n m m m m

21 12 11 11 11

n m n m p + =

43

Matrix-Matrix Multiplication

  • row by column
  • =
  • 22

21 12 11 22 21 12 11 22 21 12 11

p p p p n n n n m m m m

21 12 11 11 11

n m n m p + =

21 22 11 21 21

n m n m p + =

44

Matrix-Matrix Multiplication

  • row by column
  • =
  • 22

21 12 11 22 21 12 11 22 21 12 11

p p p p n n n n m m m m

21 12 11 11 11

n m n m p + =

22 12 12 11 12

n m n m p + =

21 22 11 21 21

n m n m p + =

45

Matrix-Matrix Multiplication

  • row by column
  • =
  • 22

21 12 11 22 21 12 11 22 21 12 11

p p p p n n n n m m m m

21 12 11 11 11

n m n m p + =

22 12 12 11 12

n m n m p + =

21 22 11 21 21

n m n m p + =

22 22 12 21 22

n m n m p + =

46

Matrix-Matrix Multiplication

  • row by column
  • noncommutative: AB != BA
  • =
  • 22

21 12 11 22 21 12 11 22 21 12 11

p p p p n n n n m m m m

21 12 11 11 11

n m n m p + =

22 12 12 11 12

n m n m p + =

21 22 11 21 21

n m n m p + =

22 22 12 21 22

n m n m p + =

47

Matrix-Vector Multiplication

  • points as column vectors: postmultiply
  • points as row vectors: premultiply
  • =
  • h

z y x m m m m m m m m m m m m m m m m h z y x

44 43 42 41 34 33 32 31 24 23 22 21 14 13 12 11

' ' ' '

Mp p'=

[ ] [ ]

T

m m m m m m m m m m m m m m m m h z y x h z y x

  • =

44 43 42 41 34 33 32 31 24 23 22 21 14 13 12 11

' ' ' '

T T T

M p p' =

48

Matrices

  • transpose
  • identity
  • inverse
  • not all matrices are invertible
  • =
  • 44

34 24 14 43 33 23 13 42 32 22 12 41 31 21 11 44 43 42 41 34 33 32 31 24 23 22 21 14 13 12 11

m m m m m m m m m m m m m m m m T m m m m m m m m m m m m m m m m

  • 1

1 1 1

I AA =

1

slide-4
SLIDE 4

49

Matrices and Linear Systems

  • linear system of n equations, n unknowns
  • matrix form Ax=b

1 2 5 1 3 4 2 4 2 7 3 = + +

  • =
  • =

+ + z y x z y x z y x

  • =
  • 1

1 4 1 2 5 3 4 2 2 7 3 z y x