Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Signed angle between two 3D vectors

  1. Oct 8, 2008 #1
    Hi all, I am looking for some help please.

    I want to calculate the signed angle between two 3D (x,y,z) vectors. I know the formula to find the unsigned angle;

    angle = arccos(A.B / |A||B|)

    but how do I get the signed angle? From searching through the internet it seems that there isnt an obvious/easy solution ?

    To clarify: Assume the two vectors can lie on any plane. Taking the first vector as a reference I want to know the angle that I would need to rotate the first vector to line it up with the second vector.

    Can someone more clever than me point me in the right direction, or prehaps offer a solution please ?
  2. jcsd
  3. Oct 8, 2008 #2
    The sign of the angle depends on the axis you use.

    Take the angle between x = (0, 1, 0) and y = (1, 0, 0). We see that y is actually x rotated 90 degrees along the z axis (described by the vector (0, 0, 1)). But we can equivalently say that y is x rotated -90 degrees through the negative z axis (described (0, 0, -1)).

    Suppose you have two points, p1 and p2, such that p2 is p1 rotated in some plane. A plane is uniquely specified by three points (assuming that all three are distinct and do not lie on a single line). The plane of our rotation is defined by the origin, p1, and p2.

    The axis about which they rotate is the normal of this plane. Each plane actually has two normals (a positive one and a negative one), which can be found by taking either the left-handed or right-handed cross product of p1 and p2.

    Once you have chosen which axis you want, you can define positive rotation to be the usual counter-clockwise direction along that axis.
  4. Oct 9, 2008 #3
    Thanks Tic Tac, I understand what you are saying. Let me give you an example of my problem:

    keeping things simple for my small brain, we have two vectors on (lets say) the xy plane
    vec1 = 1,0,0
    vec2 = 1,1,0

    the cross product, CP = 0,0,+1 (in the 'positive' direction) and the angle between them is 45 degress. (Using right hand rule, vec1 is rotated counter clockwise around CP by 45 degrees to align with vec2). Perfect.

    now lets say vec2 = -1,1,0. CP is still 0,0,+1 and the angle is +135 degrees. Perfect.

    now lets say vec2 = -1,-1,0. But now the CP flips to the other direction and CP is now 0,0,-1 (in the 'negative' direction) and the angle is +45. But actually I want the angle answer to be -45.

    So maybe the question I should ask is how do I work out if the Cross Product of my two vectors is in the 'postive' direction rather than the 'negative' direction for the plane defined by my two vectors. In the real world this plane can be in any orientation.
  5. Oct 9, 2008 #4
    You can't have your cake that way.

    As long as you've fixed your cross product's handedness, there will be situations where the normal flips. It may look inconvenient to you, but it ensures that the cross product is continuous and the angles are defined in a consistent way.

    It might help to realize there is no general distinction between the "negative" normal and the "positive" one. For the z-axis, it makes sense, but take a pair of vectors like [1, 1, 0] and [0, 1, 1]. The two normal possibilities are then [1, -1, 1] and [-1, 1, -1], and it's not clear either is "positive". The best you can do is say one is right-handed versus left handed.

    Also, note the property of the cross product that it is anti-commutative. For all a and b, a x b = -(b x a).
  6. Oct 9, 2008 #5
    Yes that does help, I can see your point. Thankyou :smile:
  7. Oct 9, 2008 #6
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook