Search in sources :

Example 56 with PVCoordinates

use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.

the class EquinoctialOrbitTest method testEquinoctialToEquinoctialCirc.

@Test
public void testEquinoctialToEquinoctialCirc() {
    double ix = 1.200e-04;
    double iy = -1.16e-04;
    double inc = 2 * FastMath.asin(FastMath.sqrt((ix * ix + iy * iy) / 4.));
    double hx = FastMath.tan(inc / 2.) * ix / (2 * FastMath.sin(inc / 2.));
    double hy = FastMath.tan(inc / 2.) * iy / (2 * FastMath.sin(inc / 2.));
    // circular orbit
    EquinoctialOrbit equiCir = new EquinoctialOrbit(42166.712, 0.1e-10, -0.1e-10, hx, hy, 5.300, PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
    Vector3D posCir = equiCir.getPVCoordinates().getPosition();
    Vector3D vitCir = equiCir.getPVCoordinates().getVelocity();
    PVCoordinates pvCoordinates = new PVCoordinates(posCir, vitCir);
    EquinoctialOrbit paramCir = new EquinoctialOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu);
    Assert.assertEquals(paramCir.getA(), equiCir.getA(), Utils.epsilonTest * equiCir.getA());
    Assert.assertEquals(paramCir.getEquinoctialEx(), equiCir.getEquinoctialEx(), Utils.epsilonEcir * FastMath.abs(equiCir.getE()));
    Assert.assertEquals(paramCir.getEquinoctialEy(), equiCir.getEquinoctialEy(), Utils.epsilonEcir * FastMath.abs(equiCir.getE()));
    Assert.assertEquals(paramCir.getHx(), equiCir.getHx(), Utils.epsilonAngle * FastMath.abs(equiCir.getI()));
    Assert.assertEquals(paramCir.getHy(), equiCir.getHy(), Utils.epsilonAngle * FastMath.abs(equiCir.getI()));
    Assert.assertEquals(MathUtils.normalizeAngle(paramCir.getLv(), equiCir.getLv()), equiCir.getLv(), Utils.epsilonAngle * FastMath.abs(equiCir.getLv()));
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) Test(org.junit.Test)

Example 57 with PVCoordinates

use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.

the class CircularOrbitTest method testCircularToEquinoctialEll.

@Test
public void testCircularToEquinoctialEll() {
    double ix = 1.200e-04;
    double iy = -1.16e-04;
    double i = 2 * FastMath.asin(FastMath.sqrt((ix * ix + iy * iy) / 4));
    double raan = FastMath.atan2(iy, ix);
    // elliptic orbit
    CircularOrbit circ = new CircularOrbit(42166.712, 0.5, -0.5, i, raan, 5.300 - raan, PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
    Vector3D pos = circ.getPVCoordinates().getPosition();
    Vector3D vit = circ.getPVCoordinates().getVelocity();
    PVCoordinates pvCoordinates = new PVCoordinates(pos, vit);
    EquinoctialOrbit param = new EquinoctialOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu);
    Assert.assertEquals(param.getA(), circ.getA(), Utils.epsilonTest * circ.getA());
    Assert.assertEquals(param.getEquinoctialEx(), circ.getEquinoctialEx(), Utils.epsilonE * FastMath.abs(circ.getE()));
    Assert.assertEquals(param.getEquinoctialEy(), circ.getEquinoctialEy(), Utils.epsilonE * FastMath.abs(circ.getE()));
    Assert.assertEquals(param.getHx(), circ.getHx(), Utils.epsilonAngle * FastMath.abs(circ.getI()));
    Assert.assertEquals(param.getHy(), circ.getHy(), Utils.epsilonAngle * FastMath.abs(circ.getI()));
    Assert.assertEquals(MathUtils.normalizeAngle(param.getLv(), circ.getLv()), circ.getLv(), Utils.epsilonAngle * FastMath.abs(circ.getLv()));
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) Test(org.junit.Test)

Example 58 with PVCoordinates

use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.

the class CircularOrbitTest method doTestInterpolation.

private void doTestInterpolation(boolean useDerivatives, double shiftErrorWithin, double interpolationErrorWithin, double shiftErrorSlightlyPast, double interpolationErrorSlightlyPast, double shiftErrorFarPast, double interpolationErrorFarPast) throws OrekitException {
    final double ehMu = 3.9860047e14;
    final double ae = 6.378137e6;
    final double c20 = -1.08263e-3;
    final double c30 = 2.54e-6;
    final double c40 = 1.62e-6;
    final double c50 = 2.3e-7;
    final double c60 = -5.5e-7;
    final AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
    final Vector3D position = new Vector3D(3220103., 69623., 6449822.);
    final Vector3D velocity = new Vector3D(6414.7, -2006., -3180.);
    final CircularOrbit initialOrbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, ehMu);
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(initialOrbit, ae, ehMu, c20, c30, c40, c50, c60);
    // set up a 5 points sample
    List<Orbit> sample = new ArrayList<Orbit>();
    for (double dt = 0; dt < 300.0; dt += 60.0) {
        Orbit orbit = propagator.propagate(date.shiftedBy(dt)).getOrbit();
        if (!useDerivatives) {
            // remove derivatives
            double[] stateVector = new double[6];
            orbit.getType().mapOrbitToArray(orbit, PositionAngle.TRUE, stateVector, null);
            orbit = orbit.getType().mapArrayToOrbit(stateVector, null, PositionAngle.TRUE, orbit.getDate(), orbit.getMu(), orbit.getFrame());
        }
        sample.add(orbit);
    }
    // well inside the sample, interpolation should be much better than Keplerian shift
    double maxShiftError = 0;
    double maxInterpolationError = 0;
    for (double dt = 0; dt < 241.0; dt += 1.0) {
        AbsoluteDate t = initialOrbit.getDate().shiftedBy(dt);
        Vector3D shifted = initialOrbit.shiftedBy(dt).getPVCoordinates().getPosition();
        Vector3D interpolated = initialOrbit.interpolate(t, sample).getPVCoordinates().getPosition();
        Vector3D propagated = propagator.propagate(t).getPVCoordinates().getPosition();
        maxShiftError = FastMath.max(maxShiftError, shifted.subtract(propagated).getNorm());
        maxInterpolationError = FastMath.max(maxInterpolationError, interpolated.subtract(propagated).getNorm());
    }
    Assert.assertEquals(shiftErrorWithin, maxShiftError, 0.01 * shiftErrorWithin);
    Assert.assertEquals(interpolationErrorWithin, maxInterpolationError, 0.01 * interpolationErrorWithin);
    // slightly past sample end, interpolation should quickly increase, but remain reasonable
    maxShiftError = 0;
    maxInterpolationError = 0;
    for (double dt = 240; dt < 300.0; dt += 1.0) {
        AbsoluteDate t = initialOrbit.getDate().shiftedBy(dt);
        Vector3D shifted = initialOrbit.shiftedBy(dt).getPVCoordinates().getPosition();
        Vector3D interpolated = initialOrbit.interpolate(t, sample).getPVCoordinates().getPosition();
        Vector3D propagated = propagator.propagate(t).getPVCoordinates().getPosition();
        maxShiftError = FastMath.max(maxShiftError, shifted.subtract(propagated).getNorm());
        maxInterpolationError = FastMath.max(maxInterpolationError, interpolated.subtract(propagated).getNorm());
    }
    Assert.assertEquals(shiftErrorSlightlyPast, maxShiftError, 0.01 * shiftErrorSlightlyPast);
    Assert.assertEquals(interpolationErrorSlightlyPast, maxInterpolationError, 0.01 * interpolationErrorSlightlyPast);
    // far past sample end, interpolation should become really wrong
    maxShiftError = 0;
    maxInterpolationError = 0;
    for (double dt = 300; dt < 1000; dt += 1.0) {
        AbsoluteDate t = initialOrbit.getDate().shiftedBy(dt);
        Vector3D shifted = initialOrbit.shiftedBy(dt).getPVCoordinates().getPosition();
        Vector3D interpolated = initialOrbit.interpolate(t, sample).getPVCoordinates().getPosition();
        Vector3D propagated = propagator.propagate(t).getPVCoordinates().getPosition();
        maxShiftError = FastMath.max(maxShiftError, shifted.subtract(propagated).getNorm());
        maxInterpolationError = FastMath.max(maxInterpolationError, interpolated.subtract(propagated).getNorm());
    }
    Assert.assertEquals(shiftErrorFarPast, maxShiftError, 0.01 * shiftErrorFarPast);
    Assert.assertEquals(interpolationErrorFarPast, maxInterpolationError, 0.01 * interpolationErrorFarPast);
}
Also used : EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) ArrayList(java.util.ArrayList) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate)

Example 59 with PVCoordinates

use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.

the class CircularOrbitTest method testAnomalyCirc.

@Test
public void testAnomalyCirc() {
    Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
    Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);
    PVCoordinates pvCoordinates = new PVCoordinates(position, velocity);
    CircularOrbit p = new CircularOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu);
    double raan = p.getRightAscensionOfAscendingNode();
    // circular orbit
    p = new CircularOrbit(p.getA(), 0, 0, p.getRightAscensionOfAscendingNode(), p.getAlphaV(), p.getAlphaV(), PositionAngle.TRUE, p.getFrame(), date, mu);
    double lv = 1.1;
    double lE = lv;
    double lM = lE;
    p = new CircularOrbit(p.getA(), p.getCircularEx(), p.getCircularEy(), p.getRightAscensionOfAscendingNode(), p.getAlphaV(), lv - raan, PositionAngle.TRUE, p.getFrame(), date, mu);
    Assert.assertEquals(p.getAlphaV() + raan, lv, Utils.epsilonAngle * FastMath.abs(lv));
    Assert.assertEquals(p.getAlphaE() + raan, lE, Utils.epsilonAngle * FastMath.abs(lE));
    Assert.assertEquals(p.getAlphaM() + raan, lM, Utils.epsilonAngle * FastMath.abs(lM));
    p = new CircularOrbit(p.getA(), p.getCircularEx(), p.getCircularEy(), p.getRightAscensionOfAscendingNode(), p.getAlphaV(), 0, PositionAngle.TRUE, p.getFrame(), date, mu);
    p = new CircularOrbit(p.getA(), p.getCircularEx(), p.getCircularEy(), p.getRightAscensionOfAscendingNode(), p.getAlphaV(), lE - raan, PositionAngle.ECCENTRIC, p.getFrame(), date, mu);
    Assert.assertEquals(p.getAlphaV() + raan, lv, Utils.epsilonAngle * FastMath.abs(lv));
    Assert.assertEquals(p.getAlphaE() + raan, lE, Utils.epsilonAngle * FastMath.abs(lE));
    Assert.assertEquals(p.getAlphaM() + raan, lM, Utils.epsilonAngle * FastMath.abs(lM));
    p = new CircularOrbit(p.getA(), p.getCircularEx(), p.getCircularEy(), p.getRightAscensionOfAscendingNode(), p.getAlphaV(), 0, PositionAngle.TRUE, p.getFrame(), date, mu);
    p = new CircularOrbit(p.getA(), p.getCircularEx(), p.getCircularEy(), p.getRightAscensionOfAscendingNode(), p.getAlphaV(), lM - raan, PositionAngle.MEAN, p.getFrame(), date, mu);
    Assert.assertEquals(p.getAlphaV() + raan, lv, Utils.epsilonAngle * FastMath.abs(lv));
    Assert.assertEquals(p.getAlphaE() + raan, lE, Utils.epsilonAngle * FastMath.abs(lE));
    Assert.assertEquals(p.getAlphaM() + raan, lM, Utils.epsilonAngle * FastMath.abs(lM));
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) Test(org.junit.Test)

Example 60 with PVCoordinates

use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.

the class CircularOrbitTest method testSerializationWithDerivatives.

@Test
public void testSerializationWithDerivatives() throws IOException, ClassNotFoundException {
    Vector3D position = new Vector3D(-29536113.0, 30329259.0, -100125.0);
    Vector3D velocity = new Vector3D(-2194.0, -2141.0, -8.0);
    double r2 = position.getNormSq();
    double r = FastMath.sqrt(r2);
    Vector3D acceleration = new Vector3D(-mu / (r * r2), position, 1, new Vector3D(-0.1, 0.2, 0.3));
    PVCoordinates pvCoordinates = new PVCoordinates(position, velocity, acceleration);
    CircularOrbit orbit = new CircularOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu);
    Assert.assertEquals(42255170.003, orbit.getA(), 1.0e-3);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(orbit);
    Assert.assertTrue(bos.size() > 400);
    Assert.assertTrue(bos.size() < 450);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    CircularOrbit deserialized = (CircularOrbit) ois.readObject();
    Assert.assertEquals(orbit.getA(), deserialized.getA(), 1.0e-10);
    Assert.assertEquals(orbit.getCircularEx(), deserialized.getCircularEx(), 1.0e-10);
    Assert.assertEquals(orbit.getCircularEy(), deserialized.getCircularEy(), 1.0e-10);
    Assert.assertEquals(orbit.getI(), deserialized.getI(), 1.0e-10);
    Assert.assertEquals(orbit.getRightAscensionOfAscendingNode(), deserialized.getRightAscensionOfAscendingNode(), 1.0e-10);
    Assert.assertEquals(orbit.getAlphaV(), deserialized.getAlphaV(), 1.0e-10);
    Assert.assertEquals(orbit.getADot(), deserialized.getADot(), 1.0e-10);
    Assert.assertEquals(orbit.getCircularExDot(), deserialized.getCircularExDot(), 1.0e-10);
    Assert.assertEquals(orbit.getCircularEyDot(), deserialized.getCircularEyDot(), 1.0e-10);
    Assert.assertEquals(orbit.getIDot(), deserialized.getIDot(), 1.0e-10);
    Assert.assertEquals(orbit.getRightAscensionOfAscendingNodeDot(), deserialized.getRightAscensionOfAscendingNodeDot(), 1.0e-10);
    Assert.assertEquals(orbit.getAlphaVDot(), deserialized.getAlphaVDot(), 1.0e-10);
    Assert.assertEquals(orbit.getDate(), deserialized.getDate());
    Assert.assertEquals(orbit.getMu(), deserialized.getMu(), 1.0e-10);
    Assert.assertEquals(orbit.getFrame().getName(), deserialized.getFrame().getName());
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) ByteArrayInputStream(java.io.ByteArrayInputStream) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Aggregations

PVCoordinates (org.orekit.utils.PVCoordinates)341 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)271 Test (org.junit.Test)242 AbsoluteDate (org.orekit.time.AbsoluteDate)189 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)159 SpacecraftState (org.orekit.propagation.SpacecraftState)95 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)76 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)73 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)71 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)67 Orbit (org.orekit.orbits.Orbit)65 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)57 Frame (org.orekit.frames.Frame)53 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)44 CartesianOrbit (org.orekit.orbits.CartesianOrbit)43 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)42 DateComponents (org.orekit.time.DateComponents)40 CircularOrbit (org.orekit.orbits.CircularOrbit)37 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)30 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)30