0% found this document useful (0 votes)
51 views23 pages

CS 543: Computer Graphics Lecture 3 (Part II) : Points, Scalars and Vectors

Points define a location in space using coordinates from a reference frame, while vectors define direction and magnitude without specifying position. Common vector operations include addition, subtraction, and scaling by scalars. The dot product between two vectors yields a scalar value that can indicate the cosine of the angle between the vectors. The cross product produces a vector perpendicular to both input vectors and is useful for computing properties like surface normals in 3D graphics.

Uploaded by

Chi Hana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views23 pages

CS 543: Computer Graphics Lecture 3 (Part II) : Points, Scalars and Vectors

Points define a location in space using coordinates from a reference frame, while vectors define direction and magnitude without specifying position. Common vector operations include addition, subtraction, and scaling by scalars. The dot product between two vectors yields a scalar value that can indicate the cosine of the angle between the vectors. The cross product produces a vector perpendicular to both input vectors and is useful for computing properties like surface normals in 3D graphics.

Uploaded by

Chi Hana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

CS 543: Computer Graphics

Lecture 3 (Part II): Points, Scalars and Vectors

Emmanuel Agu
Points, Scalars and Vectors

n Points, vectors defined relative to a coordinate system


Vectors

n Magnitude
n Direction
n NO position
n Can be added, scaled, rotated Length
n CG vectors: 2, 3 or 4
dimensions

Angle
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 =


P
point
v
v+P=Q
Q
Vector Operations

n Define vectors
Then vector addition:
a = (a1, a2 , a3 )
b = (b1,b2 , b3 ) a + b = (a1 + b1, a2 + b2 , a3 + b3 )

n and scalar, s

a
a+b

b
Vector Operations

n Scaling vector by a scalar


Note vector subtraction:

as = (a1s, a2 s, a3 s ) a−b
= (a1 + (−b1 ), a2 + (−b2 ), a3 + (−b3 ))

a a-b
a

2.5a b
Vector Operations: Examples

n Scaling vector by a scalar •Vector addition:

as = (a1s, a2 s, a3 s ) a + b = (a1 + b1, a2 + b2 , a3 + b3 )

n For example, if a=(2,5,6) and


b=(-2,7,1) and s=6, then

a + b = (a1 + b1, a2 + b2 , a3 + b3 ) = (0,12,7)

as = (a1s, a2 s, a3 s ) = (12,30,36)
Affine Combination

n Summation of all components = 1

a1 + a2 + .........an = 1

n Convex affine = affine + no negative component

a1 , a2 ,.........an = non − negative


Magnitude of a Vector

n Magnitude of a

| a |= a1 + a2 .......... + an
2 2 2

n Normalizing a vector (unit vector)


a vector
â = =
a magnitude
n Note magnitude of normalized vector = 1. i.e

a1 + a2 .......... + an = 1
2 2 2
Dot Product (Scalar product)

n Dot product,

d = a ⋅ b = a1 ⋅ b1 + a2 ⋅ b2 ........ + a3 ⋅ b3

n For example, if a=(2,3,1) and b=(0,4,-1)


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

= 0 + 12 − 1 = 11
Dot Product

n Try your hands at these:


n ( 2, 2, 2, 2)•( 4, 1, 2, 1.1)
n ( 2, 3, 1)•( 0, 4, -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.2
n ( 2, 3, 1)•( 0, 4, -1) = 0 + 12 –1 = 11
Properties of Dot Products

n Symmetry (or commutative):

a⋅b = b ⋅a
n Linearity:
(a + c) ⋅ b = a ⋅ b + c ⋅ b
n Homogeneity:

( sa) ⋅ b = s (a ⋅ b)
n And
b2 = b ⋅ b
Angle Between Two Vectors

y
c b = ( b cos φb , b sin φb )

c = ( c cos φc , c sin φc )
θ b
φc b ⋅ c = b c cosθ
φb
x
b b
b
Sign of b.c:
c c c
b.c > 0
b.c = 0 b.c < 0
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.385

3 4
b̂ =  ,  bˆ • cˆ = 0.85422 = cosθ
5 5

θ = 31.326o
Standard Unit Vectors

Define y

i = (1,0,0)
k i

j = (0,1,0)

k = (0,0,1)
0 j

z x
So that any vector,

v = (a, b, c ) = ai + bj + ck
Cross Product (Vector product)

If
a = (a x , a y , a z ) b = (bx , by , bz )
Then
a × b = (a y bz − a z by )i − (a x bz − a z bx ) j + (a x by − a y bx )k
Remember using determinant
i j k
ax ay az
bx by bz

Note: a x b is perpendicular to a and b


Cross Product

Note: a x b is perpendicular to both a and b

axb

0
a b
Cross Product

Calculate a x b if a = (3,0,2) and b = (4,1,8)


Cross Product

Calculate a x b if a = (3,0,2) and b = (4,1,8)

a x b = -2i – 16j + 3k
References

n Hill, chapter 4.2 - 4.4

You might also like