public void toOSGB36(){
  RefEll wgs84=new RefEll(6378137.000,6356752.3141);
  double a=wgs84.getMaj();
  double eSquared=wgs84.getEcc();
  double phi=Math.toRadians(this.lat);
  double lambda=Math.toRadians(this.lng);
  double v=a / (Math.sqrt(1 - eSquared * Util.sinSquared(phi)));
  double H=0;
  double x=(v + H) * Math.cos(phi) * Math.cos(lambda);
  double y=(v + H) * Math.cos(phi) * Math.sin(lambda);
  double z=((1 - eSquared) * v + H) * Math.sin(phi);
  double tx=-446.448;
  double ty=124.157;
  double tz=-542.060;
  double s=0.0000204894;
  double rx=Math.toRadians(-0.00004172222);
  double ry=Math.toRadians(-0.00006861111);
  double rz=Math.toRadians(-0.00023391666);
  double xB=tx + (x * (1 + s)) + (-rx * y)+ (ry * z);
  double yB=ty + (rz * x) + (y * (1 + s))+ (-rx * z);
  double zB=tz + (-ry * x) + (rx * y)+ (z * (1 + s));
  RefEll airy1830=new RefEll(6377563.396,6356256.909);
  a=airy1830.getMaj();
  eSquared=airy1830.getEcc();
  double lambdaB=Math.toDegrees(Math.atan(yB / xB));
  double p=Math.sqrt((xB * xB) + (yB * yB));
  double phiN=Math.atan(zB / (p * (1 - eSquared)));
  for (int i=1; i < 10; i++) {
    v=a / (Math.sqrt(1 - eSquared * Util.sinSquared(phiN)));
    double phiN1=Math.atan((zB + (eSquared * v * Math.sin(phiN))) / p);
    phiN=phiN1;
  }
  double phiB=Math.toDegrees(phiN);
  lat=phiB;
  lng=lambdaB;
}

public void toOSGB36 ( ) { RefEll wgs84 = new RefEll ( 6378137.000 , 6356752.3141 ) ; double a = wgs84 . getMaj ( ) ; double eSquared = wgs84 . getEcc ( ) ; double phi = Math . toRadians ( this . lat ) ; double lambda = Math . toRadians ( this . lng ) ; double v = a / ( Math . sqrt ( 1 - eSquared * Util . sinSquared ( phi ) ) ) ; double H = 0 ; double x = ( v + H ) * Math . cos ( phi ) * Math . cos ( lambda ) ; double y = ( v + H ) * Math . cos ( phi ) * Math . sin ( lambda ) ; double z = ( ( 1 - eSquared ) * v + H ) * Math . sin ( phi ) ; double tx = - 446.448 ; double ty = 124.157 ; double tz = - 542.060 ; double s = 0.0000204894 ; double rx = Math . toRadians ( - 0.00004172222 ) ; double ry = Math . toRadians ( - 0.00006861111 ) ; double rz = Math . toRadians ( - 0.00023391666 ) ; double xB = tx + ( x * ( 1 + s ) ) + ( - rx * y ) + ( ry * z ) ; double yB = ty + ( rz * x ) + ( y * ( 1 + s ) ) + ( - rx * z ) ; double zB = tz + ( - ry * x ) + ( rx * y ) + ( z * ( 1 + s ) ) ; RefEll airy1830 = new RefEll ( 6377563.396 , 6356256.909 ) ; a = airy1830 . getMaj ( ) ; eSquared = airy1830 . getEcc ( ) ; double lambdaB = Math . toDegrees ( Math . atan ( yB / xB ) ) ; double p = Math . sqrt ( ( xB * xB ) + ( yB * yB ) ) ; double phiN = Math . atan ( zB / ( p * ( 1 - eSquared ) ) ) ; for ( int i = 1 ; i < 10 ; i ++ ) { v = a / ( Math . sqrt ( 1 - eSquared * Util . sinSquared ( phiN ) ) ) ; double phiN1 = Math . atan ( ( zB + ( eSquared * v * Math . sin ( phiN ) ) ) / p ) ; phiN = phiN1 ; } double phiB = Math . toDegrees ( phiN ) ; lat = phiB ; lng = lambdaB ; }
convert this latlng from the wgs84 datum to the osgb36 datum using an approximate helmert transformation .
