public static double atan2(double y,double x){
  if (USE_JDK_MATH) {
    return STRICT_MATH ? StrictMath.atan2(y,x) : Math.atan2(y,x);
  }
  if (x > 0.0) {
    if (y == 0.0) {
      return (1 / y == Double.NEGATIVE_INFINITY) ? -0.0 : 0.0;
    }
    if (x == Double.POSITIVE_INFINITY) {
      if (y == Double.POSITIVE_INFINITY) {
        return Math.PI / 4;
      }
 else       if (y == Double.NEGATIVE_INFINITY) {
        return -Math.PI / 4;
      }
 else       if (y > 0.0) {
        return 0.0;
      }
 else       if (y < 0.0) {
        return -0.0;
      }
 else {
        return Double.NaN;
      }
    }
 else {
      return FastMath.atan(y / x);
    }
  }
 else   if (x < 0.0) {
    if (y == 0.0) {
      return (1 / y == Double.NEGATIVE_INFINITY) ? -Math.PI : Math.PI;
    }
    if (x == Double.NEGATIVE_INFINITY) {
      if (y == Double.POSITIVE_INFINITY) {
        return 3 * Math.PI / 4;
      }
 else       if (y == Double.NEGATIVE_INFINITY) {
        return -3 * Math.PI / 4;
      }
 else       if (y > 0.0) {
        return Math.PI;
      }
 else       if (y < 0.0) {
        return -Math.PI;
      }
 else {
        return Double.NaN;
      }
    }
 else     if (y > 0.0) {
      return Math.PI / 2 + FastMath.atan(-x / y);
    }
 else     if (y < 0.0) {
      return -Math.PI / 2 - FastMath.atan(x / y);
    }
 else {
      return Double.NaN;
    }
  }
 else   if (x == 0.0) {
    if (y == 0.0) {
      if (1 / x == Double.NEGATIVE_INFINITY) {
        return (1 / y == Double.NEGATIVE_INFINITY) ? -Math.PI : Math.PI;
      }
 else {
        return (1 / y == Double.NEGATIVE_INFINITY) ? -0.0 : 0.0;
      }
    }
    if (y > 0.0) {
      return Math.PI / 2;
    }
 else     if (y < 0.0) {
      return -Math.PI / 2;
    }
 else {
      return Double.NaN;
    }
  }
 else {
    return Double.NaN;
  }
}

public static double atan2 ( double y , double x ) { if ( USE_JDK_MATH ) { return STRICT_MATH ? StrictMath . atan2 ( y , x ) : Math . atan2 ( y , x ) ; } if ( x > 0.0 ) { if ( y == 0.0 ) { return ( 1 / y == Double . NEGATIVE_INFINITY ) ? - 0.0 : 0.0 ; } if ( x == Double . POSITIVE_INFINITY ) { if ( y == Double . POSITIVE_INFINITY ) { return Math . PI / 4 ; } else if ( y == Double . NEGATIVE_INFINITY ) { return - Math . PI / 4 ; } else if ( y > 0.0 ) { return 0.0 ; } else if ( y < 0.0 ) { return - 0.0 ; } else { return Double . NaN ; } } else { return FastMath . atan ( y / x ) ; } } else if ( x < 0.0 ) { if ( y == 0.0 ) { return ( 1 / y == Double . NEGATIVE_INFINITY ) ? - Math . PI : Math . PI ; } if ( x == Double . NEGATIVE_INFINITY ) { if ( y == Double . POSITIVE_INFINITY ) { return 3 * Math . PI / 4 ; } else if ( y == Double . NEGATIVE_INFINITY ) { return - 3 * Math . PI / 4 ; } else if ( y > 0.0 ) { return Math . PI ; } else if ( y < 0.0 ) { return - Math . PI ; } else { return Double . NaN ; } } else if ( y > 0.0 ) { return Math . PI / 2 + FastMath . atan ( - x / y ) ; } else if ( y < 0.0 ) { return - Math . PI / 2 - FastMath . atan ( x / y ) ; } else { return Double . NaN ; } } else if ( x == 0.0 ) { if ( y == 0.0 ) { if ( 1 / x == Double . NEGATIVE_INFINITY ) { return ( 1 / y == Double . NEGATIVE_INFINITY ) ? - Math . PI : Math . PI ; } else { return ( 1 / y == Double . NEGATIVE_INFINITY ) ? - 0.0 : 0.0 ; } } if ( y > 0.0 ) { return Math . PI / 2 ; } else if ( y < 0.0 ) { return - Math . PI / 2 ; } else { return Double . NaN ; } } else { return Double . NaN ; } }
for special values for which multiple conventions could be adopted , behaves like math . atan2 ( double , double ) .
