Search in sources :

Example 26 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class FieldPVCoordinatesTest method testJounceIsAccelerationSecondDerivative.

@Test
public void testJounceIsAccelerationSecondDerivative() throws OrekitException {
    final FieldCartesianOrbit<Decimal64> orbit = new FieldCartesianOrbit<>(new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(-4947831.), new Decimal64(-3765382.), new Decimal64(-3708221.)), new FieldVector3D<>(new Decimal64(-2079.), new Decimal64(5291.), new Decimal64(-7842.))), FramesFactory.getEME2000(), FieldAbsoluteDate.getJ2000Epoch(Decimal64Field.getInstance()), Constants.EIGEN5C_EARTH_MU);
    FieldPVCoordinates<FieldDerivativeStructure<Decimal64>> fv = orbit.getPVCoordinates().toDerivativeStructurePV(2);
    FieldVector3D<Decimal64> numericalJounce = differentiate(orbit, o -> {
        FieldVector3D<FieldDerivativeStructure<Decimal64>> a = o.getPVCoordinates().toDerivativeStructurePV(1).getAcceleration();
        return new FieldVector3D<>(a.getX().getPartialDerivative(1), a.getY().getPartialDerivative(1), a.getZ().getPartialDerivative(1));
    });
    Assert.assertEquals(numericalJounce.getX().getReal(), fv.getAcceleration().getX().getPartialDerivative(2).getReal(), 1.0e-15);
    Assert.assertEquals(numericalJounce.getY().getReal(), fv.getAcceleration().getY().getPartialDerivative(2).getReal(), 1.0e-15);
    Assert.assertEquals(numericalJounce.getZ().getReal(), fv.getAcceleration().getZ().getPartialDerivative(2).getReal(), 1.0e-15);
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

Example 27 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class FieldPVCoordinatesTest method testGetAngularVelocity.

@Test
public void testGetAngularVelocity() {
    // setup
    DSFactory factory = new DSFactory(1, 1);
    DerivativeStructure oneDS = factory.getDerivativeField().getOne();
    DerivativeStructure zeroDS = factory.getDerivativeField().getZero();
    FieldVector3D<DerivativeStructure> zero = new FieldVector3D<>(zeroDS, zeroDS, zeroDS);
    FieldVector3D<DerivativeStructure> i = new FieldVector3D<>(oneDS, zeroDS, zeroDS);
    FieldVector3D<DerivativeStructure> j = new FieldVector3D<>(zeroDS, oneDS, zeroDS);
    FieldVector3D<DerivativeStructure> k = new FieldVector3D<>(zeroDS, zeroDS, oneDS);
    FieldVector3D<DerivativeStructure> p = new FieldVector3D<>(oneDS, factory.constant(-2), factory.constant(3));
    FieldVector3D<DerivativeStructure> v = new FieldVector3D<>(factory.constant(-9), factory.constant(8), factory.constant(-7));
    // action + verify
    Assert.assertEquals(new FieldPVCoordinates<>(p, v).getAngularVelocity(), p.crossProduct(v).scalarMultiply(p.getNormSq().reciprocal()));
    // check extra simple cases
    Assert.assertEquals(new FieldPVCoordinates<>(i, i.scalarMultiply(-1)).getAngularVelocity(), zero);
    Assert.assertEquals(new FieldPVCoordinates<>(i.scalarMultiply(2), j).getAngularVelocity(), k.scalarMultiply(0.5));
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

Example 28 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class FieldPVCoordinatesTest method testToDerivativeStructureVector2.

@Test
public void testToDerivativeStructureVector2() throws OrekitException {
    FieldVector3D<FieldDerivativeStructure<Decimal64>> fv = new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(1), new Decimal64(0.1), new Decimal64(10)), new FieldVector3D<>(new Decimal64(-1), new Decimal64(-0.1), new Decimal64(-10)), new FieldVector3D<>(new Decimal64(10), new Decimal64(-1.0), new Decimal64(-100))).toDerivativeStructureVector(2);
    Assert.assertEquals(1, fv.getX().getFreeParameters());
    Assert.assertEquals(2, fv.getX().getOrder());
    Assert.assertEquals(1.0, fv.getX().getReal(), 1.0e-10);
    Assert.assertEquals(0.1, fv.getY().getReal(), 1.0e-10);
    Assert.assertEquals(10.0, fv.getZ().getReal(), 1.0e-10);
    Assert.assertEquals(-1.0, fv.getX().getPartialDerivative(1).getReal(), 1.0e-15);
    Assert.assertEquals(-0.1, fv.getY().getPartialDerivative(1).getReal(), 1.0e-15);
    Assert.assertEquals(-10.0, fv.getZ().getPartialDerivative(1).getReal(), 1.0e-15);
    Assert.assertEquals(10.0, fv.getX().getPartialDerivative(2).getReal(), 1.0e-15);
    Assert.assertEquals(-1.0, fv.getY().getPartialDerivative(2).getReal(), 1.0e-15);
    Assert.assertEquals(-100.0, fv.getZ().getPartialDerivative(2).getReal(), 1.0e-15);
    checkPV(new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(1), new Decimal64(0.1), new Decimal64(10)), new FieldVector3D<>(new Decimal64(-1), new Decimal64(-0.1), new Decimal64(-10)), new FieldVector3D<>(new Decimal64(10), new Decimal64(-1.0), new Decimal64(-100))), new FieldPVCoordinates<>(fv), 1.0e-15);
    for (double dt = 0; dt < 10; dt += 0.125) {
        FieldVector3D<Decimal64> p = new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(1), new Decimal64(0.1), new Decimal64(10)), new FieldVector3D<>(new Decimal64(-1), new Decimal64(-0.1), new Decimal64(-10)), new FieldVector3D<>(new Decimal64(10), new Decimal64(-1.0), new Decimal64(-100))).shiftedBy(dt).getPosition();
        Assert.assertEquals(p.getX().doubleValue(), fv.getX().taylor(dt).doubleValue(), 1.0e-14);
        Assert.assertEquals(p.getY().doubleValue(), fv.getY().taylor(dt).doubleValue(), 1.0e-14);
        Assert.assertEquals(p.getZ().doubleValue(), fv.getZ().taylor(dt).doubleValue(), 1.0e-14);
    }
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

Example 29 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class CartesianOrbit method getVelocityDS.

/**
 * Get velocity with derivatives.
 * @return velocity with derivatives
 */
private FieldVector3D<DerivativeStructure> getVelocityDS() {
    final Vector3D v = getPVCoordinates().getVelocity();
    final Vector3D a = getPVCoordinates().getAcceleration();
    return new FieldVector3D<>(FACTORY.build(v.getX(), a.getX()), FACTORY.build(v.getY(), a.getY()), FACTORY.build(v.getZ(), a.getZ()));
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D)

Example 30 with FieldVector3D

use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.

the class Geoid method getIntersectionPoint.

/**
 * {@inheritDoc}
 *
 * <p> The intersection point is computed using a line search along the
 * specified line. This is accurate when the geoid is slowly varying.
 */
@Override
public <T extends RealFieldElement<T>> FieldGeodeticPoint<T> getIntersectionPoint(final FieldLine<T> lineInFrame, final FieldVector3D<T> closeInFrame, final Frame frame, final FieldAbsoluteDate<T> date) throws OrekitException {
    final Field<T> field = date.getField();
    /*
         * It is assumed that the geoid is slowly varying over it's entire
         * surface. Therefore there will one local intersection.
         */
    // transform to body frame
    final Frame bodyFrame = this.getBodyFrame();
    final FieldTransform<T> frameToBody = frame.getTransformTo(bodyFrame, date);
    final FieldVector3D<T> close = frameToBody.transformPosition(closeInFrame);
    final FieldLine<T> lineInBodyFrame = frameToBody.transformLine(lineInFrame);
    // set the line's direction so the solved for value is always positive
    final FieldLine<T> line;
    if (lineInBodyFrame.getAbscissa(close).getReal() < 0) {
        line = lineInBodyFrame.revert();
    } else {
        line = lineInBodyFrame;
    }
    final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
    // calculate end points
    // distance from line to center of earth, squared
    final T d2 = line.pointAt(0.0).getNormSq();
    // the minimum abscissa, squared
    final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
    final T minAbscissa2 = d2.negate().add(n * n);
    // smaller end point of the interval = 0.0 or intersection with
    // min_undulation sphere
    final T lowPoint = minAbscissa2.getReal() < 0 ? field.getZero() : minAbscissa2.sqrt();
    // the maximum abscissa, squared
    final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
    final T maxAbscissa2 = d2.negate().add(x * x);
    // larger end point of the interval
    final T highPoint = maxAbscissa2.sqrt();
    // line search function
    final RealFieldUnivariateFunction<T> heightFunction = z -> {
        try {
            final FieldGeodeticPoint<T> geodetic = transform(line.pointAt(z), bodyFrame, date);
            return geodetic.getAltitude();
        } catch (OrekitException e) {
            // due to frame transform -> re-throw
            throw new RuntimeException(e);
        }
    };
    // compute answer
    if (maxAbscissa2.getReal() < 0) {
        // ray does not pierce bounding sphere -> no possible intersection
        return null;
    }
    // solve line search problem to find the intersection
    final FieldBracketingNthOrderBrentSolver<T> solver = new FieldBracketingNthOrderBrentSolver<>(field.getZero().add(1.0e-14), field.getZero().add(1.0e-6), field.getZero().add(1.0e-15), 5);
    try {
        final T abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint, AllowedSolution.ANY_SIDE);
        // return intersection point
        return this.transform(line.pointAt(abscissa), bodyFrame, date);
    } catch (MathRuntimeException e) {
        // no intersection
        return null;
    }
}
Also used : AllowedSolution(org.hipparchus.analysis.solvers.AllowedSolution) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) Frame(org.orekit.frames.Frame) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FastMath(org.hipparchus.util.FastMath) FieldBracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver) BracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) TideSystem(org.orekit.forces.gravity.potential.TideSystem) UnivariateSolver(org.hipparchus.analysis.solvers.UnivariateSolver) Line(org.hipparchus.geometry.euclidean.threed.Line) Field(org.hipparchus.Field) RealFieldUnivariateFunction(org.hipparchus.analysis.RealFieldUnivariateFunction) OrekitException(org.orekit.errors.OrekitException) RealFieldElement(org.hipparchus.RealFieldElement) FieldLine(org.hipparchus.geometry.euclidean.threed.FieldLine) Transform(org.orekit.frames.Transform) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) FieldTransform(org.orekit.frames.FieldTransform) AbsoluteDate(org.orekit.time.AbsoluteDate) Frame(org.orekit.frames.Frame) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) FieldBracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) OrekitException(org.orekit.errors.OrekitException)

Aggregations

FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)124 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)53 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)49 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)38 Test (org.junit.Test)38 Frame (org.orekit.frames.Frame)36 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)31 OrekitException (org.orekit.errors.OrekitException)23 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)20 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)20 Decimal64 (org.hipparchus.util.Decimal64)18 FieldEquinoctialOrbit (org.orekit.orbits.FieldEquinoctialOrbit)15 OrbitType (org.orekit.orbits.OrbitType)15 AbsoluteDate (org.orekit.time.AbsoluteDate)15 DormandPrince853FieldIntegrator (org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator)14 Transform (org.orekit.frames.Transform)14 FieldDerivativeStructure (org.hipparchus.analysis.differentiation.FieldDerivativeStructure)12 FieldEcksteinHechlerPropagator (org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator)10 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)9 ArrayList (java.util.ArrayList)8