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

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