Search in sources :

Example 16 with PolynomialFunction

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

the class TimeStampedFieldPVCoordinatesTest method testInterpolatePolynomialPVA.

@Test
public void testInterpolatePolynomialPVA() {
    Random random = new Random(0xfe3945fcb8bf47cel);
    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);
            FieldVector3D<DerivativeStructure> acceleration = createVector(pxDotDot.value(dt), pyDotDot.value(dt), pzDotDot.value(dt), 4);
            sample.add(new TimeStampedFieldPVCoordinates<>(t0.shiftedBy(dt), position, velocity, acceleration));
        }
        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_PVA, 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(), 6.0e-15 * a.getNorm().getReal());
            Assert.assertEquals(pyDotDot.value(dt), a.getY().getReal(), 6.0e-15 * a.getNorm().getReal());
            Assert.assertEquals(pzDotDot.value(dt), a.getZ().getReal(), 6.0e-15 * 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