# How can I generate Chebyshev cofficients from SPICE for J2000 Inertial to Moon ME Frame?

I want to extract the Chebyshev coefficients in order to be able to calculate the time-varying transformation from the ICRF / J2000 Inertial frame to the Moon ME (moon mean earth) frame. I know I can use spiceypy and the associated PCK & FK files to get the rotation matrices at any time but I want a general expression for the transformation in our code since we can't implement the entire SPICE code in our software.

Is there a way to find the coefficients within the SPICE binary PCK? If not, can I possibly get rotation matrices at particular times and then interpolate that to get the Chebyshev? I'm not an expert here and any assistance or other suggestions would be appreciated.

This is what I have been reading: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/Tutorials/pdf/individual_docs/23_lunar-earth_pck-fk.pdf

I assume you're familiar with this list of documentation?: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/index.html

Here's a section on PCK files with Chebyshev polynomials: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/pck.html#Type%202:%20Chebyshev%20(Angles%20only)

This section might have details on manual access to the binary PCK records: https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/pck.html#Summary%20of%20Calling%20Sequences

You might have to break out some manual file i/o programming, but it looks like the coefficients are there without more computation required. Definitely take a look at the list of tools to see if there is anything that can assist.

If you decide to go for re-deriving it from rotation matrices, here is a snippet of C++ code that might help:

getRotAngVel(string frame, string bodyframe, SpiceDouble et)
{
// Get 6x6 transformation matrix (displacements and speeds)
sxform_c(frame.c_str(), bodyframe.c_str(), et, sxform);

SpiceDouble rotM[3][3]; //rotation matrix
SpiceDouble angVel[3]; //Axis of angular velocity, length gives magnitude in rad/s (probably?)

//get rot matrix, ang velocity
xf2rav_c(sxform, rotM, angVel);
...
}


frame is the name of the rotation frame of observation, and bodyframe is the name of the body-fixed (or I guess planet-fixed) rotation frame of the body in question. et is J2000 time.

• I wish I could upvote twice! – uhoh Aug 2 at 2:57