acTan function

double acTan(
  1. double sinx,
  2. double cosx
)

AcTan() ArcTangent of sin(x) / cos(x). The advantage of this function over arctan() is that it returns the correct quadrant of the angle.

Implementation

double acTan(double sinx, double cosx) {
  if (cosx == 0.0) {
    return (sinx > 0.0) ? (PI / 2.0) : (3.0 * PI / 2.0);
  } else {
    return (cosx > 0.0)
        ? (math.atan(sinx / cosx))
        : (PI + math.atan(sinx / cosx));
  }
}