List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D
public Vector3D(double x, double y, double z)
From source file:org.orekit.orbits.KeplerianParametersTest.java
@Test public void testSerialization() throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException { Vector3D position = new Vector3D(-29536113.0, 30329259.0, -100125.0); Vector3D velocity = new Vector3D(-2194.0, -2141.0, -8.0); PVCoordinates pvCoordinates = new PVCoordinates(position, velocity); KeplerianOrbit orbit = new KeplerianOrbit(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);//from w w w .j a v a 2 s . c o m Assert.assertTrue(bos.size() > 250); Assert.assertTrue(bos.size() < 350); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); KeplerianOrbit deserialized = (KeplerianOrbit) ois.readObject(); Assert.assertEquals(orbit.getA(), deserialized.getA(), 1.0e-10); Assert.assertEquals(orbit.getE(), deserialized.getE(), 1.0e-10); Assert.assertEquals(orbit.getI(), deserialized.getI(), 1.0e-10); Assert.assertEquals(orbit.getPerigeeArgument(), deserialized.getPerigeeArgument(), 1.0e-10); Assert.assertEquals(orbit.getRightAscensionOfAscendingNode(), deserialized.getRightAscensionOfAscendingNode(), 1.0e-10); Assert.assertEquals(orbit.getTrueAnomaly(), deserialized.getTrueAnomaly(), 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()); }
From source file:org.orekit.OrekitMatchers.java
/** * Alias for {@link #vectorCloseTo(Vector3D, int)} * * @param x the x component/*from ww w . j av a2 s . c om*/ * @param y the y component * @param z the z component * @param ulps the relative tolerance, in ulps * @return a vector matcher */ public static Matcher<Vector3D> vectorCloseTo(double x, double y, double z, int ulps) { return vectorCloseTo(new Vector3D(x, y, z), ulps); }
From source file:org.orekit.propagation.analytical.AdapterPropagatorTest.java
@Test public void testLowEarthOrbit() throws OrekitException, ParseException, IOException { Orbit leo = new CircularOrbit( 7200000.0, -1.0e-5, 2.0e-4, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.0, PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU); double mass = 5600.0; AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0); Vector3D dV = new Vector3D(-0.1, 0.2, 0.3); double f = 20.0; double isp = 315.0; double vExhaust = Constants.G0_STANDARD_GRAVITY * isp; double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust); BoundedPropagator withoutManeuver = getEphemeris(leo, mass, 5, new LofOffset(leo.getFrame(), LOFType.LVLH), t0, Vector3D.ZERO, f, isp, false, false, null); BoundedPropagator withManeuver = getEphemeris(leo, mass, 5, new LofOffset(leo.getFrame(), LOFType.LVLH), t0, dV, f, isp, false, false, null); // we set up a model that reverts the maneuvers AdapterPropagator adapterPropagator = new AdapterPropagator(withManeuver); AdapterPropagator.DifferentialEffect effect = new SmallManeuverAnalyticalModel( adapterPropagator.propagate(t0), dV.negate(), isp); adapterPropagator.addEffect(effect); adapterPropagator.addAdditionalStateProvider(new AdditionalStateProvider() { public String getName() { return "dummy 3"; }//from ww w . j ava2 s .com public double[] getAdditionalState(SpacecraftState state) { return new double[3]; } }); // the adapted propagators do not manage the additional states from the reference, // they simply forward them Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 1")); Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 2")); Assert.assertTrue(adapterPropagator.isAdditionalStateManaged("dummy 3")); for (AbsoluteDate t = t0.shiftedBy(0.5 * dt); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t .shiftedBy(60.0)) { PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, leo.getFrame()); PVCoordinates pvReverted = adapterPropagator.getPVCoordinates(t, leo.getFrame()); double revertError = new PVCoordinates(pvWithout, pvReverted).getPosition().getNorm(); Assert.assertEquals(0, revertError, 0.45); Assert.assertEquals(2, adapterPropagator.propagate(t).getAdditionalState("dummy 1").length); Assert.assertEquals(1, adapterPropagator.propagate(t).getAdditionalState("dummy 2").length); Assert.assertEquals(3, adapterPropagator.propagate(t).getAdditionalState("dummy 3").length); } }
From source file:org.orekit.propagation.analytical.AdapterPropagatorTest.java
@Test public void testEccentricOrbit() throws OrekitException, ParseException, IOException { Orbit heo = new KeplerianOrbit(90000000.0, 0.92, FastMath.toRadians(98.0), FastMath.toRadians(12.3456), FastMath.toRadians(123.456), FastMath.toRadians(1.23456), PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU); double mass = 5600.0; AbsoluteDate t0 = heo.getDate().shiftedBy(1000.0); Vector3D dV = new Vector3D(-0.01, 0.02, 0.03); double f = 20.0; double isp = 315.0; double vExhaust = Constants.G0_STANDARD_GRAVITY * isp; double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust); BoundedPropagator withoutManeuver = getEphemeris(heo, mass, 5, new LofOffset(heo.getFrame(), LOFType.LVLH), t0, Vector3D.ZERO, f, isp, false, false, null); BoundedPropagator withManeuver = getEphemeris(heo, mass, 5, new LofOffset(heo.getFrame(), LOFType.LVLH), t0, dV, f, isp, false, false, null); // we set up a model that reverts the maneuvers AdapterPropagator adapterPropagator = new AdapterPropagator(withManeuver); AdapterPropagator.DifferentialEffect effect = new SmallManeuverAnalyticalModel( adapterPropagator.propagate(t0), dV.negate(), isp); adapterPropagator.addEffect(effect); adapterPropagator.addAdditionalStateProvider(new AdditionalStateProvider() { public String getName() { return "dummy 3"; }/*from w w w . j av a2 s. c om*/ public double[] getAdditionalState(SpacecraftState state) { return new double[3]; } }); // the adapted propagators do not manage the additional states from the reference, // they simply forward them Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 1")); Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 2")); Assert.assertTrue(adapterPropagator.isAdditionalStateManaged("dummy 3")); for (AbsoluteDate t = t0.shiftedBy(0.5 * dt); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t .shiftedBy(300.0)) { PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, heo.getFrame()); PVCoordinates pvReverted = adapterPropagator.getPVCoordinates(t, heo.getFrame()); double revertError = new PVCoordinates(pvWithout, pvReverted).getPosition().getNorm(); Assert.assertEquals(0, revertError, 180.0); Assert.assertEquals(2, adapterPropagator.propagate(t).getAdditionalState("dummy 1").length); Assert.assertEquals(1, adapterPropagator.propagate(t).getAdditionalState("dummy 2").length); Assert.assertEquals(3, adapterPropagator.propagate(t).getAdditionalState("dummy 3").length); } }
From source file:org.orekit.propagation.analytical.AdapterPropagatorTest.java
@Test public void testNonKeplerian() throws OrekitException, ParseException, IOException { Orbit leo = new CircularOrbit(7204319.233600575, 4.434564637450575E-4, 0.0011736728299091088, 1.7211611441767323, 5.5552084166959474, 24950.321259193086, PositionAngle.TRUE, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2003, 9, 16), new TimeComponents(23, 11, 20.264), TimeScalesFactory.getUTC()), Constants.EIGEN5C_EARTH_MU); double mass = 4093.0; AbsoluteDate t0 = new AbsoluteDate(new DateComponents(2003, 9, 16), new TimeComponents(23, 14, 40.264), TimeScalesFactory.getUTC()); Vector3D dV = new Vector3D(0.0, 3.0, 0.0); double f = 40.0; double isp = 300.0; double vExhaust = Constants.G0_STANDARD_GRAVITY * isp; double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust); // setup a specific coefficient file for gravity potential as it will also // try to read a corrupted one otherwise GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false)); NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getNormalizedProvider(8, 8); BoundedPropagator withoutManeuver = getEphemeris(leo, mass, 10, new LofOffset(leo.getFrame(), LOFType.VNC), t0, Vector3D.ZERO, f, isp, true, true, gravityField); BoundedPropagator withManeuver = getEphemeris(leo, mass, 10, new LofOffset(leo.getFrame(), LOFType.VNC), t0, dV, f, isp, true, true, gravityField); // we set up a model that reverts the maneuvers AdapterPropagator adapterPropagator = new AdapterPropagator(withManeuver); SpacecraftState state0 = adapterPropagator.propagate(t0); AdapterPropagator.DifferentialEffect directEffect = new SmallManeuverAnalyticalModel(state0, dV.negate(), isp);/*from w ww . j a v a 2 s.c o m*/ AdapterPropagator.DifferentialEffect derivedEffect = new J2DifferentialEffect(state0, directEffect, false, GravityFieldFactory.getUnnormalizedProvider(gravityField)); adapterPropagator.addEffect(directEffect); adapterPropagator.addEffect(derivedEffect); adapterPropagator.addAdditionalStateProvider(new AdditionalStateProvider() { public String getName() { return "dummy 3"; } public double[] getAdditionalState(SpacecraftState state) { return new double[3]; } }); // the adapted propagators do not manage the additional states from the reference, // they simply forward them Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 1")); Assert.assertFalse(adapterPropagator.isAdditionalStateManaged("dummy 2")); Assert.assertTrue(adapterPropagator.isAdditionalStateManaged("dummy 3")); double maxDelta = 0; double maxNominal = 0; for (AbsoluteDate t = t0.shiftedBy(0.5 * dt); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t .shiftedBy(600.0)) { PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, leo.getFrame()); PVCoordinates pvWith = withManeuver.getPVCoordinates(t, leo.getFrame()); PVCoordinates pvReverted = adapterPropagator.getPVCoordinates(t, leo.getFrame()); double nominal = new PVCoordinates(pvWithout, pvWith).getPosition().getNorm(); double revertError = new PVCoordinates(pvWithout, pvReverted).getPosition().getNorm(); maxDelta = FastMath.max(maxDelta, revertError); maxNominal = FastMath.max(maxNominal, nominal); Assert.assertEquals(2, adapterPropagator.propagate(t).getAdditionalState("dummy 1").length); Assert.assertEquals(1, adapterPropagator.propagate(t).getAdditionalState("dummy 2").length); Assert.assertEquals(3, adapterPropagator.propagate(t).getAdditionalState("dummy 3").length); } Assert.assertTrue(maxDelta < 120); Assert.assertTrue(maxNominal > 2800); }
From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagator.java
/** Convert circular parameters <em>with derivatives</em> to Cartesian coordinates. * @param date date of the orbital parameters * @param parameters circular parameters (a, ex, ey, i, raan, alphaM) * @return Cartesian coordinates consistent with values and derivatives *//*from w ww .j a va 2s .c o m*/ private TimeStampedPVCoordinates toCartesian(final AbsoluteDate date, final DerivativeStructure[] parameters) { // evaluate coordinates in the orbit canonical reference frame final DerivativeStructure cosOmega = parameters[4].cos(); final DerivativeStructure sinOmega = parameters[4].sin(); final DerivativeStructure cosI = parameters[3].cos(); final DerivativeStructure sinI = parameters[3].sin(); final DerivativeStructure alphaE = meanToEccentric(parameters[5], parameters[1], parameters[2]); final DerivativeStructure cosAE = alphaE.cos(); final DerivativeStructure sinAE = alphaE.sin(); final DerivativeStructure ex2 = parameters[1].multiply(parameters[1]); final DerivativeStructure ey2 = parameters[2].multiply(parameters[2]); final DerivativeStructure exy = parameters[1].multiply(parameters[2]); final DerivativeStructure q = ex2.add(ey2).subtract(1).negate().sqrt(); final DerivativeStructure beta = q.add(1).reciprocal(); final DerivativeStructure bx2 = beta.multiply(ex2); final DerivativeStructure by2 = beta.multiply(ey2); final DerivativeStructure bxy = beta.multiply(exy); final DerivativeStructure u = bxy.multiply(sinAE) .subtract(parameters[1].add(by2.subtract(1).multiply(cosAE))); final DerivativeStructure v = bxy.multiply(cosAE) .subtract(parameters[2].add(bx2.subtract(1).multiply(sinAE))); final DerivativeStructure x = parameters[0].multiply(u); final DerivativeStructure y = parameters[0].multiply(v); // canonical orbit reference frame final FieldVector3D<DerivativeStructure> p = new FieldVector3D<DerivativeStructure>( x.multiply(cosOmega).subtract(y.multiply(cosI.multiply(sinOmega))), x.multiply(sinOmega).add(y.multiply(cosI.multiply(cosOmega))), y.multiply(sinI)); // dispatch derivatives final Vector3D p0 = new Vector3D(p.getX().getValue(), p.getY().getValue(), p.getZ().getValue()); final Vector3D p1 = new Vector3D(p.getX().getPartialDerivative(1), p.getY().getPartialDerivative(1), p.getZ().getPartialDerivative(1)); final Vector3D p2 = new Vector3D(p.getX().getPartialDerivative(2), p.getY().getPartialDerivative(2), p.getZ().getPartialDerivative(2)); return new TimeStampedPVCoordinates(date, p0, p1, p2); }
From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagatorTest.java
@Test public void sameDateCartesian() throws OrekitException { // Definition of initial conditions with position and velocity // ------------------------------------------------------------ // with e around e = 1.4e-4 and i = 1.7 rad Vector3D position = new Vector3D(3220103., 69623., 6449822.); Vector3D velocity = new Vector3D(6414.7, -2006., -3180.); AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.); Orbit initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, provider.getMu()); // Extrapolator definition // ----------------------- EcksteinHechlerPropagator extrapolator = new EcksteinHechlerPropagator(initialOrbit, provider); // Extrapolation at the initial date // --------------------------------- SpacecraftState finalOrbit = extrapolator.propagate(initDate); // positions match perfectly Assert.assertEquals(0.0, Vector3D.distance(initialOrbit.getPVCoordinates().getPosition(), finalOrbit.getPVCoordinates().getPosition()), 1.0e-8); // velocity and circular parameters do *not* match, this is EXPECTED! // the reason is that we ensure position/velocity are consistent with the // evolution of the orbit, and this includes the non-Keplerian effects, // whereas the initial orbit is Keplerian only. The implementation of the // model is such that rather than having a perfect match at initial point // (either in velocity or in circular parameters), we have a propagated orbit // that remains close to a numerical reference throughout the orbit. // This is shown in the testInitializationCorrectness() where a numerical // fit is used to check initialization Assert.assertEquals(0.137, Vector3D.distance(initialOrbit.getPVCoordinates().getVelocity(), finalOrbit.getPVCoordinates().getVelocity()), 1.0e-3); Assert.assertEquals(125.2, finalOrbit.getA() - initialOrbit.getA(), 0.1); }
From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagatorTest.java
@Test public void almostSphericalBody() throws OrekitException { // Definition of initial conditions // --------------------------------- // with e around e = 1.4e-4 and i = 1.7 rad Vector3D position = new Vector3D(3220103., 69623., 6449822.); Vector3D velocity = new Vector3D(6414.7, -2006., -3180.); AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.); Orbit initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, provider.getMu()); // Initialisation to simulate a keplerian extrapolation // To be noticed: in order to simulate a keplerian extrapolation with the // analytical // extrapolator, one should put the zonal coefficients to 0. But due to // numerical pbs // one must put a non 0 value. UnnormalizedSphericalHarmonicsProvider kepProvider = GravityFieldFactory.getUnnormalizedProvider(6.378137e6, 3.9860047e14, TideSystem.UNKNOWN, new double[][] { { 0 }, { 0 }, { 0.1e-10 }, { 0.1e-13 }, { 0.1e-13 }, { 0.1e-14 }, { 0.1e-14 } }, new double[][] { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } }); // Extrapolators definitions // ------------------------- EcksteinHechlerPropagator extrapolatorAna = new EcksteinHechlerPropagator(initialOrbit, kepProvider); KeplerianPropagator extrapolatorKep = new KeplerianPropagator(initialOrbit); // Extrapolation at a final date different from initial date // --------------------------------------------------------- double delta_t = 100.0; // extrapolation duration in seconds AbsoluteDate extrapDate = initDate.shiftedBy(delta_t); SpacecraftState finalOrbitAna = extrapolatorAna.propagate(extrapDate); SpacecraftState finalOrbitKep = extrapolatorKep.propagate(extrapDate); Assert.assertEquals(finalOrbitAna.getDate().durationFrom(extrapDate), 0.0, Utils.epsilonTest); // comparison of each orbital parameters Assert.assertEquals(finalOrbitAna.getA(), finalOrbitKep.getA(), 10 * Utils.epsilonTest * finalOrbitKep.getA()); Assert.assertEquals(finalOrbitAna.getEquinoctialEx(), finalOrbitKep.getEquinoctialEx(), Utils.epsilonE * finalOrbitKep.getE()); Assert.assertEquals(finalOrbitAna.getEquinoctialEy(), finalOrbitKep.getEquinoctialEy(), Utils.epsilonE * finalOrbitKep.getE()); Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getHx(), finalOrbitKep.getHx()), finalOrbitKep.getHx(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getI())); Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getHy(), finalOrbitKep.getHy()), finalOrbitKep.getHy(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getI())); Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getLv(), finalOrbitKep.getLv()), finalOrbitKep.getLv(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getLv())); Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getLE(), finalOrbitKep.getLE()), finalOrbitKep.getLE(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getLE())); Assert.assertEquals(MathUtils.normalizeAngle(finalOrbitAna.getLM(), finalOrbitKep.getLM()), finalOrbitKep.getLM(), Utils.epsilonAngle * FastMath.abs(finalOrbitKep.getLM())); }
From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagatorTest.java
@Test public void propagatedCartesian() throws OrekitException { // Definition of initial conditions with position and velocity // ------------------------------------------------------------ // with e around e = 1.4e-4 and i = 1.7 rad Vector3D position = new Vector3D(3220103., 69623., 6449822.); Vector3D velocity = new Vector3D(6414.7, -2006., -3180.); AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.); Orbit initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, provider.getMu()); // Extrapolator definition // ----------------------- EcksteinHechlerPropagator extrapolator = new EcksteinHechlerPropagator(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC, RotationOrder.XYZ, 0, 0, 0), provider); // Extrapolation at a final date different from initial date // --------------------------------------------------------- double delta_t = 100000.0; // extrapolation duration in seconds AbsoluteDate extrapDate = initDate.shiftedBy(delta_t); SpacecraftState finalOrbit = extrapolator.propagate(extrapDate); Assert.assertEquals(0.0, finalOrbit.getDate().durationFrom(extrapDate), 1.0e-9); // computation of M final orbit double LM = finalOrbit.getLE() - finalOrbit.getEquinoctialEx() * FastMath.sin(finalOrbit.getLE()) + finalOrbit.getEquinoctialEy() * FastMath.cos(finalOrbit.getLE()); Assert.assertEquals(LM, finalOrbit.getLM(), Utils.epsilonAngle * FastMath.abs(finalOrbit.getLM())); // test of tan ((LE - Lv)/2) : Assert.assertEquals(FastMath.tan((finalOrbit.getLE() - finalOrbit.getLv()) / 2.), tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()), Utils.epsilonAngle);//from ww w . j a v a 2s .co m // test of evolution of M vs E: LM = LE - ex*sin(LE) + ey*cos(LE) double deltaM = finalOrbit.getLM() - initialOrbit.getLM(); double deltaE = finalOrbit.getLE() - initialOrbit.getLE(); double delta = finalOrbit.getEquinoctialEx() * FastMath.sin(finalOrbit.getLE()) - initialOrbit.getEquinoctialEx() * FastMath.sin(initialOrbit.getLE()) - finalOrbit.getEquinoctialEy() * FastMath.cos(finalOrbit.getLE()) + initialOrbit.getEquinoctialEy() * FastMath.cos(initialOrbit.getLE()); Assert.assertEquals(deltaM, deltaE - delta, Utils.epsilonAngle * FastMath.abs(deltaE - delta)); // for final orbit double ex = finalOrbit.getEquinoctialEx(); double ey = finalOrbit.getEquinoctialEy(); double hx = finalOrbit.getHx(); double hy = finalOrbit.getHy(); double LE = finalOrbit.getLE(); double ex2 = ex * ex; double ey2 = ey * ey; double hx2 = hx * hx; double hy2 = hy * hy; double h2p1 = 1. + hx2 + hy2; double beta = 1. / (1. + FastMath.sqrt(1. - ex2 - ey2)); double x3 = -ex + (1. - beta * ey2) * FastMath.cos(LE) + beta * ex * ey * FastMath.sin(LE); double y3 = -ey + (1. - beta * ex2) * FastMath.sin(LE) + beta * ex * ey * FastMath.cos(LE); Vector3D U = new Vector3D((1. + hx2 - hy2) / h2p1, (2. * hx * hy) / h2p1, (-2. * hy) / h2p1); Vector3D V = new Vector3D((2. * hx * hy) / h2p1, (1. - hx2 + hy2) / h2p1, (2. * hx) / h2p1); Vector3D r = new Vector3D(finalOrbit.getA(), (new Vector3D(x3, U, y3, V))); Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm(), r.getNorm(), Utils.epsilonTest * r.getNorm()); }
From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagatorTest.java
@Test public void propagatedKeplerian() throws OrekitException { // Definition of initial conditions with keplerian parameters // ----------------------------------------------------------- AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.); Orbit initialOrbit = new KeplerianOrbit(7209668.0, 0.5e-4, 1.7, 2.1, 2.9, 6.2, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, provider.getMu()); // Extrapolator definition // ----------------------- EcksteinHechlerPropagator extrapolator = new EcksteinHechlerPropagator(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC, RotationOrder.XYZ, 0, 0, 0), 2000.0, provider); // Extrapolation at a final date different from initial date // --------------------------------------------------------- double delta_t = 100000.0; // extrapolation duration in seconds AbsoluteDate extrapDate = initDate.shiftedBy(delta_t); SpacecraftState finalOrbit = extrapolator.propagate(extrapDate); Assert.assertEquals(0.0, finalOrbit.getDate().durationFrom(extrapDate), 1.0e-9); // computation of M final orbit double LM = finalOrbit.getLE() - finalOrbit.getEquinoctialEx() * FastMath.sin(finalOrbit.getLE()) + finalOrbit.getEquinoctialEy() * FastMath.cos(finalOrbit.getLE()); Assert.assertEquals(LM, finalOrbit.getLM(), Utils.epsilonAngle); // test of tan((LE - Lv)/2) : Assert.assertEquals(FastMath.tan((finalOrbit.getLE() - finalOrbit.getLv()) / 2.), tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()), Utils.epsilonAngle);//w w w.j a v a 2 s . c o m // test of evolution of M vs E: LM = LE - ex*sin(LE) + ey*cos(LE) // with ex and ey the same for initial and final orbit double deltaM = finalOrbit.getLM() - initialOrbit.getLM(); double deltaE = finalOrbit.getLE() - initialOrbit.getLE(); double delta = finalOrbit.getEquinoctialEx() * FastMath.sin(finalOrbit.getLE()) - initialOrbit.getEquinoctialEx() * FastMath.sin(initialOrbit.getLE()) - finalOrbit.getEquinoctialEy() * FastMath.cos(finalOrbit.getLE()) + initialOrbit.getEquinoctialEy() * FastMath.cos(initialOrbit.getLE()); Assert.assertEquals(deltaM, deltaE - delta, Utils.epsilonAngle * FastMath.abs(deltaE - delta)); // for final orbit double ex = finalOrbit.getEquinoctialEx(); double ey = finalOrbit.getEquinoctialEy(); double hx = finalOrbit.getHx(); double hy = finalOrbit.getHy(); double LE = finalOrbit.getLE(); double ex2 = ex * ex; double ey2 = ey * ey; double hx2 = hx * hx; double hy2 = hy * hy; double h2p1 = 1. + hx2 + hy2; double beta = 1. / (1. + FastMath.sqrt(1. - ex2 - ey2)); double x3 = -ex + (1. - beta * ey2) * FastMath.cos(LE) + beta * ex * ey * FastMath.sin(LE); double y3 = -ey + (1. - beta * ex2) * FastMath.sin(LE) + beta * ex * ey * FastMath.cos(LE); Vector3D U = new Vector3D((1. + hx2 - hy2) / h2p1, (2. * hx * hy) / h2p1, (-2. * hy) / h2p1); Vector3D V = new Vector3D((2. * hx * hy) / h2p1, (1. - hx2 + hy2) / h2p1, (2. * hx) / h2p1); Vector3D r = new Vector3D(finalOrbit.getA(), (new Vector3D(x3, U, y3, V))); Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm(), r.getNorm(), Utils.epsilonTest * r.getNorm()); }