Trying To Calculate the Difference between two angles (atan2)
angle, atan2, c#, distance, geometry
Solution
If by distance you mean the straight line joining the two interception points, you can calculate the distance by doing this:
SQRT( ( ABS|cos(A) - cos(B)| )^2 + ( ABS|sin(A) - sin(B)| )^2 )
SQRT = square root
ABS = Absolute value
If the distance is the angle, you calculate it by doing (pseudo-code)
var angle = ABS(A - B)
if(angle > pi) angle = 2*pi - angle
return angle
Problem
Atan2(y,x) will return a float between -pi and pi. I want to calculate the distance between two angles, but the non-continuity is throwing me off. See this for better understanding. I want to be able to calculate the distance between Angle 1 and Angle 2. The whole point of this is to be able to create a cone from the center to a specified angle. Essentially I will be evaluating: ``` if(DistanceFromAngle1 < pi/4 [45°]) { Angle2 is part of cone } ```