Calculating the angle between two vectors

  • Context: Undergrad 
  • Thread starter Thread starter computerex
  • Start date Start date
  • Tags Tags
    Angle Vectors
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 7K views
computerex
Messages
68
Reaction score
0
When calculating the angle between two vectors, I take the inverse cosine of the dot product of the two vectors normalized. This gives me the angle, however this does not specify whether the direction is backwards or forwards. In other words, it'll give me a range of -PI/2 to PI/2, then it loops back. Is there a way to figure out the angle in range of 0 to 360 degrees with this?
 
Physics news on Phys.org
Usually (for how it is normally defined, for example, in calculators) the cos^(-1) gives back values belonging to [0, pi], not [-pi/2 , pi/2] because in this interval the cos is not invertible.

Lets consider R^3.
If you want an angle between two normalized vectors u and v, belonging to [0, 2pi[, you have to define an orientation z for the plane where the two vectors are (the vector z lies in one side or the other of the plane, you choose).

(1) calculate alpha = cos^(-1) (u.v)
(2) calculate w = u x v
(3) if w.z > 0 or w.z = 0 then the answer is alpha
(4) if w.z < 0 then the answer is 2pi - alpha
 
The "angle between two vectors" is, by definition, the smaller of the two angles formed by the intersection of lines in the direction of the two vectors. The angle between two vectors is always between 0 and [itex]\pi[/itex].
 
HallsofIvy said:
The "angle between two vectors" is, by definition, the smaller of the two angles formed by the intersection of lines in the direction of the two vectors. The angle between two vectors is always between 0 and [itex]\pi[/itex].

Nevertheless, if you need it, you can define the angle in (0, 2pi), and to do so you have to decide an orientation.