CR3BP Frame Transformation - JavaError ("Cannot Normalize a Zero Norm Vector")

Hello,

I am currently working on creating a frame transformation function in Orekit for a CR3BP system. Specifically, I am trying to transform a spacecraft state from the J2000 inertial frame to the PrimaryRotating frame. I am using Earth as my primary body and Moon as my secondary body.

Here is my function I created and my test file:

Test :
#j200 to primary
transformedState_jp = CR3BPFrameTransformation(
spacecraftState, “J2000”, “PrimaryRotating”, primary=earth, secondary=moon, mu=None, semiMajorAxis=semiMajorAxis
)
print(“Transformed Position (m):”, transformedState_jp.getPVCoordinates().getPosition())
print(“Transformed Velocity (m/s):”, transformedState_jp.getPVCoordinates().getVelocity())

The transformations to the BarycenterRotating and SecondaryRotating frames seem to be working as expected. However, when I attempt to transform the state to the PrimaryRotating frame, I encounter the following error:

“org.hipparchus.exception.MathRuntimeException: cannot normalize a zero norm vector”

I am confused about what exactly is causing this error and why it occurs when transforming to the PrimaryRotating frame. Is there a more appropriate way to handle the transformation from the J2000 inertial frame to the PrimaryRotating frame in the CR3BP system?

Any help or insights would be greatly appreciated!

Thank you!

I guess that if your primary is Earth and you also use EME200 that is Earth-centered, you may have a zero vector somewhere due to the zero translation (a Transform contains both a translation and a rotation).