I need to make an efficient function that matches this footprint:
public static double NearestAngle(this double currentAngle, double targetAngle);
where the return value is targetAngle +/- n*2pi
. The return value should minimize the absolute difference between itself and currentAngle
. How can I do this efficiently in C#? I want to avoid loops as the inputs can be many circles apart.