Search in sources :

Example 11 with PolynomialFunction

use of org.hipparchus.analysis.polynomials.PolynomialFunction in project Orekit by CS-SI.

the class TLESeriesTest method testPVStart.

@Test
public void testPVStart() throws IOException, OrekitException {
    TLESeries series = new TLESeries("^spot-5\\.tle$", false);
    series.loadTLEData();
    AbsoluteDate t0 = new AbsoluteDate(2002, 5, 4, 11, 0, 0.0, TimeScalesFactory.getUTC());
    // this model is a rough fit on first 3 days of current tle with respect to first tle
    // there are 1500m amplitude variations around a quadratic evolution that grows up to 90km
    PolynomialFunction errorModel = new PolynomialFunction(new double[] { -135.98, 0.010186, 1.3115e-06 });
    Propagator propagator = TLEPropagator.selectExtrapolator(series.getFirst());
    for (double dt = 0; dt < 3 * Constants.JULIAN_DAY; dt += 600) {
        AbsoluteDate date = t0.shiftedBy(dt);
        PVCoordinates delta = new PVCoordinates(propagator.getPVCoordinates(date, FramesFactory.getTEME()), series.getPVCoordinates(date));
        Assert.assertEquals(errorModel.value(dt), delta.getPosition().getNorm(), 1500.0);
    }
}
Also used : Propagator(org.orekit.propagation.Propagator) PVCoordinates(org.orekit.utils.PVCoordinates) PolynomialFunction(org.hipparchus.analysis.polynomials.PolynomialFunction) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 12 with PolynomialFunction

use of org.hipparchus.analysis.polynomials.PolynomialFunction in project Orekit by CS-SI.

the class TopocentricFrameTest method testVisibilityCircle.

@Test
public void testVisibilityCircle() throws OrekitException, IOException {
    // a few random from International Laser Ranging Service
    final BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final TopocentricFrame[] ilrs = { new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(52.3800), FastMath.toRadians(3.0649), 133.745), "Potsdam"), new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(36.46273), FastMath.toRadians(-6.20619), 64.0), "San Fernando"), new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(35.5331), FastMath.toRadians(24.0705), 157.0), "Chania") };
    PolynomialFunction distanceModel = new PolynomialFunction(new double[] { 7.0892e+05, 3.1913, -8.2181e-07, 1.4033e-13 });
    for (TopocentricFrame station : ilrs) {
        for (double altitude = 500000; altitude < 2000000; altitude += 100000) {
            for (double azimuth = 0; azimuth < 2 * FastMath.PI; azimuth += 0.05) {
                GeodeticPoint p = station.computeLimitVisibilityPoint(Constants.WGS84_EARTH_EQUATORIAL_RADIUS + altitude, azimuth, FastMath.toRadians(5.0));
                double d = station.getRange(earth.transform(p), earth.getBodyFrame(), AbsoluteDate.J2000_EPOCH);
                Assert.assertEquals(distanceModel.value(altitude), d, 40000.0);
            }
        }
    }
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) PolynomialFunction(org.hipparchus.analysis.polynomials.PolynomialFunction) GeodeticPoint(org.orekit.bodies.GeodeticPoint) BodyShape(org.orekit.bodies.BodyShape) Test(org.junit.Test)

Example 13 with PolynomialFunction

use of org.hipparchus.analysis.polynomials.PolynomialFunction in project Orekit by CS-SI.

the class TimeStampedPVCoordinatesTest method testInterpolatePolynomialPositionOnly.

@Test
public void testInterpolatePolynomialPositionOnly() {
    Random random = new Random(0x88740a12e4299003l);
    AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH;
    for (int i = 0; i < 20; ++i) {
        PolynomialFunction px = randomPolynomial(5, random);
        PolynomialFunction py = randomPolynomial(5, random);
        PolynomialFunction pz = randomPolynomial(5, random);
        PolynomialFunction pxDot = px.polynomialDerivative();
        PolynomialFunction pyDot = py.polynomialDerivative();
        PolynomialFunction pzDot = pz.polynomialDerivative();
        PolynomialFunction pxDotDot = pxDot.polynomialDerivative();
        PolynomialFunction pyDotDot = pyDot.polynomialDerivative();
        PolynomialFunction pzDotDot = pzDot.polynomialDerivative();
        List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
        for (double dt : new double[] { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }) {
            Vector3D position = new Vector3D(px.value(dt), py.value(dt), pz.value(dt));
            sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, Vector3D.ZERO, Vector3D.ZERO));
        }
        for (double dt = 0; dt < 1.0; dt += 0.01) {
            TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt), CartesianDerivativesFilter.USE_P, sample);
            Vector3D p = interpolated.getPosition();
            Vector3D v = interpolated.getVelocity();
            Vector3D a = interpolated.getAcceleration();
            Assert.assertEquals(px.value(dt), p.getX(), 5.0e-16 * p.getNorm());
            Assert.assertEquals(py.value(dt), p.getY(), 5.0e-16 * p.getNorm());
            Assert.assertEquals(pz.value(dt), p.getZ(), 5.0e-16 * p.getNorm());
            Assert.assertEquals(pxDot.value(dt), v.getX(), 7.0e-15 * v.getNorm());
            Assert.assertEquals(pyDot.value(dt), v.getY(), 7.0e-15 * v.getNorm());
            Assert.assertEquals(pzDot.value(dt), v.getZ(), 7.0e-15 * v.getNorm());
            Assert.assertEquals(pxDotDot.value(dt), a.getX(), 2.0e-13 * a.getNorm());
            Assert.assertEquals(pyDotDot.value(dt), a.getY(), 2.0e-13 * a.getNorm());
            Assert.assertEquals(pzDotDot.value(dt), a.getZ(), 2.0e-13 * a.getNorm());
        }
    }
}
Also used : Random(java.util.Random) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) ArrayList(java.util.ArrayList) PolynomialFunction(org.hipparchus.analysis.polynomials.PolynomialFunction) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 14 with PolynomialFunction

use of org.hipparchus.analysis.polynomials.PolynomialFunction in project Orekit by CS-SI.

the class TimeStampedFieldPVCoordinatesTest method testInterpolatePolynomialPV.

@Test
public void testInterpolatePolynomialPV() {
    Random random = new Random(0xae7771c9933407bdl);
    AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH;
    for (int i = 0; i < 20; ++i) {
        PolynomialFunction px = randomPolynomial(5, random);
        PolynomialFunction py = randomPolynomial(5, random);
        PolynomialFunction pz = randomPolynomial(5, random);
        PolynomialFunction pxDot = px.polynomialDerivative();
        PolynomialFunction pyDot = py.polynomialDerivative();
        PolynomialFunction pzDot = pz.polynomialDerivative();
        PolynomialFunction pxDotDot = pxDot.polynomialDerivative();
        PolynomialFunction pyDotDot = pyDot.polynomialDerivative();
        PolynomialFunction pzDotDot = pzDot.polynomialDerivative();
        List<TimeStampedFieldPVCoordinates<DerivativeStructure>> sample = new ArrayList<TimeStampedFieldPVCoordinates<DerivativeStructure>>();
        for (double dt : new double[] { 0.0, 0.5, 1.0 }) {
            FieldVector3D<DerivativeStructure> position = createVector(px.value(dt), py.value(dt), pz.value(dt), 4);
            FieldVector3D<DerivativeStructure> velocity = createVector(pxDot.value(dt), pyDot.value(dt), pzDot.value(dt), 4);
            sample.add(new TimeStampedFieldPVCoordinates<>(t0.shiftedBy(dt), position, velocity, createVector(0, 0, 0, 4)));
        }
        Field<DerivativeStructure> field = sample.get(0).getDate().getField();
        for (double dt = 0; dt < 1.0; dt += 0.01) {
            FieldAbsoluteDate<DerivativeStructure> t = new FieldAbsoluteDate<>(field, t0.shiftedBy(dt));
            TimeStampedFieldPVCoordinates<DerivativeStructure> interpolated = TimeStampedFieldPVCoordinates.interpolate(t, CartesianDerivativesFilter.USE_PV, sample);
            FieldVector3D<DerivativeStructure> p = interpolated.getPosition();
            FieldVector3D<DerivativeStructure> v = interpolated.getVelocity();
            FieldVector3D<DerivativeStructure> a = interpolated.getAcceleration();
            Assert.assertEquals(px.value(dt), p.getX().getReal(), 4.0e-16 * p.getNorm().getReal());
            Assert.assertEquals(py.value(dt), p.getY().getReal(), 4.0e-16 * p.getNorm().getReal());
            Assert.assertEquals(pz.value(dt), p.getZ().getReal(), 4.0e-16 * p.getNorm().getReal());
            Assert.assertEquals(pxDot.value(dt), v.getX().getReal(), 9.0e-16 * v.getNorm().getReal());
            Assert.assertEquals(pyDot.value(dt), v.getY().getReal(), 9.0e-16 * v.getNorm().getReal());
            Assert.assertEquals(pzDot.value(dt), v.getZ().getReal(), 9.0e-16 * v.getNorm().getReal());
            Assert.assertEquals(pxDotDot.value(dt), a.getX().getReal(), 1.0e-14 * a.getNorm().getReal());
            Assert.assertEquals(pyDotDot.value(dt), a.getY().getReal(), 1.0e-14 * a.getNorm().getReal());
            Assert.assertEquals(pzDotDot.value(dt), a.getZ().getReal(), 1.0e-14 * a.getNorm().getReal());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) PolynomialFunction(org.hipparchus.analysis.polynomials.PolynomialFunction) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Random(java.util.Random) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) Test(org.junit.Test)

Example 15 with PolynomialFunction

use of org.hipparchus.analysis.polynomials.PolynomialFunction in project Orekit by CS-SI.

the class TimeStampedFieldPVCoordinatesTest method testInterpolatePolynomialPositionOnly.

@Test
public void testInterpolatePolynomialPositionOnly() {
    Random random = new Random(0x88740a12e4299003l);
    AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH;
    for (int i = 0; i < 20; ++i) {
        PolynomialFunction px = randomPolynomial(5, random);
        PolynomialFunction py = randomPolynomial(5, random);
        PolynomialFunction pz = randomPolynomial(5, random);
        PolynomialFunction pxDot = px.polynomialDerivative();
        PolynomialFunction pyDot = py.polynomialDerivative();
        PolynomialFunction pzDot = pz.polynomialDerivative();
        PolynomialFunction pxDotDot = pxDot.polynomialDerivative();
        PolynomialFunction pyDotDot = pyDot.polynomialDerivative();
        PolynomialFunction pzDotDot = pzDot.polynomialDerivative();
        List<TimeStampedFieldPVCoordinates<DerivativeStructure>> sample = new ArrayList<TimeStampedFieldPVCoordinates<DerivativeStructure>>();
        for (double dt : new double[] { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }) {
            FieldVector3D<DerivativeStructure> position = createVector(px.value(dt), py.value(dt), pz.value(dt), 4);
            sample.add(new TimeStampedFieldPVCoordinates<>(t0.shiftedBy(dt), position, createVector(0, 0, 0, 4), createVector(0, 0, 0, 4)));
        }
        Field<DerivativeStructure> field = sample.get(0).getDate().getField();
        for (double dt = 0; dt < 1.0; dt += 0.01) {
            FieldAbsoluteDate<DerivativeStructure> t = new FieldAbsoluteDate<>(field, t0.shiftedBy(dt));
            TimeStampedFieldPVCoordinates<DerivativeStructure> interpolated = TimeStampedFieldPVCoordinates.interpolate(t, CartesianDerivativesFilter.USE_P, sample);
            FieldVector3D<DerivativeStructure> p = interpolated.getPosition();
            FieldVector3D<DerivativeStructure> v = interpolated.getVelocity();
            FieldVector3D<DerivativeStructure> a = interpolated.getAcceleration();
            Assert.assertEquals(px.value(dt), p.getX().getReal(), 5.0e-16 * p.getNorm().getReal());
            Assert.assertEquals(py.value(dt), p.getY().getReal(), 5.0e-16 * p.getNorm().getReal());
            Assert.assertEquals(pz.value(dt), p.getZ().getReal(), 5.0e-16 * p.getNorm().getReal());
            Assert.assertEquals(pxDot.value(dt), v.getX().getReal(), 7.0e-15 * v.getNorm().getReal());
            Assert.assertEquals(pyDot.value(dt), v.getY().getReal(), 7.0e-15 * v.getNorm().getReal());
            Assert.assertEquals(pzDot.value(dt), v.getZ().getReal(), 7.0e-15 * v.getNorm().getReal());
            Assert.assertEquals(pxDotDot.value(dt), a.getX().getReal(), 2.0e-13 * a.getNorm().getReal());
            Assert.assertEquals(pyDotDot.value(dt), a.getY().getReal(), 2.0e-13 * a.getNorm().getReal());
            Assert.assertEquals(pzDotDot.value(dt), a.getZ().getReal(), 2.0e-13 * a.getNorm().getReal());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) PolynomialFunction(org.hipparchus.analysis.polynomials.PolynomialFunction) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Random(java.util.Random) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) Test(org.junit.Test)

Aggregations

PolynomialFunction (org.hipparchus.analysis.polynomials.PolynomialFunction)16 Test (org.junit.Test)9 AbsoluteDate (org.orekit.time.AbsoluteDate)8 ArrayList (java.util.ArrayList)6 Random (java.util.Random)6 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)4 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)4 FieldDerivativeStructure (org.hipparchus.analysis.differentiation.FieldDerivativeStructure)3 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)3 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)3 PVCoordinates (org.orekit.utils.PVCoordinates)2 BodyCenterPointing (org.orekit.attitudes.BodyCenterPointing)1 BodyShape (org.orekit.bodies.BodyShape)1 GeodeticPoint (org.orekit.bodies.GeodeticPoint)1 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)1 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)1 Propagator (org.orekit.propagation.Propagator)1 FieldEcksteinHechlerPropagator (org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator)1 NSKey (org.orekit.propagation.semianalytical.dsst.utilities.CoefficientsFactory.NSKey)1 DateComponents (org.orekit.time.DateComponents)1