bug in GroundPointing's getAttitude()
We found a bug in the getAttitude(...)
of GroundPointing
class.
With the following code:
Attitude att1 = getAttitude(pvProv, date, frame1);
Attitude att2 = getAttitude(pvProv, date, frame2);
Attitude att3 = att2.withReferenceFrame(frame1);
the att3
Attitude
doesn't equal to att1
, and it should be.
A possible solution could be:
public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date,
final Frame frame)
throws OrekitException {
// inertial frame*
Frame eme2000 = FramesFactory.getEME2000();
// Construction of the satellite-target position/velocity vector at t-h, t and t+h
final double h = 0.1;
final AbsoluteDate dateM1H = date.shiftedBy(-h);
final PVCoordinates pvM1H = pvProv.getPVCoordinates(dateM1H, eme2000);
final Vector3D deltaPM1h = getTargetPoint(pvProv, dateM1H, eme2000).subtract(pvM1H.getPosition());
final PVCoordinates pv0 = pvProv.getPVCoordinates(date, eme2000);
final Vector3D deltaP0 = getTargetPoint(pvProv, date, eme2000).subtract(pv0.getPosition());
final AbsoluteDate dateP1H = date.shiftedBy(h);
final PVCoordinates pvP1H = pvProv.getPVCoordinates(dateP1H, eme2000);
final Vector3D deltaPP1h = getTargetPoint(pvProv, dateP1H, eme2000).subtract(pvP1H.getPosition());
// New orekit exception if null position.
if (deltaP0.equals(Vector3D.ZERO)) {
throw new OrekitException(OrekitMessages.SATELLITE_COLLIDED_WITH_TARGET);
}
// Attitude rotation:
// line of sight computed from inertial frame -> z satellite axis,
// satellite velocity computed from inertial frame -> x satellite axis.
final Rotation rot = new Rotation(deltaP0, pv0.getVelocity(), Vector3D.PLUS_K, Vector3D.PLUS_I);
// Attitude spin
final Rotation rotM1h = new Rotation(deltaPM1h, pvM1H.getVelocity(), Vector3D.PLUS_K, Vector3D.PLUS_I);
final Rotation rotP1h = new Rotation(deltaPP1h, pvP1H.getVelocity(), Vector3D.PLUS_K, Vector3D.PLUS_I);
final Vector3D spin = AngularCoordinates.estimateRate(rotM1h, rotP1h, 2 * h);
return new Attitude(date, eme2000, rot, spin).withReferenceFrame(frame);
}
Regards,
Julien
(from redmine: issue id 115, created on 2012-09-21, closed on 2016-02-10)