Maybe Spacedman have already gave the answer but I was actually looking for formulae . I have found this page which is Turkish so I'll give you only the part you can understand. It says with this formulization we can transform our Geographic(Ellipsoidal) coordinates to Cartesian Coordinates. ( "h" is ellipsoidal height)
Then I have found this page which is Turkish again (but I'm sure you can find English one) describes how to transform Cartesian Coordinates to Spherical Coordinates.
So shortly my approach to this problem is like ;
İnput: Ellipsoidal Geographic Coordinates and ellipsoidal height.(GPS data of each point).
Transform this coordinates to Cartesian Coordinates. Then transform Cartesian Coordinates to Spherical Coordinates
Output: Spherical Coordinates.
Please let me know if you think this is a wrong approach for this problem or you think this is right way..