Search in sources :

Example 46 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class TabulatedEphemerisTest method checkInterpolation.

private void checkInterpolation(StateFilter f, double expectedDP, double expectedDV) throws OrekitException {
    double mass = 2500;
    double a = 7187990.1979844316;
    double e = 0.5e-4;
    double i = 1.7105407051081795;
    double omega = 1.9674147913622104;
    double OMEGA = FastMath.toRadians(261);
    double lv = 0;
    final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), TimeComponents.H00, TimeScalesFactory.getUTC());
    final AbsoluteDate finalDate = new AbsoluteDate(new DateComponents(2004, 01, 02), TimeComponents.H00, TimeScalesFactory.getUTC());
    double deltaT = finalDate.durationFrom(initDate);
    Orbit transPar = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
    int nbIntervals = 720;
    EcksteinHechlerPropagator eck = new EcksteinHechlerPropagator(transPar, mass, ae, mu, c20, c30, c40, c50, c60);
    AdditionalStateProvider provider = new AdditionalStateProvider() {

        public String getName() {
            return "dt";
        }

        public double[] getAdditionalState(SpacecraftState state) {
            return new double[] { state.getDate().durationFrom(initDate) };
        }
    };
    eck.addAdditionalStateProvider(provider);
    try {
        eck.addAdditionalStateProvider(provider);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.ADDITIONAL_STATE_NAME_ALREADY_IN_USE, oe.getSpecifier());
    }
    List<SpacecraftState> tab = new ArrayList<SpacecraftState>(nbIntervals + 1);
    for (int j = 0; j <= nbIntervals; j++) {
        AbsoluteDate current = initDate.shiftedBy((j * deltaT) / nbIntervals);
        tab.add(f.filter(eck.propagate(current)));
    }
    try {
        new Ephemeris(tab, nbIntervals + 2);
        Assert.fail("an exception should have been thrown");
    } catch (MathIllegalArgumentException miae) {
    // expected
    }
    Ephemeris te = new Ephemeris(tab, 2);
    Assert.assertEquals(0.0, te.getMaxDate().durationFrom(finalDate), 1.0e-9);
    Assert.assertEquals(0.0, te.getMinDate().durationFrom(initDate), 1.0e-9);
    double maxP = 0;
    double maxV = 0;
    for (double dt = 0; dt < 3600; dt += 1) {
        AbsoluteDate date = initDate.shiftedBy(dt);
        CartesianOrbit c1 = (CartesianOrbit) eck.propagate(date).getOrbit();
        CartesianOrbit c2 = (CartesianOrbit) te.propagate(date).getOrbit();
        maxP = FastMath.max(maxP, Vector3D.distance(c1.getPVCoordinates().getPosition(), c2.getPVCoordinates().getPosition()));
        maxV = FastMath.max(maxV, Vector3D.distance(c1.getPVCoordinates().getVelocity(), c2.getPVCoordinates().getVelocity()));
    }
    Assert.assertEquals(expectedDP, maxP, 0.1 * expectedDP);
    Assert.assertEquals(expectedDV, maxV, 0.1 * expectedDV);
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) ArrayList(java.util.ArrayList) DateComponents(org.orekit.time.DateComponents) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) AdditionalStateProvider(org.orekit.propagation.AdditionalStateProvider) MathIllegalArgumentException(org.hipparchus.exception.MathIllegalArgumentException) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException)

Example 47 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class EclipseDetectorTest method testInsideOcculting.

@Test
public void testInsideOcculting() throws OrekitException {
    EclipseDetector e = new EclipseDetector(sun, sunRadius, earth, earthRadius);
    SpacecraftState s = new SpacecraftState(new CartesianOrbit(new TimeStampedPVCoordinates(AbsoluteDate.J2000_EPOCH, new Vector3D(1e6, 2e6, 3e6), new Vector3D(1000, 0, 0)), FramesFactory.getGCRF(), mu));
    Assert.assertEquals(-FastMath.PI, e.g(s), 1.0e-15);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) Test(org.junit.Test)

Example 48 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class EclipseDetectorTest method testInsideOcculted.

@Test
public void testInsideOcculted() throws OrekitException {
    EclipseDetector e = new EclipseDetector(sun, sunRadius, earth, earthRadius);
    Vector3D p = sun.getPVCoordinates(AbsoluteDate.J2000_EPOCH, FramesFactory.getGCRF()).getPosition();
    SpacecraftState s = new SpacecraftState(new CartesianOrbit(new TimeStampedPVCoordinates(AbsoluteDate.J2000_EPOCH, p.add(Vector3D.PLUS_I), Vector3D.PLUS_K), FramesFactory.getGCRF(), mu));
    Assert.assertEquals(FastMath.PI, e.g(s), 1.0e-15);
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) Test(org.junit.Test)

Example 49 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class GPSPropagator method propagateOrbit.

/**
 * {@inheritDoc}
 */
protected Orbit propagateOrbit(final AbsoluteDate date) throws OrekitException {
    // Gets the PVCoordinates in ECEF frame
    final PVCoordinates pvaInECEF = propagateInEcef(date);
    // Transforms the PVCoordinates to ECI frame
    final PVCoordinates pvaInECI = ecef.getTransformTo(eci, date).transformPVCoordinates(pvaInECEF);
    // Returns the Cartesian orbit
    return new CartesianOrbit(pvaInECI, eci, date, GPSOrbitalElements.GPS_MU);
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) PVCoordinates(org.orekit.utils.PVCoordinates)

Example 50 with CartesianOrbit

use of org.orekit.orbits.CartesianOrbit in project Orekit by CS-SI.

the class Context method createBuilder.

public NumericalPropagatorBuilder createBuilder(final OrbitType orbitType, final PositionAngle positionAngle, final boolean perfectStart, final double minStep, final double maxStep, final double dP, final Force... forces) throws OrekitException {
    final Orbit startOrbit;
    if (perfectStart) {
        // orbit estimation will start from a perfect orbit
        startOrbit = initialOrbit;
    } else {
        // orbit estimation will start from a wrong point
        final Vector3D initialPosition = initialOrbit.getPVCoordinates().getPosition();
        final Vector3D initialVelocity = initialOrbit.getPVCoordinates().getVelocity();
        final Vector3D wrongPosition = initialPosition.add(new Vector3D(1000.0, 0, 0));
        final Vector3D wrongVelocity = initialVelocity.add(new Vector3D(0, 0, 0.01));
        startOrbit = new CartesianOrbit(new PVCoordinates(wrongPosition, wrongVelocity), initialOrbit.getFrame(), initialOrbit.getDate(), initialOrbit.getMu());
    }
    final NumericalPropagatorBuilder propagatorBuilder = new NumericalPropagatorBuilder(orbitType.convertType(startOrbit), new DormandPrince853IntegratorBuilder(minStep, maxStep, dP), positionAngle, dP);
    for (Force force : forces) {
        propagatorBuilder.addForceModel(force.getForceModel(this));
    }
    return propagatorBuilder;
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) Orbit(org.orekit.orbits.Orbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) PVCoordinates(org.orekit.utils.PVCoordinates) DormandPrince853IntegratorBuilder(org.orekit.propagation.conversion.DormandPrince853IntegratorBuilder)

Aggregations

CartesianOrbit (org.orekit.orbits.CartesianOrbit)57 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)48 AbsoluteDate (org.orekit.time.AbsoluteDate)43 SpacecraftState (org.orekit.propagation.SpacecraftState)38 Test (org.junit.Test)37 PVCoordinates (org.orekit.utils.PVCoordinates)32 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)28 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)25 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)22 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)20 Orbit (org.orekit.orbits.Orbit)20 Frame (org.orekit.frames.Frame)17 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)15 OrekitException (org.orekit.errors.OrekitException)14 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)14 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)13 BoundedPropagator (org.orekit.propagation.BoundedPropagator)11 Propagator (org.orekit.propagation.Propagator)10 TimeScale (org.orekit.time.TimeScale)10 DormandPrince853Integrator (org.hipparchus.ode.nonstiff.DormandPrince853Integrator)9