Docsity

Scalars - Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Scalars - Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Computer Graphics Points, Scalars and Vectors

Points, Scalars and Vectors n Points, vectors defined relative to a coordinate system

Points n Location in coordinate system n Cannot add or scale n Subtract 2 points = vector Point

Vector-Point Relationship n Diff. b/w 2 points = vector v = Q – P n Sum of point and vector = point v + P = Q P Q v

Vector Operations n Scaling vector by a scalar ( , , ) 1 2 3 a s = a s a s a s ( ( ), ( ), ( )) 1 1 2 2 3 3 = a + − b a + − b a + − b a − b Note vector subtraction: a b a a-b 2.5a

Vector Operations: Examples n Scaling vector by a scalar n For example, if a =(2,5,6) and b = (-2,7,1) and s =6, then

1 2 3 a s = a s a s a s •Vector addition: ( , ) 1 1 , 2 2 3 3 a + b = a + b a + b a + b ( , ) ( 0 , 12 , 7 ) 1 1 , 2 2 3 3 a + b = a + b a + b a + b = ( , , ) ( 12 , 30 , 36 ) 1 2 3 a s = a s a s a s =

Magnitude of a Vector n Magnitude of a n Normalizing a vector (unit vector) n Note magnitude of normalized vector = 1. i.e 2 2 2 2 1

n

a = a + a + a

magnitude

vector

a

a

a ˆ

.......... 1 2 2 2 2 1

    • = n a a a

Dot Product (Scalar product) n Dot product, n For example, if a =(2,3,1) and b= (0,4,-1) then 1 1 2 2 3 3

d = a ⋅ b = a ⋅ b + a ⋅ b ........ + a ⋅ b

a ⋅ b = 2 ⋅ 0 + 3 ⋅ 4 + 1 ⋅− 1

Dot Product n Try your hands at these: n ( 2, 2, 2, 2)•( 4, 1, 2, 1.1) = 8 + 2 + 4 + 2.2 = 16. n ( 2, 3, 1)•( 0, 4, -1) = 0 + 12 –1 = 11

Properties of Dot Products n Symmetry (or commutative): n Linearity: n Homogeneity: n And

a ⋅ b = b ⋅ a

( s a ) ⋅ b = s ( a ⋅ b )

( a + c )⋅ b = a ⋅ b + c ⋅ b

b = b ⋅ b

2

Angle Between Two Vectors n Find the angle b/w the vectors b = (3,4) and c = (5,2)

Angle Between Two Vectors n Find the angle b/w the vectors b = (3,4) and c = (5,2) n | b |= 5, | c |= 5.       = 5 4 , 5 3 ˆ b (^) b ˆ^ • c ˆ = 0. 85422 =cos θ o θ = 31. 326

Cross Product (Vector product)

x y z

a = a , a , a ( )

x y z

b = b , b , b

If Then a b ( ) i ( ) j ( ) k y z z y x z z x x y y x × = a b − a b − a b − a b + a b − a b Remember using determinant x y z x y z

b b b

a a a

i j k

Note: a x b is perpendicular to a and b

Cross Product Note: a x b is perpendicular to both a and b a x b a 0 b