BASIC ELLIPSOID FORMULAS AND RELATIONSHIPS APPLIED HERE
Given the general static ellipsoid parameters:
 R = Equatorial radius of ellipsoid = Length of semimajor axis
 r = Polar radius of ellipsoid = Length of semiminor axis
 where, r ≤ R
 If ((R = r)), then the form is a perfect sphere, otherwise it is an ellipsoid or oblate
spheroid to some degree, generally wider between two opposite equatorial points
due to a slight equatorial bulge, than between the opposite polar points.
 NOTE:
In the equations, any units of measure may be used for (R, r), such as feet, meters, kilometers, miles, etc., just as long as the same units are used consistently throughout. The values of (x, y, z) will be expressed in the same units as the parameters (R, r).
Computing 3D Rectangular XYZCoordinates For a Point on a Reference Ellipsoid Surface
The reference ellipsoid parameters, location and elevation of the point are:
R = Equatorial radius.
r = Polar radius.
Lat = Geographic latitude of point on ellipsoid surface.
Lon = Geographic longtitude of point on ellipsoid surface (Negative = West).
$h$ = Height or elevation of point relative to ellipsoid surface.
From the given parameters, the 3D XYZcoordinates of the point, relative to the surface of the reference ellipsoid, are computed from the equations given below.
Let:
$f=\frac{R\text{}\text{}r}{R}$ = Polar flattening factor of ellipsoid.
$e=\sqrt{1{\left(\frac{r}{R}\right)}^{2}}$
$\rho =\frac{R}{1\text{}\text{}e\xb2\xb7sin\xb2(\mathrm{Lat})}$ = Radius vector from ellipsoid center to surface at latitude $\left(\mathrm{Lat}\right)$.
Then:
$x=(h+\rho )\xb7cos(\mathrm{Lat})\xb7cos(\mathrm{Lon})$
$y=(h+\rho )\xb7cos(\mathrm{Lat})\xb7sin(\mathrm{Lon})$
$z=(h+\rho \xb7(1e\xb2))\xb7sin(\mathrm{Lat})$
