The Dot Product in Detail – Interactive 3D Graphics

July 30, 2019 posted by


So, here’s our x-y coordinate system and let’s just forget about z for now. Let’s start with a normalized vector 1,0 pointing along the x-axis. If I draw a normalized vector here at 0.8,0.6, the dot product between these two vectors is simply the x component, 0.8, with the vector 0.707,0.707, a 45-degree angle here. The dot product is again, the x component, 0.707, with the vector of 0.6,0.8, the x component is 6, and that’s the dot product. It’s always the x component. Continuing on with the vector 0,1, the dot product between this vector and this vector is 0. Vectors at right angles to each other always have a dot product of 0. If you work your way around with more vectors, you’ll form a circle. As you may recall from Geometry, the cosine is often defined as the distance in x of a point on the circle. So, as this vector angle increases, the cosine of this angle is computed by taking the dot product. I’ve known this fact for 30 years, but it’s still slightly magical to me that taking a dot product of two normalized vectors, which just multiplies and adds them together, gives you a trigonometric function. If you’re still not convinced, what you can do is plot out the various angles and what dot product you get out of them. And you’ll see, you actually get a cosine curve. So, here are two normalized vectors. When you take the dot product geometrically, what is happening is that one normalized vector is being projected onto the other. That is, the dot product shows how far one vector extends with respect to some given vector. So, for 0.6,0.8, the vector extends 0.6 along our initial vector. Another way to say this is that one vector projects onto the other vector to give this distance. This works both ways. Our initial vector can also be projected on to the second vector and get you the same length, 0.6. In other words, the dot product operation is commutative. A dot B gives the same answer as B dot A. Projecting one way gives the same answer as projecting the other. That’s it in a nut shell. The dot product projects one vector onto another vector. If both vectors are normalized, the dot product gives the cosine between them. We’ll see in the next unit on transforms, what happens when one or both vectors are not normalized. For computing the shade of the material, however, we have the tool that we need, so let’s use it.

1 Comment

One Reply to “The Dot Product in Detail – Interactive 3D Graphics”

  1. voyageruk2002 says:

    The X component is 0.6 not 6

Leave a Comment

Your email address will not be published. Required fields are marked *