Skip to main content

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 is applied to an object, it can move by a certain distance . The quantity, work, represents how much energy is transferred to the object by the force. Thinking intuitively, if you push a box with the same force over a longer distance, you are giving it more energy. Similarly, if you push a box with a stronger force over the same distance, you are also giving it more energy.

Thus, we can define work, as the product of the magnitudes of the force and distance, right?

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 . Denote the vector going from the ball back to the pixel as . Denote the the intensity at the point as .

The first contribution to the intensity at is the light emitted from the ball itself. While it does not emit light in this case, in other cases, it would glow with a certain intensity. This can be denoted as .

Hence:

For the other contributions, we keep working backwards. Starting at point , we consider all the light that hits it by shooting rays from the point in all directions. For example, consider the light that hits directly from the lamp. It comes from a direction . Now, we need to think about the contributions from the lamp to the intensity at :

  1. How reflective the ball is; this is denoted by the reflectance of the ball, , where just means the light comes from and reflects to .
  2. 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 to the equation. Hence, the intensity at due to the light from the lamp is:

That's just the light coming from one specific direction (the lamp). To get the total intensity at , we need to consider all the light coming from all directions. More specifically, all directions from which light can hit - a hemisphere around the point, denoted by . Since we are going towards a continuous case (all directions), instead of thinking about individual directions , it's better to think of as a small cone of directions. The intensity at due to the light from the lamp is then the sum of the intensities from all these cones:

As we make the cones smaller and smaller, this sum becomes an integral:

Finally, the total intensity at is the emitted light plus the light from all other sources (which is the integral above):

What we have just derived is known as the rendering equation.

Language

Recall that the dot product of two vectors and can be thought of as a measure of their similarity. If the dot product is positive, the vectors are pointing in roughly the same direction. If the dot product is negative, the vectors are pointing in roughly opposite directions.

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 , "b" is , and "c" is .

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.