Search in sources :

Example 36 with DerivativeStructure

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

the class AlongTrackAiming method alongTileDirection.

/**
 * {@inheritDoc}
 */
@Override
public Vector3D alongTileDirection(final Vector3D point, final GeodeticPoint gp) throws OrekitException {
    final double lStart = halfTrack.get(0).getFirst().getLatitude();
    final double lEnd = halfTrack.get(halfTrack.size() - 1).getFirst().getLatitude();
    // check the point can be reached
    if (gp.getLatitude() < FastMath.min(lStart, lEnd) || gp.getLatitude() > FastMath.max(lStart, lEnd)) {
        throw new OrekitException(OrekitMessages.OUT_OF_RANGE_LATITUDE, FastMath.toDegrees(gp.getLatitude()), FastMath.toDegrees(FastMath.min(lStart, lEnd)), FastMath.toDegrees(FastMath.max(lStart, lEnd)));
    }
    // bracket the point in the half track sample
    int iInf = 0;
    int iSup = halfTrack.size() - 1;
    while (iSup - iInf > 1) {
        final int iMiddle = (iSup + iInf) / 2;
        if ((lStart < lEnd) ^ (halfTrack.get(iMiddle).getFirst().getLatitude() > gp.getLatitude())) {
            // the specified latitude is in the second half
            iInf = iMiddle;
        } else {
            // the specified latitude is in the first half
            iSup = iMiddle;
        }
    }
    // ensure we can get points at iStart, iStart + 1, iStart + 2 and iStart + 3
    final int iStart = FastMath.max(0, FastMath.min(iInf - 1, halfTrack.size() - 4));
    // interpolate ground sliding point at specified latitude
    final HermiteInterpolator interpolator = new HermiteInterpolator();
    for (int i = iStart; i < iStart + 4; ++i) {
        final Vector3D position = halfTrack.get(i).getSecond().getPosition();
        final Vector3D velocity = halfTrack.get(i).getSecond().getVelocity();
        interpolator.addSamplePoint(halfTrack.get(i).getFirst().getLatitude(), new double[] { position.getX(), position.getY(), position.getZ(), velocity.getX(), velocity.getY(), velocity.getZ() });
    }
    final DerivativeStructure[] p = interpolator.value(factory.variable(0, gp.getLatitude()));
    // extract interpolated ground position/velocity
    final Vector3D position = new Vector3D(p[0].getValue(), p[1].getValue(), p[2].getValue());
    final Vector3D velocity = new Vector3D(p[3].getValue(), p[4].getValue(), p[5].getValue());
    // adjust longitude to match the specified one
    final Rotation rotation = new Rotation(Vector3D.PLUS_K, position, Vector3D.PLUS_K, point);
    final Vector3D fixedVelocity = rotation.applyTo(velocity);
    // the tile direction is aligned with sliding point velocity
    return fixedVelocity.normalize();
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) OrekitException(org.orekit.errors.OrekitException) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) GeodeticPoint(org.orekit.bodies.GeodeticPoint) HermiteInterpolator(org.hipparchus.analysis.interpolation.HermiteInterpolator)

Example 37 with DerivativeStructure

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

the class CartesianOrbit method getHxDot.

/**
 * {@inheritDoc}
 */
public double getHxDot() {
    if (hasDerivatives()) {
        final FieldVector3D<DerivativeStructure> w = FieldVector3D.crossProduct(getPositionDS(), getVelocityDS()).normalize();
        // Check for equatorial retrograde orbit
        final double x = w.getX().getValue();
        final double y = w.getY().getValue();
        final double z = w.getZ().getValue();
        if (((x * x + y * y) == 0) && z < 0) {
            return Double.NaN;
        }
        final DerivativeStructure hx = w.getY().negate().divide(w.getZ().add(1));
        return hx.getPartialDerivative(1);
    } else {
        return Double.NaN;
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure)

Example 38 with DerivativeStructure

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

the class CartesianOrbit method getHyDot.

/**
 * {@inheritDoc}
 */
public double getHyDot() {
    if (hasDerivatives()) {
        final FieldVector3D<DerivativeStructure> w = FieldVector3D.crossProduct(getPositionDS(), getVelocityDS()).normalize();
        // Check for equatorial retrograde orbit
        final double x = w.getX().getValue();
        final double y = w.getY().getValue();
        final double z = w.getZ().getValue();
        if (((x * x + y * y) == 0) && z < 0) {
            return Double.NaN;
        }
        final DerivativeStructure hy = w.getX().divide(w.getZ().add(1));
        return hy.getPartialDerivative(1);
    } else {
        return Double.NaN;
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure)

Example 39 with DerivativeStructure

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

the class EquinoctialOrbit method getLEDot.

/**
 * {@inheritDoc}
 */
public double getLEDot() {
    final DerivativeStructure lVDS = FACTORY.build(lv, lvDot);
    final DerivativeStructure exDS = FACTORY.build(ex, exDot);
    final DerivativeStructure eyDS = FACTORY.build(ey, eyDot);
    final DerivativeStructure lEDS = FieldEquinoctialOrbit.trueToEccentric(lVDS, exDS, eyDS);
    return lEDS.getPartialDerivative(1);
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure)

Example 40 with DerivativeStructure

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

the class EcksteinHechlerPropagator method meanToEccentric.

/**
 * Computes the eccentric latitude argument from the mean latitude argument.
 * @param alphaM = M + Ω mean latitude argument (rad)
 * @param ex e cos(Ω), first component of circular eccentricity vector
 * @param ey e sin(Ω), second component of circular eccentricity vector
 * @return the eccentric latitude argument.
 */
private DerivativeStructure meanToEccentric(final DerivativeStructure alphaM, final DerivativeStructure ex, final DerivativeStructure ey) {
    // Generalization of Kepler equation to circular parameters
    // with alphaE = PA + E and
    // alphaM = PA + M = alphaE - ex.sin(alphaE) + ey.cos(alphaE)
    DerivativeStructure alphaE = alphaM;
    DerivativeStructure shift = alphaM.getField().getZero();
    DerivativeStructure alphaEMalphaM = alphaM.getField().getZero();
    DerivativeStructure cosAlphaE = alphaE.cos();
    DerivativeStructure sinAlphaE = alphaE.sin();
    int iter = 0;
    do {
        final DerivativeStructure f2 = ex.multiply(sinAlphaE).subtract(ey.multiply(cosAlphaE));
        final DerivativeStructure f1 = alphaM.getField().getOne().subtract(ex.multiply(cosAlphaE)).subtract(ey.multiply(sinAlphaE));
        final DerivativeStructure f0 = alphaEMalphaM.subtract(f2);
        final DerivativeStructure f12 = f1.multiply(2);
        shift = f0.multiply(f12).divide(f1.multiply(f12).subtract(f0.multiply(f2)));
        alphaEMalphaM = alphaEMalphaM.subtract(shift);
        alphaE = alphaM.add(alphaEMalphaM);
        cosAlphaE = alphaE.cos();
        sinAlphaE = alphaE.sin();
    } while ((++iter < 50) && (FastMath.abs(shift.getValue()) > 1.0e-12));
    return alphaE;
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure)

Aggregations

DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)140 Test (org.junit.Test)69 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)63 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)42 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)40 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)33 SpacecraftState (org.orekit.propagation.SpacecraftState)30 AbsoluteDate (org.orekit.time.AbsoluteDate)25 RandomGenerator (org.hipparchus.random.RandomGenerator)22 Frame (org.orekit.frames.Frame)22 PVCoordinates (org.orekit.utils.PVCoordinates)21 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)20 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)18 OrekitException (org.orekit.errors.OrekitException)16 FiniteDifferencesDifferentiator (org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)15 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)15 OrbitType (org.orekit.orbits.OrbitType)15 ParameterDriver (org.orekit.utils.ParameterDriver)15 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)14 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)14