Angle.atanFullTurn constructor Null safety

Angle.atanFullTurn(
  1. double y,
  2. double x
)

Works in the same manner as Angle.atan2, but results in an angle in [0°, 360°). Sample values:

  • y=0, x=0 => 0°
  • y=0, x=1 => 0°
  • y=1, x=0 => 90°
  • y=0, x=-1 => 180°
  • y=-1, x=0 => 270°

Implementation

factory Angle.atanFullTurn(final double y, final double x) {
  if (y >= 0) {
    return Angle.atan2(y, x);
  } else {
    return Angle.atan2(-y, -x) + Angle.halfTurn();
  }
}