public static double[] fromLatLon(double[] inputCoordinates,double a,double b,double n0,double e0,double f0,double lat0,double lon0){
  double lat=Math.toRadians(inputCoordinates[0]);
  double lon=Math.toRadians(inputCoordinates[1]);
  double lat0Rad=Math.toRadians(lat0);
  double lon0Rad=Math.toRadians(lon0);
  double e2=(Math.pow(a,2) - Math.pow(b,2)) / Math.pow(a,2);
  double n=(a - b) / (a + b);
  double n2=Math.pow(n,2);
  double n3=Math.pow(n,3);
  double eSinPhi=1 - e2 * Math.pow(Math.sin(lat),2);
  double nu=a * f0 * Math.pow(eSinPhi,-0.5);
  double rho=a * f0 * (1 - e2)* Math.pow(eSinPhi,-1.5);
  double eta2=(nu / rho) - 1;
  double m=b * f0 * ((1 + n + (5.0 / 4.0) * n2 + (5.0 / 4.0) * n3) * (lat - lat0Rad) - (3.0 * n + 3.0 * n2 + (21.0 / 8.0) * n3) * Math.sin(lat - lat0Rad) * Math.cos(lat + lat0Rad) + ((15.0 / 8.0) * n2 + (15.0 / 8.0) * n3) * Math.sin(2.0 * (lat - lat0Rad)) * Math.cos(2.0 * (lat + lat0Rad)) - (35.0 / 24.0) * n3 * Math.sin(3.0 * (lat - lat0Rad))* Math.cos(3.0 * (lat + lat0Rad)));
  double i=m + n0;
  double ii=(nu / 2) * Math.sin(lat) * Math.cos(lat);
  double iii=(nu / 24) * Math.sin(lat) * Math.pow(Math.cos(lat),3)* (5 - Math.pow(Math.tan(lat),2) + 9 * eta2);
  double iiiA=(nu / 720) * Math.sin(lat) * Math.pow(Math.cos(lat),5)* (61 - 58 * Math.pow(Math.tan(lat),2) + Math.pow(Math.tan(lat),4));
  double iv=nu * Math.cos(lat);
  double v=(nu / 6) * Math.pow(Math.cos(lat),3) * ((nu / rho) - Math.pow(Math.tan(lat),2));
  double vi=(nu / 120) * Math.pow(Math.cos(lat),5) * (5 - 18 * Math.pow(Math.tan(lat),2) + Math.pow(Math.tan(lat),4) + 14 * eta2 - 58 * (Math.pow(Math.tan(lat),2)) * eta2);
  double retN=i + ii * Math.pow(lon - lon0Rad,2) + iii * Math.pow(lon - lon0Rad,4) + iiiA * Math.pow(lon - lon0Rad,6);
  double retE=e0 + iv * (lon - lon0Rad) + v * Math.pow(lon - lon0Rad,3) + vi * Math.pow(lon - lon0Rad,5);
  return new double[]{retE,retN};
}

public static double [ ] fromLatLon ( double [ ] inputCoordinates , double a , double b , double n0 , double e0 , double f0 , double lat0 , double lon0 ) { double lat = Math . toRadians ( inputCoordinates [ 0 ] ) ; double lon = Math . toRadians ( inputCoordinates [ 1 ] ) ; double lat0Rad = Math . toRadians ( lat0 ) ; double lon0Rad = Math . toRadians ( lon0 ) ; double e2 = ( Math . pow ( a , 2 ) - Math . pow ( b , 2 ) ) / Math . pow ( a , 2 ) ; double n = ( a - b ) / ( a + b ) ; double n2 = Math . pow ( n , 2 ) ; double n3 = Math . pow ( n , 3 ) ; double eSinPhi = 1 - e2 * Math . pow ( Math . sin ( lat ) , 2 ) ; double nu = a * f0 * Math . pow ( eSinPhi , - 0.5 ) ; double rho = a * f0 * ( 1 - e2 ) * Math . pow ( eSinPhi , - 1.5 ) ; double eta2 = ( nu / rho ) - 1 ; double m = b * f0 * ( ( 1 + n + ( 5.0 / 4.0 ) * n2 + ( 5.0 / 4.0 ) * n3 ) * ( lat - lat0Rad ) - ( 3.0 * n + 3.0 * n2 + ( 21.0 / 8.0 ) * n3 ) * Math . sin ( lat - lat0Rad ) * Math . cos ( lat + lat0Rad ) + ( ( 15.0 / 8.0 ) * n2 + ( 15.0 / 8.0 ) * n3 ) * Math . sin ( 2.0 * ( lat - lat0Rad ) ) * Math . cos ( 2.0 * ( lat + lat0Rad ) ) - ( 35.0 / 24.0 ) * n3 * Math . sin ( 3.0 * ( lat - lat0Rad ) ) * Math . cos ( 3.0 * ( lat + lat0Rad ) ) ) ; double i = m + n0 ; double ii = ( nu / 2 ) * Math . sin ( lat ) * Math . cos ( lat ) ; double iii = ( nu / 24 ) * Math . sin ( lat ) * Math . pow ( Math . cos ( lat ) , 3 ) * ( 5 - Math . pow ( Math . tan ( lat ) , 2 ) + 9 * eta2 ) ; double iiiA = ( nu / 720 ) * Math . sin ( lat ) * Math . pow ( Math . cos ( lat ) , 5 ) * ( 61 - 58 * Math . pow ( Math . tan ( lat ) , 2 ) + Math . pow ( Math . tan ( lat ) , 4 ) ) ; double iv = nu * Math . cos ( lat ) ; double v = ( nu / 6 ) * Math . pow ( Math . cos ( lat ) , 3 ) * ( ( nu / rho ) - Math . pow ( Math . tan ( lat ) , 2 ) ) ; double vi = ( nu / 120 ) * Math . pow ( Math . cos ( lat ) , 5 ) * ( 5 - 18 * Math . pow ( Math . tan ( lat ) , 2 ) + Math . pow ( Math . tan ( lat ) , 4 ) + 14 * eta2 - 58 * ( Math . pow ( Math . tan ( lat ) , 2 ) ) * eta2 ) ; double retN = i + ii * Math . pow ( lon - lon0Rad , 2 ) + iii * Math . pow ( lon - lon0Rad , 4 ) + iiiA * Math . pow ( lon - lon0Rad , 6 ) ; double retE = e0 + iv * ( lon - lon0Rad ) + v * Math . pow ( lon - lon0Rad , 3 ) + vi * Math . pow ( lon - lon0Rad , 5 ) ; return new double [ ] { retE , retN } ; }
convert from lat lon
