use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldEcksteinHechlerPropagatorTest method doPropagatedKeplerian.
private <T extends RealFieldElement<T>> void doPropagatedKeplerian(Field<T> field) throws OrekitException {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
// Definition of initial conditions with Keplerian parameters
// -----------------------------------------------------------
FieldAbsoluteDate<T> initDate = date.shiftedBy(584.);
FieldOrbit<T> initialOrbit = new FieldKeplerianOrbit<>(zero.add(7209668.0), zero.add(0.5e-4), zero.add(1.7), zero.add(2.1), zero.add(2.9), zero.add(6.2), PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, provider.getMu());
// Extrapolator definition
// -----------------------
FieldEcksteinHechlerPropagator<T> extrapolator = new FieldEcksteinHechlerPropagator<>(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC), zero.add(2000.0), provider);
// Extrapolation at a final date different from initial date
// ---------------------------------------------------------
// extrapolation duration in seconds
double delta_t = 100000.0;
FieldAbsoluteDate<T> extrapDate = initDate.shiftedBy(delta_t);
FieldSpacecraftState<T> finalOrbit = extrapolator.propagate(extrapDate);
Assert.assertEquals(0.0, finalOrbit.getDate().durationFrom(extrapDate).getReal(), 1.0e-9);
// computation of M final orbit
T LM = finalOrbit.getLE().subtract(finalOrbit.getEquinoctialEx().multiply(finalOrbit.getLE().sin())).add(finalOrbit.getEquinoctialEy().multiply(finalOrbit.getLE().cos()));
Assert.assertEquals(LM.getReal(), finalOrbit.getLM().getReal(), Utils.epsilonAngle);
// test of tan((LE - Lv)/2) :
Assert.assertEquals(FastMath.tan((finalOrbit.getLE().getReal() - finalOrbit.getLv().getReal()) / 2.), tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()).getReal(), Utils.epsilonAngle);
// 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
T deltaM = finalOrbit.getLM().subtract(initialOrbit.getLM());
T deltaE = finalOrbit.getLE().subtract(initialOrbit.getLE());
T delta = finalOrbit.getEquinoctialEx().multiply(finalOrbit.getLE().sin()).subtract(initialOrbit.getEquinoctialEx().multiply(initialOrbit.getLE().sin())).subtract(finalOrbit.getEquinoctialEy().multiply(finalOrbit.getLE().cos())).add(initialOrbit.getEquinoctialEy().multiply(initialOrbit.getLE().cos()));
Assert.assertEquals(deltaM.getReal(), deltaE.getReal() - delta.getReal(), Utils.epsilonAngle * FastMath.abs(deltaE.getReal() - delta.getReal()));
// for final orbit
T ex = finalOrbit.getEquinoctialEx();
T ey = finalOrbit.getEquinoctialEy();
T hx = finalOrbit.getHx();
T hy = finalOrbit.getHy();
T LE = finalOrbit.getLE();
T ex2 = ex.multiply(ex);
T ey2 = ey.multiply(ey);
T hx2 = hx.multiply(hx);
T hy2 = hy.multiply(hy);
T h2p1 = hx2.add(1).add(hy2);
T beta = ex2.negate().add(1.).subtract(ey2).sqrt().add(1).reciprocal();
T x3 = ex.negate().add(beta.negate().multiply(ey2).add(1).multiply(LE.cos())).add(beta.multiply(ex).multiply(ey).multiply(LE.sin()));
T y3 = ey.negate().add(beta.negate().multiply(ex2).add(1).multiply(LE.sin())).add(beta.multiply(ex).multiply(ey).multiply(LE.cos()));
FieldVector3D<T> U = new FieldVector3D<>(hx2.subtract(hy2).add(1.).divide(h2p1), hx.multiply(2).multiply(hy).divide(h2p1), hy.multiply(-2.).divide(h2p1));
FieldVector3D<T> V = new FieldVector3D<>(hx.multiply(2.).multiply(hy).divide(h2p1), hy2.subtract(hx2).add(1.).divide(h2p1), hx.multiply(2).divide(h2p1));
FieldVector3D<T> r = new FieldVector3D<>(finalOrbit.getA(), new FieldVector3D<>(x3, U, y3, V));
Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm().getReal(), r.getNorm().getReal(), Utils.epsilonTest * r.getNorm().getReal());
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldEcksteinHechlerPropagatorTest method doPropagatedCartesian.
private <T extends RealFieldElement<T>> void doPropagatedCartesian(Field<T> field) throws OrekitException {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
// Definition of initial conditions with position and velocity
// ------------------------------------------------------------
// with e around e = 1.4e-4 and i = 1.7 rad
FieldVector3D<T> position = new FieldVector3D<>(zero.add(3220103.), zero.add(69623.), zero.add(6449822.));
FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(6414.7), zero.add(-2006.), zero.add(-3180.));
FieldAbsoluteDate<T> initDate = date.shiftedBy(584.);
FieldOrbit<T> initialOrbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), initDate, provider.getMu());
// Extrapolator definition
// -----------------------
FieldEcksteinHechlerPropagator<T> extrapolator = new FieldEcksteinHechlerPropagator<>(initialOrbit, new LofOffset(initialOrbit.getFrame(), LOFType.VNC, RotationOrder.XYZ, 0, 0, 0), provider);
// Extrapolation at a final date different from initial date
// ---------------------------------------------------------
// extrapolation duration in seconds
double delta_t = 100000.0;
FieldAbsoluteDate<T> extrapDate = initDate.shiftedBy(delta_t);
FieldSpacecraftState<T> finalOrbit = extrapolator.propagate(extrapDate);
Assert.assertEquals(0.0, finalOrbit.getDate().durationFrom(extrapDate).getReal(), 1.0e-9);
// computation of M final orbit
T LM = finalOrbit.getLE().subtract(finalOrbit.getEquinoctialEx().multiply(finalOrbit.getLE().sin())).add(finalOrbit.getEquinoctialEy().multiply(finalOrbit.getLE().cos()));
Assert.assertEquals(LM.getReal(), finalOrbit.getLM().getReal(), Utils.epsilonAngle * FastMath.abs(finalOrbit.getLM().getReal()));
// test of tan ((LE - Lv)/2) :
Assert.assertEquals(FastMath.tan((finalOrbit.getLE().getReal() - finalOrbit.getLv().getReal()) / 2.), tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()).getReal(), Utils.epsilonAngle);
// test of evolution of M vs E: LM = LE - ex*sin(LE) + ey*cos(LE)
T deltaM = finalOrbit.getLM().subtract(initialOrbit.getLM());
T deltaE = finalOrbit.getLE().subtract(initialOrbit.getLE());
T delta = finalOrbit.getEquinoctialEx().multiply(finalOrbit.getLE().sin()).subtract(initialOrbit.getEquinoctialEx().multiply(initialOrbit.getLE().sin())).subtract(finalOrbit.getEquinoctialEy().multiply(finalOrbit.getLE().cos())).add(initialOrbit.getEquinoctialEy().multiply(initialOrbit.getLE().cos()));
Assert.assertEquals(deltaM.getReal(), deltaE.getReal() - delta.getReal(), Utils.epsilonAngle * FastMath.abs(deltaE.getReal() - delta.getReal()));
// for final orbit
T ex = finalOrbit.getEquinoctialEx();
T ey = finalOrbit.getEquinoctialEy();
T hx = finalOrbit.getHx();
T hy = finalOrbit.getHy();
T LE = finalOrbit.getLE();
T ex2 = ex.multiply(ex);
T ey2 = ey.multiply(ey);
T hx2 = hx.multiply(hx);
T hy2 = hy.multiply(hy);
T h2p1 = hx2.add(1.).add(hy2);
T beta = ex2.negate().add(1.).subtract(ey2).sqrt().add(1.).reciprocal();
T x3 = ex.negate().add(ey2.multiply(beta).negate().add(1.).multiply(LE.cos())).add(beta.multiply(ex).multiply(ey).multiply(LE.sin()));
T y3 = ey.negate().add(ex2.negate().multiply(beta).add(1).multiply(LE.sin())).add(beta.multiply(ex).multiply(ey).multiply(LE.cos()));
FieldVector3D<T> U = new FieldVector3D<>(hx2.add(1).subtract(hy2).divide(h2p1), hx.multiply(hy).multiply(2).divide(h2p1), hy.multiply(-2).divide(h2p1));
FieldVector3D<T> V = new FieldVector3D<>(hx.multiply(2).multiply(hy).divide(h2p1), hy2.add(1).subtract(hx2).divide(h2p1), hx.multiply(2).divide(h2p1));
FieldVector3D<T> r = new FieldVector3D<>(finalOrbit.getA(), new FieldVector3D<>(x3, U, y3, V));
Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm().getReal(), r.getNorm().getReal(), Utils.epsilonTest * r.getNorm().getReal());
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldKeplerianPropagatorTest method doTestIssue107.
private <T extends RealFieldElement<T>> void doTestIssue107(Field<T> field) throws OrekitException {
T zero = field.getZero();
final TimeScale utc = TimeScalesFactory.getUTC();
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.848), zero.add(942.781), zero.add(7435.922));
final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
final FieldOrbit<T> orbit = new FieldCircularOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, mu);
FieldPropagator<T> propagator = new FieldKeplerianPropagator<T>(orbit) {
FieldAbsoluteDate<T> lastDate = FieldAbsoluteDate.getPastInfinity(field);
protected FieldSpacecraftState<T> basicPropagate(final FieldAbsoluteDate<T> date) throws OrekitException {
if (date.compareTo(lastDate) < 0) {
throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "no backward propagation allowed");
}
lastDate = date;
return super.basicPropagate(date);
}
};
FieldSpacecraftState<T> finalState = propagator.propagate(date.shiftedBy(3600.0));
Assert.assertEquals(3600.0, finalState.getDate().durationFrom(date).getReal(), 1.0e-15);
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldEventDetectorTest method doTestIssue108Numerical.
private <T extends RealFieldElement<T>> void doTestIssue108Numerical(Field<T> field) throws OrekitException {
final T zero = field.getZero();
final TimeScale utc = TimeScalesFactory.getUTC();
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.848), zero.add(942.781), zero.add(7435.922));
final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
final FieldOrbit<T> orbit = new FieldCircularOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, mu);
final T step = zero.add(60.0);
final int n = 100;
FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, new ClassicalRungeKuttaFieldIntegrator<>(field, step));
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.resetInitialState(new FieldSpacecraftState<>(orbit));
GCallsCounter<T> counter = new GCallsCounter<>(zero.add(100000.0), zero.add(1.0e-6), 20, new FieldStopOnEvent<GCallsCounter<T>, T>());
propagator.addEventDetector(counter);
propagator.propagate(date.shiftedBy(step.multiply(n)));
Assert.assertEquals(n + 1, counter.getCount());
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldEclipseDetectorTest method doTestInsideOcculted.
private <T extends RealFieldElement<T>> void doTestInsideOcculted(Field<T> field) throws OrekitException {
T zero = field.getZero();
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.560), zero.add(-25767.25680));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.8479685), zero.add(942.7809215), zero.add(7435.922231));
FieldAbsoluteDate<T> iniDate = new FieldAbsoluteDate<>(field, 1969, 7, 28, 4, 0, 0.0, TimeScalesFactory.getTT());
final FieldOrbit<T> orbit = new FieldEquinoctialOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getGCRF(), iniDate, mu);
FieldSpacecraftState<T> initialState = new FieldSpacecraftState<>(orbit);
double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
AdaptiveStepsizeFieldIntegrator<T> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 1000, absTolerance, relTolerance);
integrator.setInitialStepSize(field.getZero().add(60));
FieldNumericalPropagator<T> propagator = new FieldNumericalPropagator<>(field, integrator);
propagator.setOrbitType(OrbitType.EQUINOCTIAL);
propagator.setInitialState(initialState);
sun = CelestialBodyFactory.getSun();
earth = CelestialBodyFactory.getEarth();
sunRadius = 696000000.;
earthRadius = 6400000.;
FieldEclipseDetector<T> e = new FieldEclipseDetector<>(field.getZero().add(60.), field.getZero().add(1.e-3), sun, sunRadius, earth, earthRadius);
Vector3D p = sun.getPVCoordinates(AbsoluteDate.J2000_EPOCH, FramesFactory.getGCRF()).getPosition();
FieldSpacecraftState<T> s = new FieldSpacecraftState<>(new FieldCartesianOrbit<>(new TimeStampedFieldPVCoordinates<>(FieldAbsoluteDate.getJ2000Epoch(field), new FieldPVCoordinates<>(new FieldVector3D<>(field.getOne(), field.getZero(), field.getZero()).add(p), new FieldVector3D<>(field.getZero(), field.getZero(), field.getOne()))), FramesFactory.getGCRF(), mu));
Assert.assertEquals(FastMath.PI, e.g(s).getReal(), 1.0e-15);
}
Aggregations