Search code examples
c#algorithmmathtrigonometryangle

How to find out if the angle between two vectors is external or internal? (in 3D space)


I read this post,


How to find out if the angle between two vectors is external or internal?

I know how to find out angle between 2 vectors, but it always gives me internal angle, but I want it to give me always the angle in anticlockwise direction, even if it is greater then 180.


I got similar question.

The only different is my two vectors are in 3D space,

A = (x1, y1, z1)

B = (x2, y2, z2)

How to find out the angle between two vectors is external or internal?

(From A to B, anticlockwise direction, 0~360)


Solution

  • There is no clockwise or counter-clockwise in 3D space. If you have given two vectors A and B, there is exactly one angle between them. It's a pretty canonical choice: The smaller of the two angles connecting them in the plane which is defined by A and B (i.e. the plane which is parallel to both of these vectors. There is only one choice unless A and B are parallel).

    So if you want the larger of those angles, just subtract the smaller angle (which is usually called the angle between A and B) from 360.