5
\$\begingroup\$

I know that if you take the dot-product of two normalized vectors, you get the cosine of the angle between them.

But if I take the dot-product of two non-normalized vectors (or one normalized, one not), how can I interpret the resulting scalar?

\$\endgroup\$
7
\$\begingroup\$

Others have pointed out how you can use the sign of the dot product to broadly determine the angle between two arbitrary vectors (positive: < 90, zero: = 90, negative: > 90), but there's another useful geometric interpretation if at least one of the vectors is of length 1.

If you have one unit vector U and one arbitrary vector V, you can interpret the dot product as the length of the projection of V onto U:

diagram of a dot product with a unit vector

Equivalently, (U · V) is the length of the component of V pointing in the direction of U. ie. You can break V into a sum of two perpendicular vectors, V = (U · V)U + P, where P is some vector perpendicular to U.

This is helpful for rewriting a vector from one coordinate system in terms of a different basis, or for removing/reflecting the component of a vector that's parallel to a particular direction while keeping the perpendicular component intact. (eg. zeroing the component of a velocity that would take an object through a barrier, but allowing it to slide along that barrier, or rebounding it away)

I'm not aware of a convenient geometric interpretation of the dot product when both vectors are of arbitrary length (other than using the sign to categorize the angle).

\$\endgroup\$
  • \$\begingroup\$ +1 for "If you have one unit vector U and one arbitrary vector V, you can interpret the dot product as the length of the projection of V onto U" \$\endgroup\$ – Jonathan Mee Oct 23 '15 at 17:48
4
\$\begingroup\$

If the resulting scalar is 0; then it means the 2 vectors are perpendicular to each other (angle difference 90 degrees) . If the resulting scalar > 0; then the angle difference between them is less than 90 degrees. If the resulting scale is < 0; then the 2 vectors are facing opposite directions ( or angle difference > 90 degrees).

This can be useful in calculating backstabs for example. Or determine which quadrant one vector is relative to the other.

\$\endgroup\$
  • \$\begingroup\$ Is this true for non-normalized vectors? \$\endgroup\$ – Steven Dec 17 '14 at 3:11
  • \$\begingroup\$ Yes. More Characters. \$\endgroup\$ – user55564 Dec 17 '14 at 3:20
2
\$\begingroup\$

the dot product is equal to v1.length() * v2.length() * dot(v1.normalized(), v2.normalized())

the most you can get out of that is whether the angle is acute or not or pass to other algorithms where you can delay the normalization. But you can get the normalized from the non-normalized by dividing with sqrt(v1.lengthSquared() * v2.lengthSquared()) (saves a sqrt calculation)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.