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):
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 )
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 )
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.