// Geod_2_Cart.java
// Transformation of co-ordinates (Geodetic to Cartensian)

public class Geod_2_Cart
{
   protected double a;   // semi-major axis of the reference ellipsoid
   protected double ee;   // first eccentricity of the reference ellipsoid
   protected double N;   // the radius of curvature in prime vertical
   public double X, Y, Z;   // Cartesian co-ordinates of a point
   public double Lat, Long;   // Latitude and Longitude of a point
   public double h;   // ellipsoid height of a point
   
   public Geod_2_Cart( double aa, double e2)
   {
      a = aa;
      ee = e2;
   }
   
   // to compute the radius of curvature in prime vertical
   protected double curvature()
   {
      return a/Math.sqrt(1-ee*Math.pow(Math.sin(Lat),2));
   }
   
   // to perform the conversion
   public void compute()
   {
      N = curvature();
      
      // 3D transformation formulae
      X = (N+h) * Math.cos( Lat) * Math.cos( Long);
      Y = (N+h) * Math.cos( Lat) * Math.sin( Long);
      Z = ((1-ee) * N + h) * Math.sin( Lat);
   }
}  // end of Geod_2_Cart.java
