# Help converting from ECEF frame to ICRF frame for interplanetary mission design

I am writing a piece of software which propagates the orbit of a spacecraft from an initial Earth orbit to an interplanetary orbit. My simple two-body propagation works fine in either a geocentric or heliocentric orbit. However, I cannot seem to handle the transition correctly.

Here are the steps of that transition (I can share relevant code if useful):

1. Get ecliptic J200 position of Earth (via https://github.com/soniakeys/meeus/blob/master/planetposition/planetposition.go#L195 ) and compute the velocity of Earth (via equations in the first pages of Vallado - Fundamentals in Astrodynamics). Note that the "meeus/planetposition" library returns the ecliptic positions in L, B, R, which I convert to cartesian coordinates (via https://en.wikipedia.org/wiki/Ecliptic_coordinate_system#Rectangular_coordinates )

2. Rotate the radius and velocity vectors of my geocentric orbit about the first axis and by the axial tilt of Earth (as per https://en.wikipedia.org/wiki/Ecliptic_coordinate_system#Converting_Cartesian_vectors )

3. Add the spacecraft R and V vectors computed in step 2 to the radius and velocity vectors of the planet computed in step 1 (since $r_{\text{sc}_{\text{helio}}} = r_{\text{sc}_{\text{earth}}} + r_{\text{earth}_{\text{helio}}}$)

When visualizing both trajectories in Cosmographia, I can definitely tell that the computation is wrong (cf. the two screenshots below). I have been stuck on this issue for a few hours now (about twelve I'd say), so any help would be greatly appreciated.

• This is a good place to ask, but you can also look in Astronomy SE and Math SE for potentially helpful pre-existing answers as well. – uhoh Oct 31 '16 at 5:53
• I highly recommend the use of JPL's SPICE Toolkit for coordinate frame conversions, as well as many other things, such as accessing natural body and spacecraft ephemerides. – Mark Adler Oct 31 '16 at 13:58
• I know of SPICE, however, it isn't feasible for me to use it currently (I was initially hoping to use it). My software is written entirely in Go without any bindings to other languages. – ChrisR Oct 31 '16 at 14:17