public void toVH(double lat,double lon){
  lat=Math.toRadians(lat);
  lon=Math.toRadians(lon);
  double lon1=lon + Math.toRadians(52.0);
  double latsq=lat * lat;
  double lat1=lat * (K1 + (K2 + (K3 + (K4 + K5 * latsq) * latsq) * latsq) * latsq);
  double cos_lat1=Math.cos(lat1);
  double x=cos_lat1 * Math.sin(-lon1);
  double y=cos_lat1 * Math.cos(-lon1);
  double z=Math.sin(lat1);
  double e=EX * x + EY * y + EZ * z;
  double w=WX * x + WY * y + WZ * z;
  e=e > 1.0 ? 1.0 : e;
  w=w > 1.0 ? 1.0 : w;
  e=M_PI_2 - Math.atan(e / Math.sqrt(1 - e * e));
  w=M_PI_2 - Math.atan(w / Math.sqrt(1 - w * w));
  double ht=(e * e - w * w + .16) / .8;
  double vt=Math.sqrt(Math.abs(e * e - ht * ht));
  vt=(PX * x + PY * y + PZ * z) < 0 ? -vt : vt;
  double v=TRANSV + K9 * ht - K10 * vt;
  double h=TRANSH + K10 * ht + K9 * vt;
  this.resultV=v;
  this.resultH=h;
}

public void toVH ( double lat , double lon ) { lat = Math . toRadians ( lat ) ; lon = Math . toRadians ( lon ) ; double lon1 = lon + Math . toRadians ( 52.0 ) ; double latsq = lat * lat ; double lat1 = lat * ( K1 + ( K2 + ( K3 + ( K4 + K5 * latsq ) * latsq ) * latsq ) * latsq ) ; double cos_lat1 = Math . cos ( lat1 ) ; double x = cos_lat1 * Math . sin ( - lon1 ) ; double y = cos_lat1 * Math . cos ( - lon1 ) ; double z = Math . sin ( lat1 ) ; double e = EX * x + EY * y + EZ * z ; double w = WX * x + WY * y + WZ * z ; e = e > 1.0 ? 1.0 : e ; w = w > 1.0 ? 1.0 : w ; e = M_PI_2 - Math . atan ( e / Math . sqrt ( 1 - e * e ) ) ; w = M_PI_2 - Math . atan ( w / Math . sqrt ( 1 - w * w ) ) ; double ht = ( e * e - w * w + .16 ) / .8 ; double vt = Math . sqrt ( Math . abs ( e * e - ht * ht ) ) ; vt = ( PX * x + PY * y + PZ * z ) < 0 ? - vt : vt ; double v = TRANSV + K9 * ht - K10 * vt ; double h = TRANSH + K10 * ht + K9 * vt ; this . resultV = v ; this . resultH = h ; }
lat and lon are in degrees , positive north and east .
