# State vector conversion when changing central body

I have the following state vector of a spacecraft : [X, Y, Z, VX, VY, VZ]. The state vector is expressed in the inertial frame of the central body. I would like to convert this state vector when changing central body (for an interplanetary trajectory). For example my center body is the Earth, then when approaching the orbit of the Moon, I would like to express the state vector of the spacecraft in the same inertial frame but centered on the Moon.

For position transformation, it's just a translation (I compute planetary positions from a Chebyshev interpolation). But how do I transform the velocity of the spacecraft knowing that I do not have access to the planets velocity ? I have read some answers on this question here, but I can't use SPICE because I want to do this computation onboard the spacecraft. So is there an algorithm allowing to calculate the planets velocities via the Chebyshev coefficients ? Or is there another method to compute spacecraft velocity when changing central body ? I am interested by any paper talking about this.

• I'll try to draft a more complete answer later but you can get planet velocities from Chebyshev coefficients very easily as explained here space.stackexchange.com/questions/58484/…
– Rafa
Apr 21, 2022 at 0:41

You can get velocities of planets (and other higher order derivatives also in fact) from the Chebyshev coefficients. As @DavidHammen points out in this answer, the Chebyshev polynomial coefficients are differentiable. For example, see this answer. If you want to follow an implementation, you can check chbint from SPICE, or my own implementation in R.

From there, having obtained the velocities for the different bodies, with respect to the body currently being used as center of your frame of reference, you can easily get the velocity in the new frame of reference in the same way you would obtain the position.

• Thanks a lot ! I'm using the "original formulation" of Chebyshev's reccurrence instead of Clenshaw's recurrence. I have adapted the algorithm to compute the derivative with my formulation. Apr 21, 2022 at 10:24
• Great! Just out of curiosity, is there any special reason that you prefer the original recurrence instead of Clenshaw's algorithm? I believe the latter is significantly faster
– Rafa
Apr 22, 2022 at 3:55
• No special reason, but yes I guess the Clenshaw's algorithm is the best if they implemented this one in SPICE. Apr 22, 2022 at 8:08

SPICE only supports frame conversion when all of the state information is stored in one of the kernels.

For your onboard GNC, you'll need to perform the vector summation independently. For example, if your navigation state vector is in the Moon J2000 frame and you need it in the EME2000 frame, you'll need to query SPICE for the Moon J2000 to EME2000 state vector and then add that to the state vector of your navigation state.

(Source: my job)

• I would never recommend use SPICE in onboard GNC. Not ever. Apr 21, 2022 at 14:17
• I agree. That's why another GNC engineer and I have started working on ANISE: github.com/anise-toolkit . It'll support C, FORTRAN, Rust, and Python, and is designed for onboard GNC but also for working on desktop machine. Allows searching for ephemerides and mix-and-match of kernels (like a SPICE text meta kernel). Think of the platform as "docker for astrodynamics data" and the libraries as SPICE written by GNC & embedded software engineers. Apr 22, 2022 at 23:05

You may look at the C library calceph for the evaluation of the state vectors of the solar system bodies :

https://www.imcce.fr/inpop/calceph

https://gitlab.obspm.fr/imcce_calceph

Chebyshev polynomials are evaluated in this file: https://gitlab.obspm.fr/imcce_calceph/calceph/-/blob/master/src/calcephchebyshev.c