How to Calculate the Angle Between Two Vectors

A vector is a quantity with magnitude and direction. For example a wind speed vector says how fast the wind is blowing, as well as in what direction. The easiest way to calculate the angle between two different vectors is by using the dot product.
  1. Vector Notation

    • One way to notate a vector is with coordinates (x,y,z). For example, the vector v = (3,-2,5) corresponds to a vector that starts at the origin (0,0,0) and ends at the point (3,-2,5). When we talk about the angle between two vectors, we think of them as both extending from the origin.

    Vector Magnitude

    • The magnitude, or length, of a vector is calculated using Pythagoras’ theorem. The vector v = (x,y,z) has a magnitude |v| = sqrt(x^2 + y^2 + z^2).

    Dot Product

    • The dot product, or scalar product, of two vectors is equal to the sum of the products of the corresponding coordinates in each vector. If a = (x,y,z) and b = (u,v,w), then the dot product is a·b = x*u + y*v + z*w. A property of the dot product is that, if θ is the angle between a and b, then a·b = |a||b|cos(θ).

    Finding the Angle

    • We can find the angle by solving for cos(θ) in the dot product formula, and then using the inverse cosine, or arccos function to find θ. Putting it all together, θ = arccos( a·b / (|a||b|) ).

    Example

    • Let a = (-3,4,10) and b = (5,1,-1). Then |a| = 5.39, |b| = 5.20, a·b = -13.00 and θ = arccos(-13/(5.39*5.20)) = 118 degrees.

Learnify Hub © www.0685.com All Rights Reserved