Hi Samuel, welcome
The simplest way to do this is to use an attitude provider to manage the attitude and a propagator to merge both the orbit and attitude together as time evolves.
The attitude provider would be:
AttitudeProvider attitudeProvider = new LofOffset(inertialFrame, LOFType.VNC, RotationOrder.XYZ,
FastMath.toRadians(39.976486),
FastMath.toRadians( 0.219314),
FastMath.toRadians( 0.0));
Beware I selected VNC as the base Local Orbital Frame, but it may be something different like LOFType.LVLH_CCSDS
You can register this to any propagator by calling propagator.setAttitudeProvider(attitudeProvider)
, then, each time you get a SpacecraftState
from the propagator (either inside a step handler during the propagation or at the end of the propagation), it will contain both the time-stamped orbit and attitude (and also mass and additional parameters, but you won’t need these).
So assuming state
is a SpacecraftState
, you can do this:
Transform inertToBody = state.getFrame().getTransformTo(earth.getBodyFrame(), state.getDate());
Transform scToBody = new Transform(state.getDate(),
state.toTransform().getInverse(),
inertToBody);
Vector3D position = scToBody.transformPosition(Vector3D.ZERO);
Vector3D farAwayAlongZ = scToBody.transformPosition(new Vector3D(1.0e6,
Vector3D.PLUS_K);
Line lineOfSight = new Line(position, farAwayAlongZ, 1.0e-3);
GeodeticPoint gp = earth.getIntersectionPoint(lineOfSight, position,
earth.getBodyFrame(),
state.getDate());