public static void toPolarCoordinates(double[] x,double[] y){
  if (x.length != y.length) {
    throw new IllegalArgumentException("Arrays must be equal length");
  }
  for (int i=0; i < x.length; i++) {
    double r=Math.sqrt(x[i] * x[i] + y[i] * y[i]);
    double phi=Math.atan2(y[i],x[i]);
    x[i]=r;
    y[i]=phi;
  }
}

public static void toPolarCoordinates ( double [ ] x , double [ ] y ) { if ( x . length != y . length ) { throw new IllegalArgumentException ( "Arrays must be equal length" ) ; } for ( int i = 0 ; i < x . length ; i ++ ) { double r = Math . sqrt ( x [ i ] * x [ i ] + y [ i ] * y [ i ] ) ; double phi = Math . atan2 ( y [ i ] , x [ i ] ) ; x [ i ] = r ; y [ i ] = phi ; } }
convert a pair of arrays from cartesian ( x , y ) coordinates to polar ( r , phi ) coordinates . phi will be in radians , i . e . a full circle is two pi .
