DonAntonio said:
There are several ways to do it:
1) Calculate the formula of the straightline passing through the spacecraft (point S) and the ellipsoid's center, and then find out
the intersection point P between that line and the ellipsoid. Finally, just calculate the distance between S and P
2) Take a generic point on the ellipsoid ( according to its formula ) and find its distance to point S. Use now differential calculus to find
the minimum of the distance function you got.
DonAntonio
Method 1 is incorrect. Method 2 doesn't help much.
Method 1 is the starting point of the iterative Bowring algorithm, see Borkowski (1989). The Bowring algorithm and an improved version are easy to code up, but they're iterative. There are also a couple of closed form solutions. These aren't quite so easy to encode but they closed form. See Rey-Jer You (2000), W. E. Featherstone and S. J. Claessens (2008).
K. M. Borkowski (1989), "Accurate algorithms to transform geocentric to geodetic coordinates", Bulletin Géodésique (Journal of Geodesy), 63:1
Rey-Jer You (2000), "Transformation of Cartesian to Geodetic Coordinates Without Iterations", Journal of Surveying Engineering, 126:1
W. E. Featherstone and S. J. Claessens (2008), "Closed-form transformation between geodetic and ellipsoidal coordinates", Studia Geophysica et Geodaetica, 52:1
All of the cited papers can be found online, but I don't know if they are legit links (don't violate copyright), so you'll have to find them yourself if you are interested.