Linear Algebra Recap

advertisement
COMP 175 | COMPUTER GRAPHICS
Lecture 03:
Linear Algebra
COMP 175: Computer Graphics
January 29, 2015
Remco Chang
03 – Linear Algebra
1/50
COMP 175 | COMPUTER GRAPHICS
Administrative



Assignment 1
Algorithm Worksheet
Programming Assignment
Due in 1 Week
Due in 2 Weeks
“Demo” to the TA
(see Google Doc sign up sheet)
Demo to me
(schedule to be announced)
How did Lab 0 go?
A few notes about Assignment 1


Algebra.h
Why is this bad? How to fix it?
float val = getVal();
if (val == 1.0) {
//do something
}
Remco Chang
03 – Linear Algebra
2/50
COMP 175 | COMPUTER GRAPHICS
Linear Algebra for 3D Graphics

Linear Algebra that you should know…





3D Coordinate Geometry
3D Points and Vectors
dot products and cross products
Vector and Matrix notations and algebra
Properties of matrix multiplication (associative property,
but NOT communicative property)



Associative => (5 + 2) + 1 = 5 + (2 + 1)
Commutative => 5 +2 + 1 = 1 + 2 + 5
Matrix operations (multiplication, transpose, inverse,
etc.)
Remco Chang
03 – Linear Algebra
3/50
COMP 175 | COMPUTER GRAPHICS
Cartesian Coordinate System

1D, 2D, and 3D real coordinate spaces
R3
Y
R1
5
4
3
2
1
R2
-5 -4 -3 -2 -1 0 1 2 3 4 5
-5 -4 -3 -2 -1
-1
-2
-3
-4
-5

1 2 3 4 5
X
Y
5
4
3
2
1
-5 -4 -3 -2 -1
-1
-2
-3
-4
-5
Z
1 2 3 4 5
Compare this with positive integer coordinate
spaces
…
1 2 3 4 5
…
1024
“normal” coordinate axes
5
4
3
2
1
1 2 3 4 5
computer screen axes
…
03 – Linear Algebra
1024
1024
…
0
Remco Chang
0
1
2
3
4
5
1024
4/50
COMP 175 | COMPUTER GRAPHICS
Points

Denotes a location in the Cartesian coordinate
system
Y
R3
5
4
R2
3
2
2
1
1
-5 -4 -3 -2 -1
-1
Remco Chang
5
4
Point at (2, 3)
3
Y
X
1
2
3
4
-5 -4 -3 -2 -1
5
-1
-2
-2
-3
-3
-4
-4
-5
-5
Z
03 – Linear Algebra
1
2
3
4
5
Point at
(4, -2, 3)
5/50
COMP 175 | COMPUTER GRAPHICS
Vectors

Denotes:




Magnitude
Direction
NO POSITION!!
In ℝ𝑑 , a vector can be defined as
an ordered d-tuple:
𝑣1
𝑣2
𝑣= ⋮
𝑣𝑑

A vector 𝑣 is often written as 𝑣
for clarity
Remco Chang
03 – Linear Algebra
6/50
COMP 175 | COMPUTER GRAPHICS
Vectors

Because a vector has no
position, one way to think of
𝑣𝑥
a 2D vector 𝑣 = 𝑣 is as an
𝑦
“offset from the origin”.

Such offset can be translated
(moved around)
Remco Chang
03 – Linear Algebra
7/50
COMP 175 | COMPUTER GRAPHICS
Vectors - Length

Find the length of the following vector:
Remco Chang
03 – Linear Algebra
8/50
COMP 175 | COMPUTER GRAPHICS
Vectors - Length

𝑣𝑥
the Euclidean length of a 2D vector 𝑣 = 𝑣 is:
𝑦
𝑣 =

𝑣1
𝑣2
The length of a 𝑑-dimensional vector 𝑣 = ⋮ is:
𝑣𝑑
𝑣 =

𝑣𝑥 2 + 𝑣𝑦 2
𝑣1 2 + 𝑣2 2 + 𝑣3 2 + ⋯ + 𝑣𝑑 2
Note that the length of a vector is sometimes called the
“norm” of the vector
Remco Chang
03 – Linear Algebra
9/50
COMP 175 | COMPUTER GRAPHICS
Vectors – Scalar Multiple


𝑣1
𝑣2
For a vector 𝑣 = ⋮ , the vector can be multiplied
𝑣𝑑
by a scalar value 𝛼 such that the resulting vector 𝑣′
is:
𝑣1
𝛼𝑣1
𝑣2
𝛼𝑣2
′
𝑣 = 𝛼𝑣 = 𝛼 ⋮ = ⋮
𝑣𝑑
𝛼𝑣𝑑
Question: what happens when 𝛼 is negative?
Remco Chang
03 – Linear Algebra
10/50
COMP 175 | COMPUTER GRAPHICS
Vectors – Scalar Multiple



5
Examples of scalar multiples of the vector 𝑣 =
1
These vectors are said to be parallel to the vector 𝑣.
Question: What happens if 𝛼 = 0?
Remco Chang
03 – Linear Algebra
11/50
COMP 175 | COMPUTER GRAPHICS
Vectors – Unit Vector

If I don’t care about magnitude of the vector – that is,
all I care about is the direction, I can represent the
vector 𝑣 such that: 𝑣 = 1

This vector 𝑣 is said to be a “unit vector” (often
denoted as 𝑣, called v-hat), and the process of making a
vector be of length = 1 is called “normalization”.
Remco Chang
03 – Linear Algebra
12/50
COMP 175 | COMPUTER GRAPHICS
Vectors – Unit Vector

Question: Given a vector 𝑣,
how do you find 𝑣?

Question: Can every vector be
normalized?

Question, what is the equation
of a line using vector math?


What about a point on the line?
A range along the line (i.e. line
segment)?
Remco Chang
03 – Linear Algebra
13/50
COMP 175 | COMPUTER GRAPHICS
Vectors - Addition

Addition of vectors is commutative (and
associative).
2
4
𝑣=
,𝑢 =
3
2
10
10
9
9
8
8
7
7
6
6
5
5
4
4
v
3
v+u
v
3
2
2
u
1
u
1
1
Remco Chang
2
3
4
5
6
7
8
9
10
03 – Linear Algebra
1
2
3
4
5
6
7
8
9
10
14/50
COMP 175 | COMPUTER GRAPHICS
Vectors - Addition

Addition of vectors is commutative (and
associative).
10
10
9
9
8
8
7
7
6
6
5
5
4
4
v
3
u+v
v
3
2
2
u
1
1
u
1
Remco Chang
2
3
4
5
6
7
8
9
10
03 – Linear Algebra
1
2
3
4
5
6
7
8
9
10
15/50
COMP 175 | COMPUTER GRAPHICS
Vectors – Addition

Given two vectors,
2
4
𝑣=
,𝑢 =
3
2
10
9
8
7
6
5
v+u
4
v
3
2
u
1
2
6
4
𝑣+𝑢 =
+
=
3
2
5
1
2
3
4
5
6
7
8
9
10
10
9
Which is equal to:
8
7
6
5
u+v
4
𝑢+𝑣 =
2
6
4
+
=
2
3
5
v
3
2
1
u
1
Remco Chang
03 – Linear Algebra
2 3
4
5
6
7
8
9
10
16/50
COMP 175 | COMPUTER GRAPHICS
Vectors - Subtraction


Subtraction works the
same as addition (with
negative values):
Given two vectors,
2
4
𝑣=
,𝑢 =
3
2
2
4
−2
𝑣−𝑢 =
−
=
3
2
1
5
4
v
3
-u
-4
-u
-3 -2
u
2
1
-1
-1
-2
1
2
3
4
5
-3
-4
Remco Chang
03 – Linear Algebra
17/50
COMP 175 | COMPUTER GRAPHICS
Vectors – Basis

1
Give two vectors 𝑢 =
,
0
0
and 𝑣 =
1
2
1.8
1.6

There are two interesting
things about 𝑢, and 𝑣:


They are perpendicular to each
other
They are both unit vectors
Remco Chang
03 – Linear Algebra
1.4
1.2
1
𝑣
0.8
0.6
0.4
𝑢
0.2
0.2 0.4 0.6
0.8
1
1.2 1.4 1.6 1.8 2
18/50
COMP 175 | COMPUTER GRAPHICS
Vectors – Basis

1
0
For 𝑢 =
, and 𝑣 =
:
0
1
2
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
They are perpendicular to each other
(𝑢, and 𝑣 are said to be “orthogonal” to each other)
 They are both unit vectors

𝑣
𝑢
0.2 0.40.6 0.8 1 1.2 1.4 1.6 1.82
𝑥
1
0
=
𝑥𝑢
+
𝑦𝑣
=
𝑥
+
𝑦
𝑦
0
1


These two vectors form the 2D Cartesian Coordinate
System.
1
0
We can say that 𝑢 =
and 𝑣 =
are the “basis
0
1
vectors” of the 2D Cartesian Coordinate System
Remco Chang
03 – Linear Algebra
19/50
COMP 175 | COMPUTER GRAPHICS
Vector - Basis

1
0
, and 𝑣 =
, we
0
1
say that the two vectors form
an “orthonormal basis”
because they:
For 𝑢 =


Are orthogonal to each other,
and
Are both unit vectors
Remco Chang
03 – Linear Algebra
20/50
COMP 175 | COMPUTER GRAPHICS
Vectors – Basis

It turns out, any two
“linearly independent”
vectors, 𝑢, 𝑣, can form a 2D
basis.
10
9
𝑤 = 1.5𝑣 + 0.5𝑢
8
7
6

In other words, given a
vector 𝑤, we can always
express 𝑤 as a linear
combination of the basis
vectors 𝑢, 𝑣
Remco Chang
03 – Linear Algebra
5
4
𝑣
3
2
𝑢
1
1
2
3
4
5
6
7
8
9
10
21/50
COMP 175 | COMPUTER GRAPHICS
Vector - Basis

More formally, given a 2D vector 𝑤, we can express
it using two basis vectors 𝑢 and 𝑣:
𝑢1
𝑣1
𝑎𝑢1 + 𝑏𝑣1
𝑛
𝑤=
= 𝑎𝑢 + 𝑏𝑣 = 𝑎 𝑢 + 𝑏 𝑣 =
𝑚
𝑎𝑢2 + 𝑏𝑣2
2
2

Question: Can you think of two vectors that
CANNOT form basis vectors for a 2D space?

(Hint: think linear independence)
Remco Chang
03 – Linear Algebra
22/50
COMP 175 | COMPUTER GRAPHICS
Vector - Basis
𝑢1
𝑣1
𝑎𝑢1 + 𝑏𝑣1
𝑛
𝑤=
= 𝑎𝑢 + 𝑏𝑣 = 𝑎 𝑢 + 𝑏 𝑣 =
𝑚
𝑎𝑢2 + 𝑏𝑣2
2
2
OK

OK
not OK
not OK
The last two conditions are NOT ok because the
two vectors are “linearly dependent”.

That is, one vector is the scalar multiple of the other
Remco Chang
03 – Linear Algebra
23/50
COMP 175 | COMPUTER GRAPHICS
Algebraic Properties of Vectors







Commutative: 𝒗 + 𝒖 = 𝒖 + 𝒗
Associative: 𝒗 + 𝒖 + 𝒘 = 𝒗 + (𝒖 + 𝒘)
Additive identity: there is a vector 0 (the null
vector), such that: ∀𝒗: 𝒗 + 𝟎 = 𝒗 = (𝟎 + 𝒗)
Additive inverse: ∀𝒗, ∃ −𝒗 : 𝒗 + −𝒗 = 𝟎
Distributive (vector): 𝜶 𝒗 + 𝒖 = 𝜶𝒗 + 𝜶𝒖
Distributive (scalar): 𝜶 + 𝜷 𝒗 = 𝜶𝒗 + 𝜷v
Multiplicative identity: For any 𝒗, 𝟏 ∈ ℝ, 𝟏 ∙ 𝒗 = 𝒗
Remco Chang
03 – Linear Algebra
24/50
COMP 175 | COMPUTER GRAPHICS
Questions?
Remco Chang
03 – Linear Algebra
25/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product


The Cross Product of two vectors is a vector that is
perpendicular to both original vectors. That is, it is
normal to the plane containing the two vectors.
𝑣1
𝑢1
Given two vectors 𝑣 = 𝑣2 and 𝑢 = 𝑢2 , the cross
𝑣3
𝑢3
product is written as 𝑣 × 𝑢.
Remco Chang
03 – Linear Algebra
26/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product




Important Note:
Cross Product is not commutative. That is:
𝑣×𝑢 ≠𝑢×𝑣
In fact,
𝑣 × 𝑢 = −(𝑢 × 𝑣)
The “Right Hand Rule”
Remco Chang
03 – Linear Algebra
27/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product

𝑣𝑥
More formally: the cross product of 𝑣 = 𝑣𝑦 and
𝑣𝑧
𝑢𝑥
𝑢𝑥
𝑣𝑥
𝑢 = 𝑢𝑦 is written as: 𝑣 × 𝑢 = 𝑣𝑦 × 𝑢𝑦 , and is
𝑢𝑧
𝑣𝑧
𝑢𝑧
defined as:
𝑣𝑦 𝑢𝑧 − 𝑣𝑧 𝑢𝑦
𝑢𝑥
𝑣𝑥
𝑣𝑦 × 𝑢𝑦 = 𝑣𝑧 𝑢𝑥 − 𝑣𝑥 𝑢𝑧
𝑣𝑥 𝑢𝑦 − 𝑣𝑦 𝑢𝑥
𝑣𝑧
𝑢𝑧
Remco Chang
03 – Linear Algebra
28/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product


In addition, it is important to note
that:
𝑣×𝑢 ≠1
That is, the cross product of two
vectors is not a normal vector
(unless… (see below)).
In fact,
𝑣 × 𝑢 = 𝑣 𝑢 sin 𝜃
where 𝜃 is the angle between the two
vectors 𝑢 and 𝑣.


What is the area of a parallelogram?
Remco Chang
03 – Linear Algebra
29/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product


If you think about it, this equation:
𝑣 × 𝑢 = 𝑣 𝑢 sin 𝜃
says that the magnitude of the cross product is “how
perpendicular 𝑣 and 𝑢 are”


Hint, think about the 𝜃. If 𝜃 = 90, then sin 𝜃 = 1
Since the magnitude of a 3D vector is:
𝑣 =

𝑣𝑥 2 + 𝑣𝑦 2 + 𝑣𝑧 2
We can think of the cross product as the “magnitude”
of the sum of the x, y, and z components
Remco Chang
03 – Linear Algebra
30/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product

Deriving the cross product… For a simple 2D Case:
Remco Chang
03 – Linear Algebra
31/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product

When the axes are x and y, we get:
𝑎𝑟𝑒𝑎(𝑥,𝑦) = 𝐴𝑥 𝐵𝑦 − 𝐵𝑥 𝐴𝑦

We could have easily labeled the axes as y and z, or z
and x, and we would get:
𝑎𝑟𝑒𝑎(𝑦,𝑧) = 𝐴𝑦 𝐵𝑧 − 𝐵𝑦 𝐴𝑧
𝑎𝑟𝑒𝑎(𝑧,𝑥) = 𝐴𝑧 𝐵𝑥 − 𝐵𝑧 𝐴𝑥

In other words, if we take two 3D vectors, and project
them down to the (x,y), (y,z), and (z,x) planes, we could
get the areas of the parallelogram in each of the planes.
Remco Chang
03 – Linear Algebra
32/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product

Since we can think of the (x,y) plane as defined by a
0
unit vector 𝑧 = 0 at the origin (0, 0, 0). Meaning
1
that we can think of the relationship as: 𝑧 = 𝑥 × 𝑦,
we can rewrite the previous equations as:
𝑎𝑟𝑒𝑎(𝑥,𝑦) = (𝐴𝑥 𝐵𝑦 − 𝐵𝑥 𝐴𝑦 )𝑧

Similarly:
𝑎𝑟𝑒𝑎(𝑦,𝑧) = (𝐴𝑦 𝐵𝑧 − 𝐵𝑦 𝐴𝑧 )𝑥
𝑎𝑟𝑒𝑎(𝑧,𝑥) = (𝐴𝑧 𝐵𝑥 − 𝐵𝑧 𝐴𝑥 )𝑦
Remco Chang
03 – Linear Algebra
33/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product
𝑎𝑟𝑒𝑎(𝑥,𝑦) = (𝐴𝑥 𝐵𝑦 − 𝐵𝑥 𝐴𝑦 )𝑧
𝑎𝑟𝑒𝑎(𝑦,𝑧) = (𝐴𝑦 𝐵𝑧 − 𝐵𝑦 𝐴𝑧 )𝑥
𝑎𝑟𝑒𝑎(𝑧,𝑥) = (𝐴𝑧 𝐵𝑥 − 𝐵𝑧 𝐴𝑥 )𝑦

Or more simply:
𝐴𝑦 𝐵𝑧 − 𝐴𝑧 𝐵𝑦
𝐴𝑥
𝐵𝑥
𝐴𝑦 × 𝐵𝑦 = 𝐴𝑧 𝐵𝑥 − 𝐴𝑥 𝐵𝑧
𝐴𝑥 𝐵𝑦 − 𝐴𝑦 𝐵𝑥
𝐵𝑧
𝐴𝑧
Remco Chang
03 – Linear Algebra
34/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product


Another way to derive the cross product:
Let’s say that we’re in ℝ3 , which is formed by three
orthonormal basis vectors: (𝑖, 𝑗, 𝑘)


1
0
If it makes things easier, you can imagine 𝑖 = 0 , 𝑗 = 1 , and
0
0
0
𝑘= 0.
1
Based on our definition of the cross product:
𝑖×𝑖 =𝑗×𝑗 =𝑘×𝑘 =0
𝑖 × 𝑗 = 𝑘, 𝑗 × 𝑘 = 𝑖, 𝑘 × 𝑖 = 𝑗
𝑗 × 𝑖 = −𝑘, 𝑘 × 𝑗 = −𝑖, 𝑖 × 𝑘 = −𝑗
Remco Chang
03 – Linear Algebra
35/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product


𝑢𝑥
𝑣𝑥
Given two 𝑣 = 𝑣𝑦 and 𝑢 = 𝑢𝑦 , we can rewrite
𝑣𝑧
𝑢𝑧
each as a sum of its components in the i, j, k basis,
such that:
𝑣 = (𝑣𝑥 𝑖 + 𝑣𝑦 𝑗 + 𝑣𝑧 𝑘), and 𝑢 = (𝑢𝑥 𝑖 + 𝑢𝑦 𝑗 + 𝑢𝑧 𝑘)
So 𝑣 × 𝑢 =
𝑣𝑥 𝑖 + 𝑣𝑦 𝑗 + 𝑣𝑧 𝑘 × 𝑢𝑥 𝑖 + 𝑢𝑦 𝑗 + 𝑢𝑧 𝑘 =
𝑣𝑥 𝑢𝑥 𝑖 × 𝑖 + 𝑣𝑥 𝑢𝑦 𝑖 × 𝑗 + ⋯ =
𝑣𝑦 𝑢𝑧 − 𝑣𝑧 𝑢𝑦 𝑖 + 𝑣𝑧 𝑢𝑥 − 𝑣𝑥 𝑢𝑧 𝑗 + 𝑣𝑥 𝑢𝑦 − 𝑣𝑦 𝑢𝑥 𝑘
Remco Chang
03 – Linear Algebra
36/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product


One More Thought:
For those of you who are ninja’s in linear algebra.
You might have already noticed that:
𝑖
𝑣 × 𝑢 = det 𝑣𝑥
𝑢𝑥

𝑗
𝑣𝑦
𝑢𝑦
𝑘
𝑣𝑧
𝑢𝑧
Recall that the determinant of a matrix is:
𝑣𝑦 𝑢𝑧 𝑖 − 𝑣𝑧 𝑢𝑦 𝑖 + 𝑣𝑧 𝑢𝑥 𝑗 − 𝑣𝑥 𝑢𝑧 𝑗 + 𝑣𝑥 𝑢𝑦 𝑘 − 𝑣𝑦 𝑢𝑥 𝑘
Remco Chang
03 – Linear Algebra
37/50
COMP 175 | COMPUTER GRAPHICS
Vector – Cross Product

Recall that the determinant of a matrix is:
𝑣𝑦 𝑢𝑧 𝑖 − 𝑣𝑧 𝑢𝑦 𝑖 + 𝑣𝑧 𝑢𝑥 𝑗 − 𝑣𝑥 𝑢𝑧 𝑗 + 𝑣𝑥 𝑢𝑦 𝑘 − 𝑣𝑦 𝑢𝑥 𝑘

Organize the terms a little bit, and you get:
𝑣𝑦 𝑢𝑧 − 𝑣𝑧 𝑢𝑦
𝑢𝑥
𝑣𝑥
𝑣𝑦 × 𝑢𝑦 = 𝑣𝑧 𝑢𝑥 − 𝑣𝑥 𝑢𝑧
𝑣𝑥 𝑢𝑦 − 𝑣𝑦 𝑢𝑥
𝑣𝑧
𝑢𝑧
Remco Chang
03 – Linear Algebra
38/50
COMP 175 | COMPUTER GRAPHICS
Questions?
Remco Chang
03 – Linear Algebra
39/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product

Basic Formula:

For two vectors, 𝑢 and 𝑣 ∈ ℝ𝑑 , the dot product (or
“inner product” or “scalar product”) is defined as:
𝑢 ∙ 𝑣 = 𝑢1 𝑣1 + 𝑢2 𝑣2 + ⋯ + 𝑢𝑑 𝑣𝑑

Or,
𝑑
𝑢∙𝑣 =
𝑢𝑖 𝑣𝑖
𝑖=1
Remco Chang
03 – Linear Algebra
40/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product

As it turns out, if 𝑢 and 𝑣 are two non-zero vectors:
𝑢∙𝑣 = 𝑢
𝑣 cos(𝜃)
𝑢
𝜃
𝑣
Remco Chang
03 – Linear Algebra
41/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product

This is important because if I want to know the angle
between two vectors, I can trivially compute:
𝑢∙𝑣 = 𝑢
𝑣 cos 𝜃
𝑢∙𝑣
cos 𝜃 =
𝑢 𝑣
𝑢∙𝑣
−1
𝜃 = cos (
)
𝑢 𝑣

Note that if both 𝑢 and 𝑣 are unit vectors, then:
𝜃 = cos −1 (𝑢 ∙ 𝑣)

Note that 𝜃 will be in radians (that is, 0 ≤ 𝜃 ≤ 𝜋)
Remco Chang
03 – Linear Algebra
42/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product

Other useful things with dot products

What are the results?
Remco Chang
03 – Linear Algebra
43/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product

Other useful things with dot products
Remco Chang
03 – Linear Algebra
44/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product

Determining “front” vs. “back” facing triangles


Back-face culling
How to find the “normal vector”?
Remco Chang
03 – Linear Algebra
45/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product

Example:


Perpendicular vectors always have a dot product of 0
because the cosine of 90o is 0
4
−3
, and 𝑣 =
3
4
For 𝑢 =
𝑢 ∙ 𝑣 = 4 ∙ −3 + 3 ∙ −4 = 0
5
𝑣
4
𝑢
3
𝑢∙𝑣 = 𝑢
2
1
-5
Remco Chang
-4
-3
-2
-1
1
2
3
03 – Linear Algebra
4
𝜋
𝑣 cos( ) = 0
2
5
46/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product


More use of the Dot Product: Finding the length
of a projection
If 𝑢 is a unit vector, then 𝑣 ∙ 𝑢 is the length of the
projection of 𝑣 onto the line containing 𝑢
Recall dot product:
𝑣 ∙ 𝑢 = |𝑣||𝑢| cos 𝜃
v
𝛼
𝜃 = (𝛼 − 𝜙)
u
u’
If |𝑢| = 1, then
𝑣 ∙ 𝑢 = 𝑣 cos 𝜃 = |𝑢′ |
𝜙
Remco Chang
03 – Linear Algebra
47/50
COMP 175 | COMPUTER GRAPHICS
Vector – Dot Product


Prove that: 𝑢 ∙ 𝑣 = 𝑢 𝑣 cos 𝜃
𝑣𝑥
cos 𝛼
𝑣= 𝑣 = 𝑣
sin 𝛼
𝑦
𝑢𝑥
cos 𝜙
𝑢= 𝑢 = 𝑢
sin 𝜙
𝑦
cos 𝜙
cos 𝛼
𝑢∙𝑣 = 𝑣
∙ 𝑢
sin 𝛼
sin 𝜙
cos 𝜙
cos 𝛼
= 𝑣 𝑢
∙
sin 𝛼
sin 𝜙
= 𝑣 𝑢 (cos 𝛼 cos 𝜙 + sin 𝛼 sin 𝜙)
By trigonometric identity: (see proof:
http://www.themathpage.com/atrig/sumproof.htm)
cos 𝛼 cos 𝜙 + sin 𝛼 sin 𝜙 = cos(𝛼 − 𝜙)
 So,
𝑢 ∙ 𝑣 = 𝑢 𝑣 cos 𝛼 − 𝜙 = 𝑢 𝑣 cos 𝜃
Remco Chang
03 – Linear Algebra
radius = ||v||
|v| sin()
|v| cos()
𝑣
𝛼
𝜃 = (𝛼 − 𝜙)
𝑢
𝜙
48/50
COMP 175 | COMPUTER GRAPHICS
Questions?
Remco Chang
03 – Linear Algebra
49/50
COMP 175 | COMPUTER GRAPHICS
Exercises:
What is the result? A point 𝑝, a vector 𝑣, and a vector
𝑢, or a scalar 𝛼?
1.
1.
2.
3.
4.
5.
6.
7.
8.
𝑣 + 𝑣 =?
𝑝 + 𝑣 =?
𝑝 − 𝑝 =?
𝑝 + 𝑝 =?
𝑣 × 𝑢 =?
𝑣 × 𝑣 =?
𝑣 ∙ 𝑢 =?
𝑣 ∙ 𝑣 =?
Show that 𝑣 × 𝑢 is orthogonal to both 𝑣 and 𝑢
2.

Hint: how to test if two vectors are orthogonal?
Remco Chang
03 – Linear Algebra
50/50
COMP 175 | COMPUTER GRAPHICS
Questions?
Remco Chang
03 – Linear Algebra
51/50
Download