Understanding differences in Geodetic (WGS84) to ECEF equations? Methods suggested in this, that and there all recommend the following:
$$x = R \cos(\theta) \cos(\phi)$$
$$y = R \cos(\theta) \sin(\phi)$$
$$z = R \sin(\theta),$$
where latitude is $\theta$, longitude is $\phi$ and the Earth's approximate radius is $R$ (6371km).
However, I am not sure why these equations are using $R$ rather than their documented form:
$$x = (N(\theta) + h) \cos(\theta) \cos(\phi)$$
$$y = (N(\theta) + h) \cos(\theta) \sin(\phi)$$
$$z = \left(\frac{b^2}{a^2} N(\theta) + h\right) \sin(\theta),$$
where altitude is $h$, semi-major axis is $a$, semi-minor axis is $b$ and the prime vertical radius of curvature is $N(\theta)$. Further, we can say:
$$N(\theta) = \frac{a}{\sqrt{1-{e^2}\sin^{2}(\theta)}}$$
and...
$$e^2 = 1 - \frac{b^2}{a^2}$$
thus...
$$z = (1 - e^2)  (N(\theta) + h)  \sin(\theta).$$
Now for my purposes, I am treating all points with an altitude of 1, so the $h$ can be eliminated. What I am not comprehending is how they are arriving at:
$$N(\theta) = R$$
and...
$$(1-e^2) * N(\theta) = R$$
Is it safe to use the radius of the Earth as an approximation or should I use the WGS84 constraints (semi-major and first eccentricity) in my computations?
 A: Comments
The earth is not perfectly spherical. There is a flattening at the poles.
The WGS84 modifies spherical coordinates in two ways.
First in order to take into account the equatorial bulge through eccentricity factor $e$.
Secondly if distances are measured from an aircraft or spacecraft at an altitude $h$ above the earth this altitude should be added on to earth's radius.
Parallel lines unlike meridians are not geodesics even in the ideal spherical earth model $(e=0)$. At higher latitudes distance measured along latitudes and shortest path geodesic is more pronounced.
A: The value of $e^2$ for the Earth is roughly $6.6\times 10^{-3}$, so that multiplied by the Earth radius is the order of 40 kilometers. As long as you don't care about missing your positions by such a margin, it does not matter whether the Earth is approximated by a sphere. As soon as you need higher accuracy, the full WGS84 equations are needed.
In addition it is very important to understand that the latitude angles in the WGS equations are not geocentric, so the $\theta$ in the two coordinate systems do not have the same values.
