The dot product multiplies two vectors and produces a scalar quantity. Multiply each of the first vector’s components by the second vector’s corresponding component. Add the products of each component to get the dot product.
v1 = < x1, y1, z1 > v2 = < x2, y2, z2 > v1 dot v2 = (x1 * x2) + (y1 * y2) + (z1 + z2)
Let’s look at an example.
v1 = < -5, 3, 6 > v2 = < 4, 5, 7 > v1 dot v2 = (-5 * 4) + (3 * 5) + (6 * 7) v1 dot v2 = -20 + 15 + 42 = 37
An alternative method of calculating the dot product is to multiply the lengths of the two vectors and multiply the product by the cosine of the interior angle (See Figure 2) between the two vectors.
v1 dot v2 = ||v1|| * ||v2|| * cos(theta)
You wouldn’t want to calculate the dot product using the second formula because it’s slower and more complicated to calculate. The second formula helps to calculate the interior angle.
cos(theta) = (v1 dot v2) / (||v1|| * ||v2||)
Figure 2: The interior angle between two vectors.