Dot Product: Applications
This is likely the last section of the miniseries on dot products. In this section, we will explore some applications of the dot product in various fields. We will begin with the more common applications, and then move on to some more less well-known ones.
Table of Contents
Physical Work
In Physics, there is a quantity called a force. This force is a vector quantity; its magnitude is the strength of the force, and its direction is the direction in which the force is applied. For example, if you push a box to the right, the force you apply is a vector pointing to the right.
When a force
Thus, we can define work,
The problem with this definition is that it does not account for the direction of the force. Imagine you are pushing a box in an upward-right direction against a wall. The force you apply is in the upward-right direction, but the box only moves up. In this case, only the force component in the direction of the motion (up) contributes to the work done.
So, in reality, the work done is:
But wait... that's just the dot product of the force and the distance vector:
The work is an extremely important concept in Physics, and the dot product is the key to understanding it. It's relevant to understanding how energy is transferred in various systems, which in turn is crucial for understanding the behavior of physical systems.
Graphical Projection
We know that the dot product can act as a way to project one vector onto another. This property is used in Computer Graphics to determine the position of objects on the screen.
Think about it: when you're looking at a 3D scene on a screen, the computer is essentially projecting a 3D scene onto a 2D plane. There are different ways to project a 3D scene onto a 2D plane, but many of them involve the dot product.
Not much more to say here; we will discuss planes in much more detail in the next sections.
Lighting in Graphics
In Computer Graphics, the dot product is used to determine the intensity of light on a surface. When light hits a surface, the intensity of the light is determined by the angle between the light source and the surface.
Imagine a scene with a ground, a ball, a lamp, and a camera. The lamp emits light rays in all directions, and some of these rays hit the ball or the ground. Some others hit the ground, bounce off, and hit the ball.
For our purposes, treat the camera as simply a grid of pixels. The goal of rendering is simply to determine the color of each of those pixels.
The above scene is a simplified version of a rendering setup, with only one pixel on the camera. Let's assume a pixel can only have one color, so the only data is the intensity of light.
The way we begin to calculate the intensity of light on a pixel is by imagining the pixel shooting a beam towards the ball.
We're essentially working backwards from the camera to the light source.
The light hits a point on the ball, denoted by
The first contribution to the intensity at
Hence:
For the other contributions, we keep working backwards. Starting at point
- How reflective the ball is; this is denoted by the reflectance of the ball,
, where just means the light comes from and reflects to . - The intensity of light at the point on the ball where the light hits,
.
The third factor is the angle between the light source and the point on the ball where the light hits. This is the key part. If the light was closer to the normal of the surface, it would be more intense, and vice versa. Wait... that's just a dot product:
So we add a factor of
That's just the light coming from one specific direction (the lamp).
To get the total intensity at
As we make the cones smaller and smaller, this sum becomes an integral:
Finally, the total intensity at
What we have just derived is known as the rendering equation.
Language
Recall that the dot product of two vectors
This property of the dot product is used in Natural Language Processing (NLP) to compare the similarity of two pieces of text.
For a simplified example, imagine we have three letters, "a", "b", and "c".
We can represent each word as a dimension in a 3D space, where the letter "a" is the vector
Now, let's consider the words "abca" and "accb".
The word "abca" has two "a"s, one "b", and one "c".
Thus, we can represent it as
Similarly, the word "accb" can be represented as
Then, their similarity can be calculated as the dot product of the two vectors:
Of course, in real-world applications, the vectors are much higher-dimensional, and the words are represented as vectors in a high-dimensional space. For example, some plagiarism detection software use the dot product to compare the similarity of two pieces of text.
Summary and Next Steps
This concludes our miniseries on the dot product. We have explored the dot product in depth, from its definition to its applications in various fields.
Here are the key points to remember:
- The dot product is a measure of the similarity of two vectors.
- It can be used to project one vector onto another.
- It is used in Physics to calculate work done by a force.
- It is used in Computer Graphics to determine the intensity of light on a surface.
- It is used in Natural Language Processing to compare the similarity of two pieces of text.
In the next section, we will introduce another fundamental operation on vectors: the cross product.