# How does one know if a normal vector is between two angles?

I have a Max Angle and a Min Angle, and also a unit vector pointing in some direction (2D).

How do I find out if this normal vector is between the two angles?

## Answers

Calculate the angle from the dot product (this is easy in 2d) and then compare to your angle range.

I don't know c#, but I know math:

Suppose the vector's coordinates are (x,y), and it is a unit vector, so |(x,y)| = 1. The angle a between the positive x-axis and the vector is

a = atan2(y,x)

where atan2 is the four-quadrant arctangent. You can then check if this angle is between your max and min angles (provided they are also defined with respect to the positive x-axis).

Note that a is in radians; if your angles are given in degrees, you should first compute

a = a*180/pi;

where pi = 3.1415..... of course.

Does this help at all?