Search in sources :

Example 6 with UnivariateDifferentiableFunction

use of org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction in project Orekit by CS-SI.

the class FieldCircularOrbitTest method differentiate.

private <T extends RealFieldElement<T>, S extends Function<FieldCircularOrbit<T>, T>> double differentiate(TimeStampedFieldPVCoordinates<T> pv, Frame frame, double mu, S picker) {
    final DSFactory factory = new DSFactory(1, 1);
    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(8, 0.1);
    UnivariateDifferentiableFunction diff = differentiator.differentiate(new UnivariateFunction() {

        public double value(double dt) {
            return picker.apply(new FieldCircularOrbit<>(pv.shiftedBy(dt), frame, mu)).getReal();
        }
    });
    return diff.value(factory.variable(0, 0.0)).getPartialDerivative(1);
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)

Example 7 with UnivariateDifferentiableFunction

use of org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction in project Orekit by CS-SI.

the class FieldEquinoctialOrbitTest method differentiate.

private <T extends RealFieldElement<T>, S extends Function<FieldEquinoctialOrbit<T>, T>> double differentiate(TimeStampedFieldPVCoordinates<T> pv, Frame frame, double mu, S picker) {
    final DSFactory factory = new DSFactory(1, 1);
    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(8, 0.1);
    UnivariateDifferentiableFunction diff = differentiator.differentiate(new UnivariateFunction() {

        public double value(double dt) {
            return picker.apply(new FieldEquinoctialOrbit<>(pv.shiftedBy(dt), frame, mu)).getReal();
        }
    });
    return diff.value(factory.variable(0, 0.0)).getPartialDerivative(1);
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)

Example 8 with UnivariateDifferentiableFunction

use of org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction in project Orekit by CS-SI.

the class FieldKeplerianOrbitTest method differentiate.

private <T extends RealFieldElement<T>, S extends Function<FieldKeplerianOrbit<T>, T>> double differentiate(TimeStampedFieldPVCoordinates<T> pv, Frame frame, double mu, S picker) {
    final DSFactory factory = new DSFactory(1, 1);
    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(8, 0.1);
    UnivariateDifferentiableFunction diff = differentiator.differentiate(new UnivariateFunction() {

        public double value(double dt) {
            return picker.apply(new FieldKeplerianOrbit<>(pv.shiftedBy(dt), frame, mu)).getReal();
        }
    });
    return diff.value(factory.variable(0, 0.0)).getPartialDerivative(1);
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)

Example 9 with UnivariateDifferentiableFunction

use of org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction in project Orekit by CS-SI.

the class KeplerianOrbitTest method differentiate.

private <S extends Function<KeplerianOrbit, Double>> double differentiate(KeplerianOrbit orbit, S picker) {
    final DSFactory factory = new DSFactory(1, 1);
    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(8, 0.1);
    UnivariateDifferentiableFunction diff = differentiator.differentiate(new UnivariateFunction() {

        public double value(double dt) {
            return picker.apply(orbit.shiftedBy(dt));
        }
    });
    return diff.value(factory.variable(0, 0.0)).getPartialDerivative(1);
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)

Example 10 with UnivariateDifferentiableFunction

use of org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction in project Orekit by CS-SI.

the class OneAxisEllipsoidTest method testMovingGeodeticPoint.

@Test
public void testMovingGeodeticPoint() throws OrekitException {
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    double lat0 = FastMath.toRadians(60.0);
    double lon0 = FastMath.toRadians(25.0);
    double alt0 = 100.0;
    double lat1 = 1.0e-3;
    double lon1 = -2.0e-3;
    double alt1 = 1.2;
    double lat2 = -1.0e-5;
    double lon2 = -3.0e-5;
    double alt2 = -0.01;
    final DSFactory factory = new DSFactory(1, 2);
    final DerivativeStructure latDS = factory.build(lat0, lat1, lat2);
    final DerivativeStructure lonDS = factory.build(lon0, lon1, lon2);
    final DerivativeStructure altDS = factory.build(alt0, alt1, alt2);
    // direct computation of position, velocity and acceleration
    PVCoordinates pv = new PVCoordinates(earth.transform(new FieldGeodeticPoint<>(latDS, lonDS, altDS)));
    // finite differences computation
    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(5, 0.1);
    UnivariateDifferentiableFunction fx = differentiator.differentiate(new UnivariateFunction() {

        public double value(double dt) {
            GeodeticPoint gp = new GeodeticPoint(latDS.taylor(dt), lonDS.taylor(dt), altDS.taylor(dt));
            return earth.transform(gp).getX();
        }
    });
    UnivariateDifferentiableFunction fy = differentiator.differentiate(new UnivariateFunction() {

        public double value(double dt) {
            GeodeticPoint gp = new GeodeticPoint(latDS.taylor(dt), lonDS.taylor(dt), altDS.taylor(dt));
            return earth.transform(gp).getY();
        }
    });
    UnivariateDifferentiableFunction fz = differentiator.differentiate(new UnivariateFunction() {

        public double value(double dt) {
            GeodeticPoint gp = new GeodeticPoint(latDS.taylor(dt), lonDS.taylor(dt), altDS.taylor(dt));
            return earth.transform(gp).getZ();
        }
    });
    DerivativeStructure dtZero = factory.variable(0, 0.0);
    DerivativeStructure xDS = fx.value(dtZero);
    DerivativeStructure yDS = fy.value(dtZero);
    DerivativeStructure zDS = fz.value(dtZero);
    Assert.assertEquals(xDS.getValue(), pv.getPosition().getX(), 2.0e-20 * FastMath.abs(xDS.getValue()));
    Assert.assertEquals(xDS.getPartialDerivative(1), pv.getVelocity().getX(), 2.0e-12 * FastMath.abs(xDS.getPartialDerivative(1)));
    Assert.assertEquals(xDS.getPartialDerivative(2), pv.getAcceleration().getX(), 2.0e-9 * FastMath.abs(xDS.getPartialDerivative(2)));
    Assert.assertEquals(yDS.getValue(), pv.getPosition().getY(), 2.0e-20 * FastMath.abs(yDS.getValue()));
    Assert.assertEquals(yDS.getPartialDerivative(1), pv.getVelocity().getY(), 2.0e-12 * FastMath.abs(yDS.getPartialDerivative(1)));
    Assert.assertEquals(yDS.getPartialDerivative(2), pv.getAcceleration().getY(), 2.0e-9 * FastMath.abs(yDS.getPartialDerivative(2)));
    Assert.assertEquals(zDS.getValue(), pv.getPosition().getZ(), 2.0e-20 * FastMath.abs(zDS.getValue()));
    Assert.assertEquals(zDS.getPartialDerivative(1), pv.getVelocity().getZ(), 2.0e-12 * FastMath.abs(zDS.getPartialDerivative(1)));
    Assert.assertEquals(zDS.getPartialDerivative(2), pv.getAcceleration().getZ(), 2.0e-9 * FastMath.abs(zDS.getPartialDerivative(2)));
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) Test(org.junit.Test)

Aggregations

UnivariateDifferentiableFunction (org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction)18 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)17 FiniteDifferencesDifferentiator (org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)16 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)15 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)7 Test (org.junit.Test)5 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)4 TimeScale (org.orekit.time.TimeScale)3 AbsoluteDate (org.orekit.time.AbsoluteDate)2 IERSConventions (org.orekit.utils.IERSConventions)2 UnivariateVectorFunction (org.hipparchus.analysis.UnivariateVectorFunction)1 UnivariateDifferentiableVectorFunction (org.hipparchus.analysis.differentiation.UnivariateDifferentiableVectorFunction)1 Decimal64 (org.hipparchus.util.Decimal64)1 OldIAUPole (org.orekit.bodies.IAUPoleFactory.OldIAUPole)1 OrekitException (org.orekit.errors.OrekitException)1 OrekitExceptionWrapper (org.orekit.errors.OrekitExceptionWrapper)1 PVCoordinates (org.orekit.utils.PVCoordinates)1 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)1