Search in sources :

Example 6 with FieldDerivativeStructure

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

the class FieldPVCoordinatesTest method testMomentumDerivative.

@Test
public void testMomentumDerivative() throws OrekitException {
    final FieldPVCoordinates<Decimal64> pva = new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(-4947831.), new Decimal64(-3765382.), new Decimal64(-3708221.)), new FieldVector3D<>(new Decimal64(-2079.), new Decimal64(5291.), new Decimal64(-7842.)));
    final FieldVector3D<Decimal64> p = pva.getPosition();
    final FieldVector3D<Decimal64> v = pva.getVelocity();
    final FieldVector3D<Decimal64> a = pva.getAcceleration();
    final Decimal64 r2 = p.getNormSq();
    final Decimal64 r = r2.sqrt();
    final FieldVector3D<Decimal64> keplerianJerk = new FieldVector3D<>(FieldVector3D.dotProduct(p, v).multiply(-2).divide(r2), a, a.getNorm().negate().divide(r), v);
    final FieldPVCoordinates<Decimal64> velocity = new FieldPVCoordinates<>(v, a, keplerianJerk);
    final FieldVector3D<Decimal64> momentumRef = pva.getMomentum();
    final FieldVector3D<Decimal64> momentumDotRef = pva.crossProduct(velocity).getVelocity();
    final FieldVector3D<FieldDerivativeStructure<Decimal64>> momentumDot = pva.toDerivativeStructurePV(1).getMomentum();
    Assert.assertEquals(momentumRef.getX().getReal(), momentumDot.getX().getReal(), 1.0e-15);
    Assert.assertEquals(momentumRef.getY().getReal(), momentumDot.getY().getReal(), 1.0e-15);
    Assert.assertEquals(momentumRef.getZ().getReal(), momentumDot.getZ().getReal(), 1.0e-15);
    Assert.assertEquals(momentumDotRef.getX().getReal(), momentumDot.getX().getPartialDerivative(1).getReal(), 1.0e-15);
    Assert.assertEquals(momentumDotRef.getY().getReal(), momentumDot.getY().getPartialDerivative(1).getReal(), 1.0e-15);
    Assert.assertEquals(momentumDotRef.getZ().getReal(), momentumDot.getZ().getPartialDerivative(1).getReal(), 1.0e-15);
}
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 7 with FieldDerivativeStructure

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

the class FieldPVCoordinatesTest method testJerkIsVelocitySecondDerivative.

@Test
public void testJerkIsVelocitySecondDerivative() 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> numericalJerk = differentiate(orbit, o -> o.getPVCoordinates().getAcceleration());
    Assert.assertEquals(numericalJerk.getX().getReal(), fv.getVelocity().getX().getPartialDerivative(2).getReal(), 1.0e-13);
    Assert.assertEquals(numericalJerk.getY().getReal(), fv.getVelocity().getY().getPartialDerivative(2).getReal(), 1.0e-13);
    Assert.assertEquals(numericalJerk.getZ().getReal(), fv.getVelocity().getZ().getPartialDerivative(2).getReal(), 1.0e-13);
}
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 8 with FieldDerivativeStructure

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

the class FieldPVCoordinatesTest method testToDerivativeStructureVector0.

@Test
public void testToDerivativeStructureVector0() 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(0);
    Assert.assertEquals(1, fv.getX().getFreeParameters());
    Assert.assertEquals(0, 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);
    checkPV(new FieldPVCoordinates<>(new FieldVector3D<>(new Decimal64(1), new Decimal64(0.1), new Decimal64(10)), FieldVector3D.getZero(Decimal64Field.getInstance()), FieldVector3D.getZero(Decimal64Field.getInstance())), new FieldPVCoordinates<>(fv), 1.0e-15);
}
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 9 with FieldDerivativeStructure

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

the class FieldPVCoordinatesTest method testJerkIsAccelerationDerivative.

@Test
public void testJerkIsAccelerationDerivative() 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>> fv1 = orbit.getPVCoordinates().toDerivativeStructurePV(1);
    FieldVector3D<Decimal64> numericalJerk = differentiate(orbit, o -> o.getPVCoordinates().getAcceleration());
    Assert.assertEquals(numericalJerk.getX().getReal(), fv1.getAcceleration().getX().getPartialDerivative(1).getReal(), 1.0e-13);
    Assert.assertEquals(numericalJerk.getY().getReal(), fv1.getAcceleration().getY().getPartialDerivative(1).getReal(), 1.0e-13);
    Assert.assertEquals(numericalJerk.getZ().getReal(), fv1.getAcceleration().getZ().getPartialDerivative(1).getReal(), 1.0e-13);
    FieldPVCoordinates<FieldDerivativeStructure<Decimal64>> fv2 = orbit.getPVCoordinates().toDerivativeStructurePV(2);
    Assert.assertEquals(numericalJerk.getX().getReal(), fv2.getAcceleration().getX().getPartialDerivative(1).getReal(), 1.0e-13);
    Assert.assertEquals(numericalJerk.getY().getReal(), fv2.getAcceleration().getY().getPartialDerivative(1).getReal(), 1.0e-13);
    Assert.assertEquals(numericalJerk.getZ().getReal(), fv2.getAcceleration().getZ().getPartialDerivative(1).getReal(), 1.0e-13);
}
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 10 with FieldDerivativeStructure

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

the class FieldPVCoordinatesTest method testToDerivativeStructurePV1.

@Test
public void testToDerivativeStructurePV1() throws OrekitException {
    FieldPVCoordinates<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))).toDerivativeStructurePV(1);
    Assert.assertEquals(1, fv.getPosition().getX().getFreeParameters());
    Assert.assertEquals(1, fv.getPosition().getX().getOrder());
    Assert.assertEquals(1.0, fv.getPosition().getX().getReal(), 1.0e-10);
    Assert.assertEquals(0.1, fv.getPosition().getY().getReal(), 1.0e-10);
    Assert.assertEquals(10.0, fv.getPosition().getZ().getReal(), 1.0e-10);
    Assert.assertEquals(-1.0, fv.getVelocity().getX().getReal(), 1.0e-10);
    Assert.assertEquals(-0.1, fv.getVelocity().getY().getReal(), 1.0e-10);
    Assert.assertEquals(-10.0, fv.getVelocity().getZ().getReal(), 1.0e-10);
    Assert.assertEquals(10.0, fv.getAcceleration().getX().getReal(), 1.0e-10);
    Assert.assertEquals(-1.0, fv.getAcceleration().getY().getReal(), 1.0e-10);
    Assert.assertEquals(-100.0, fv.getAcceleration().getZ().getReal(), 1.0e-10);
    Assert.assertEquals(fv.getVelocity().getX().getReal(), fv.getPosition().getX().getPartialDerivative(1).getReal(), 1.0e-10);
    Assert.assertEquals(fv.getVelocity().getY().getReal(), fv.getPosition().getY().getPartialDerivative(1).getReal(), 1.0e-10);
    Assert.assertEquals(fv.getVelocity().getZ().getReal(), fv.getPosition().getZ().getPartialDerivative(1).getReal(), 1.0e-10);
    Assert.assertEquals(fv.getAcceleration().getX().getReal(), fv.getVelocity().getX().getPartialDerivative(1).getReal(), 1.0e-10);
    Assert.assertEquals(fv.getAcceleration().getY().getReal(), fv.getVelocity().getY().getPartialDerivative(1).getReal(), 1.0e-10);
    Assert.assertEquals(fv.getAcceleration().getZ().getReal(), fv.getVelocity().getZ().getPartialDerivative(1).getReal(), 1.0e-10);
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

Aggregations

FieldDerivativeStructure (org.hipparchus.analysis.differentiation.FieldDerivativeStructure)10 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)10 Decimal64 (org.hipparchus.util.Decimal64)10 Test (org.junit.Test)10 FieldCartesianOrbit (org.orekit.orbits.FieldCartesianOrbit)3 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)1