use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class KeplerianOrbitTest method testPositionAngleHyperbolicDerivatives.
@Test
public void testPositionAngleHyperbolicDerivatives() throws OrekitException {
final AbsoluteDate date = new AbsoluteDate("2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
final Vector3D position = new Vector3D(224267911.905821, 290251613.109399, 45534292.777492);
final Vector3D velocity = new Vector3D(-1494.068165293, 1124.771027677, 526.915286134);
final Vector3D acceleration = new Vector3D(-0.001295920501, -0.002233045187, -0.000349906292);
final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
final Frame frame = FramesFactory.getEME2000();
final double mu = Constants.EIGEN5C_EARTH_MU;
final KeplerianOrbit orbit = new KeplerianOrbit(pv, frame, mu);
for (PositionAngle type : PositionAngle.values()) {
final KeplerianOrbit rebuilt = new KeplerianOrbit(orbit.getA(), orbit.getE(), orbit.getI(), orbit.getPerigeeArgument(), orbit.getRightAscensionOfAscendingNode(), orbit.getAnomaly(type), orbit.getADot(), orbit.getEDot(), orbit.getIDot(), orbit.getPerigeeArgumentDot(), orbit.getRightAscensionOfAscendingNodeDot(), orbit.getAnomalyDot(type), type, orbit.getFrame(), orbit.getDate(), orbit.getMu());
Assert.assertThat(rebuilt.getA(), relativelyCloseTo(orbit.getA(), 1));
Assert.assertThat(rebuilt.getE(), relativelyCloseTo(orbit.getE(), 1));
Assert.assertThat(rebuilt.getI(), relativelyCloseTo(orbit.getI(), 1));
Assert.assertThat(rebuilt.getPerigeeArgument(), relativelyCloseTo(orbit.getPerigeeArgument(), 1));
Assert.assertThat(rebuilt.getRightAscensionOfAscendingNode(), relativelyCloseTo(orbit.getRightAscensionOfAscendingNode(), 1));
Assert.assertThat(rebuilt.getADot(), relativelyCloseTo(orbit.getADot(), 1));
Assert.assertThat(rebuilt.getEDot(), relativelyCloseTo(orbit.getEDot(), 1));
Assert.assertThat(rebuilt.getIDot(), relativelyCloseTo(orbit.getIDot(), 1));
Assert.assertThat(rebuilt.getPerigeeArgumentDot(), relativelyCloseTo(orbit.getPerigeeArgumentDot(), 1));
Assert.assertThat(rebuilt.getRightAscensionOfAscendingNodeDot(), relativelyCloseTo(orbit.getRightAscensionOfAscendingNodeDot(), 1));
for (PositionAngle type2 : PositionAngle.values()) {
Assert.assertThat(rebuilt.getAnomaly(type2), relativelyCloseTo(orbit.getAnomaly(type2), 2));
Assert.assertThat(rebuilt.getAnomalyDot(type2), relativelyCloseTo(orbit.getAnomalyDot(type2), 4));
}
}
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class KeplerianOrbitTest method testNonKeplerianEllipticDerivatives.
@Test
public void testNonKeplerianEllipticDerivatives() throws OrekitException {
final AbsoluteDate date = new AbsoluteDate("2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
final Vector3D position = new Vector3D(6896874.444705, 1956581.072644, -147476.245054);
final Vector3D velocity = new Vector3D(166.816407662, -1106.783301861, -7372.745712770);
final Vector3D acceleration = new Vector3D(-7.466182457944, -2.118153357345, 0.160004048437);
final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
final Frame frame = FramesFactory.getEME2000();
final double mu = Constants.EIGEN5C_EARTH_MU;
final KeplerianOrbit orbit = new KeplerianOrbit(pv, frame, mu);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getA()), orbit.getADot(), 4.3e-8);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEx()), orbit.getEquinoctialExDot(), 2.1e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEy()), orbit.getEquinoctialEyDot(), 5.3e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHx()), orbit.getHxDot(), 1.6e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHy()), orbit.getHyDot(), 7.3e-17);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLv()), orbit.getLvDot(), 1.1e-14);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLE()), orbit.getLEDot(), 7.2e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLM()), orbit.getLMDot(), 4.7e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getE()), orbit.getEDot(), 6.9e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getI()), orbit.getIDot(), 5.8e-16);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getPerigeeArgument()), orbit.getPerigeeArgumentDot(), 1.5e-12);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getRightAscensionOfAscendingNode()), orbit.getRightAscensionOfAscendingNodeDot(), 1.5e-15);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getTrueAnomaly()), orbit.getTrueAnomalyDot(), 1.5e-12);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEccentricAnomaly()), orbit.getEccentricAnomalyDot(), 1.5e-12);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getMeanAnomaly()), orbit.getMeanAnomalyDot(), 1.5e-12);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.TRUE)), orbit.getAnomalyDot(PositionAngle.TRUE), 1.5e-12);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.ECCENTRIC)), orbit.getAnomalyDot(PositionAngle.ECCENTRIC), 1.5e-12);
Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getAnomaly(PositionAngle.MEAN)), orbit.getAnomalyDot(PositionAngle.MEAN), 1.5e-12);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class EcksteinHechlerPropagatorTest method testAcceleration.
@Test
public void testAcceleration() throws OrekitException {
final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, provider.getMu());
EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, provider);
AbsoluteDate target = AbsoluteDate.J2000_EPOCH.shiftedBy(10000.0);
List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
for (double dt : Arrays.asList(-0.5, 0.0, 0.5)) {
sample.add(propagator.propagate(target.shiftedBy(dt)).getPVCoordinates());
}
TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(target, CartesianDerivativesFilter.USE_P, sample);
Vector3D computedP = sample.get(1).getPosition();
Vector3D computedV = sample.get(1).getVelocity();
Vector3D referenceP = interpolated.getPosition();
Vector3D referenceV = interpolated.getVelocity();
Vector3D computedA = sample.get(1).getAcceleration();
Vector3D referenceA = interpolated.getAcceleration();
final CircularOrbit propagated = (CircularOrbit) OrbitType.CIRCULAR.convertType(propagator.propagateOrbit(target));
final CircularOrbit keplerian = new CircularOrbit(propagated.getA(), propagated.getCircularEx(), propagated.getCircularEy(), propagated.getI(), propagated.getRightAscensionOfAscendingNode(), propagated.getAlphaM(), PositionAngle.MEAN, propagated.getFrame(), propagated.getDate(), propagated.getMu());
Vector3D keplerianP = keplerian.getPVCoordinates().getPosition();
Vector3D keplerianV = keplerian.getPVCoordinates().getVelocity();
Vector3D keplerianA = keplerian.getPVCoordinates().getAcceleration();
// perturbed orbit position should be similar to Keplerian orbit position
Assert.assertEquals(0.0, Vector3D.distance(referenceP, computedP), 1.0e-15);
Assert.assertEquals(0.0, Vector3D.distance(referenceP, keplerianP), 4.0e-9);
// perturbed orbit velocity should be equal to Keplerian orbit because
// it was in fact reconstructed from Cartesian coordinates
double computationErrorV = Vector3D.distance(referenceV, computedV);
double nonKeplerianEffectV = Vector3D.distance(referenceV, keplerianV);
Assert.assertEquals(nonKeplerianEffectV, computationErrorV, 9.0e-13);
Assert.assertEquals(2.2e-4, computationErrorV, 3.0e-6);
// perturbed orbit acceleration should be different from Keplerian orbit because
// Keplerian orbit doesn't take orbit shape changes into account
// perturbed orbit acceleration should be consistent with position evolution
double computationErrorA = Vector3D.distance(referenceA, computedA);
double nonKeplerianEffectA = Vector3D.distance(referenceA, keplerianA);
Assert.assertEquals(1.0e-7, computationErrorA, 6.0e-9);
Assert.assertEquals(6.37e-3, nonKeplerianEffectA, 7.0e-6);
Assert.assertTrue(computationErrorA < nonKeplerianEffectA / 60000);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class EphemerisTest method testSerialization.
@Test
public void testSerialization() throws OrekitException, IOException, ClassNotFoundException {
propagator.setAttitudeProvider(new LofOffset(inertialFrame, LOFType.VVLH));
int numberOfIntervals = 150;
double deltaT = finalDate.durationFrom(initDate) / numberOfIntervals;
List<SpacecraftState> states = new ArrayList<SpacecraftState>(numberOfIntervals + 1);
for (int j = 0; j <= numberOfIntervals; j++) {
states.add(propagator.propagate(initDate.shiftedBy((j * deltaT))));
}
int numInterpolationPoints = 2;
Ephemeris ephemPropagator = new Ephemeris(states, numInterpolationPoints, 1.25);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(ephemPropagator);
Assert.assertTrue(bos.size() > 30000);
Assert.assertTrue(bos.size() < 31000);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
Ephemeris deserialized = (Ephemeris) ois.readObject();
Assert.assertEquals(deserialized.getMinDate(), ephemPropagator.getMinDate());
Assert.assertEquals(deserialized.getMaxDate(), ephemPropagator.getMaxDate());
Assert.assertEquals(deserialized.getExtrapolationThreshold(), ephemPropagator.getExtrapolationThreshold(), 1.0e-15);
for (double dt = 0; dt < finalDate.durationFrom(initDate); dt += 10.0) {
AbsoluteDate date = initDate.shiftedBy(dt);
TimeStampedPVCoordinates pvRef = ephemPropagator.getPVCoordinates(date, inertialFrame);
TimeStampedPVCoordinates pv = deserialized.getPVCoordinates(date, inertialFrame);
Assert.assertEquals(0.0, Vector3D.distance(pvRef.getPosition(), pv.getPosition()), 1.0e-15);
Assert.assertEquals(0.0, Vector3D.distance(pvRef.getVelocity(), pv.getVelocity()), 1.0e-15);
Assert.assertEquals(0.0, Vector3D.distance(pvRef.getAcceleration(), pv.getAcceleration()), 1.0e-15);
}
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class LofOffsetPointingTest method checkField.
private <T extends RealFieldElement<T>> void checkField(final Field<T> field, final GroundPointing provider, final Orbit orbit, final AbsoluteDate date, final Frame frame) throws OrekitException {
final Attitude attitudeD = provider.getAttitude(orbit, date, frame);
final FieldOrbit<T> orbitF = new FieldSpacecraftState<>(field, new SpacecraftState(orbit)).getOrbit();
final FieldAbsoluteDate<T> dateF = new FieldAbsoluteDate<>(field, date);
final FieldAttitude<T> attitudeF = provider.getAttitude(orbitF, dateF, frame);
Assert.assertEquals(0.0, Rotation.distance(attitudeD.getRotation(), attitudeF.getRotation().toRotation()), 1.0e-15);
Assert.assertEquals(0.0, Vector3D.distance(attitudeD.getSpin(), attitudeF.getSpin().toVector3D()), 1.0e-15);
Assert.assertEquals(0.0, Vector3D.distance(attitudeD.getRotationAcceleration(), attitudeF.getRotationAcceleration().toVector3D()), 1.0e-15);
final TimeStampedPVCoordinates pvD = provider.getTargetPV(orbit, date, frame);
final TimeStampedFieldPVCoordinates<T> pvF = provider.getTargetPV(orbitF, dateF, frame);
Assert.assertEquals(0.0, Vector3D.distance(pvD.getPosition(), pvF.getPosition().toVector3D()), 9.0e-9);
Assert.assertEquals(0.0, Vector3D.distance(pvD.getVelocity(), pvF.getVelocity().toVector3D()), 5.0e-9);
Assert.assertEquals(0.0, Vector3D.distance(pvD.getAcceleration(), pvF.getAcceleration().toVector3D()), 4.0e-5);
}
Aggregations