# Different angle for similar vectors

Hi,

Can I ask for a bit of explanation? I am not getting expected results when calculating vector angles. For one set of vectors I get a result 90 degrees, for another I get 270 degrees. Can you please take a look at it?

The angle between two vectors is the acos of the dot of two normalised vectors
That means you never get an angle greater as 180 degrees. You can do a left/right check in order to determine if clockwise or counterclockwise, by creating the cross of those vectors, and evaluating the dot again between vector a and the normal.A vector is parallel when the dot is 1, antiparallel when -1 and orthogonal when 0.
It makes sense to implement it by yourself, so that you understand the math behind. Its not that complicated…

Hi,

I know the math behind, and if you can see 2nd example, the angle is 4.712 radians, which is 270 degrees. The 90 degrees is a correct value if we use for example right hand rule to calculate angle. In this case I should either get 90 and -270 degress or both values as 90 degrees or both as -270, but a case where I get for nearly identical vectors values +90 and +270 degrees are at least strange. I definitely want to avoid implementing angle calculation methods if I can use the one implemented in RhinoCommons, but I need to get information if this is something I can overcome, or if this is a bug.

Edit:

OK, so I came back to this example and actually used simpler form of the method without giving Normal vector. This gives predictable results and works correct. for both sets of input values.

angle = Vector3d.VectorAngle(tangent, x);