🍔 HW 16: Dot & Cross Product
Vector Dot Product
When multiplying two vectors together, there are two types of vector products. The first vector product is the dot product or inner product. The dot product is important in video game programming, computer graphics, simulation, and AI. Therefore, the dot product is an important concept and formula to grasp.
The name "dot product" comes from the dot symbol used in the notation: a * b
. Just like the scalar-times-vector multiplication, the vector dot product is performed before addition and subtraction, unless parantheses are used to override this default order of operations. While we usually omit the multiplication symbol when multiplying two scalars or a scalar and a vector, we must not forget the dot symbol when performing a vector dot product. The dot product of two vectors is the sum of the products of corresponding components, resulting in a scalar.
What does the vector dot product mean geometrically?
The vector dot product is fundamental to almost every aspect of 3D math. There are two main ways to interpet the dot product:
-
Projection: Assume that
a^
is a unit vector andb
is a vector of any length. Now takeb
and project it onto a line parallel toa^
. Then, we can define the dot product (a^ * b
) as the signed length of the projection ofb
onto this line. This projection ofb
can be thought of as a shadow onto a. The result of a dot product is scalar, not a vector. The dot producta * b
is equal to the signed length of the projection ofb
onto any line parallel toa
, multiplied by the length ofa
. -
Trigonometry: We can also examine the dot product through the lens of trigonometry.
Unity has Vector3.Dot
that gets the Dot Product of two vectors. The dot product is a float value equal to the magnitudes of two vectors multiplied to gether and then multiplied by the cosine of the angle between them.
Vector Cross Product
The other vector product is known as the cross product. The cross product is only applied in 3D mathematical situations and is not commutative. The term "cross product" comes from the symbol used in the notation a x b
. We write the cross symbol, rather than omitting it as we do with scalar multiplication.
The cross product enjoys the same level of operator precedence as the dot product: multiplication occurs before addition and subtraction. When dot product and cross product are used together, the cross product takes precedence: a * b x c = a * (b x c)
.
Resources and Links
Submission
GitHub Pull Requests
To receive credit for this homework assignment, please make sure you provide a link to your GitHub branch and name the branch as your first name.
Then assign Nile and Debbie as Reviewers
and Assignees
before you hit the green Create Pull Request
button.