use of org.hipparchus.analysis.differentiation.FieldDerivativeStructure in project Orekit by CS-SI.
the class TimeStampedFieldPVCoordinatesTest method testToDerivativeStructureVector2.
@Test
public void testToDerivativeStructureVector2() throws OrekitException {
FieldVector3D<FieldDerivativeStructure<Decimal64>> fv = new TimeStampedFieldPVCoordinates<>(FieldAbsoluteDate.getGalileoEpoch(Decimal64Field.getInstance()), 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).doubleValue(), 1.0e-15);
Assert.assertEquals(-0.1, fv.getY().getPartialDerivative(1).doubleValue(), 1.0e-15);
Assert.assertEquals(-10.0, fv.getZ().getPartialDerivative(1).doubleValue(), 1.0e-15);
Assert.assertEquals(10.0, fv.getX().getPartialDerivative(2).doubleValue(), 1.0e-15);
Assert.assertEquals(-1.0, fv.getY().getPartialDerivative(2).doubleValue(), 1.0e-15);
Assert.assertEquals(-100.0, fv.getZ().getPartialDerivative(2).doubleValue(), 1.0e-15);
checkPV(new TimeStampedFieldPVCoordinates<>(FieldAbsoluteDate.getGalileoEpoch(Decimal64Field.getInstance()), 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 TimeStampedFieldPVCoordinates<>(FieldAbsoluteDate.getGalileoEpoch(Decimal64Field.getInstance()), 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);
}
}
use of org.hipparchus.analysis.differentiation.FieldDerivativeStructure in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testToDerivativeStructurePV2.
@Test
public void testToDerivativeStructurePV2() 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(2);
Assert.assertEquals(1, fv.getPosition().getX().getFreeParameters());
Assert.assertEquals(2, 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.getPosition().getX().getPartialDerivative(2).getReal(), 1.0e-10);
Assert.assertEquals(fv.getAcceleration().getY().getReal(), fv.getPosition().getY().getPartialDerivative(2).getReal(), 1.0e-10);
Assert.assertEquals(fv.getAcceleration().getZ().getReal(), fv.getPosition().getZ().getPartialDerivative(2).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);
Assert.assertEquals(fv.getAcceleration().getX().getPartialDerivative(1).getReal(), fv.getVelocity().getX().getPartialDerivative(2).getReal(), 1.0e-10);
Assert.assertEquals(fv.getAcceleration().getY().getPartialDerivative(1).getReal(), fv.getVelocity().getY().getPartialDerivative(2).getReal(), 1.0e-10);
Assert.assertEquals(fv.getAcceleration().getZ().getPartialDerivative(1).getReal(), fv.getVelocity().getZ().getPartialDerivative(2).getReal(), 1.0e-10);
for (double dt = 0; dt < 10; dt += 0.125) {
Vector3D p = new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)).shiftedBy(dt).getPosition();
Assert.assertEquals(p.getX(), fv.getPosition().getX().taylor(dt).getReal(), 1.0e-14);
Assert.assertEquals(p.getY(), fv.getPosition().getY().taylor(dt).getReal(), 1.0e-14);
Assert.assertEquals(p.getZ(), fv.getPosition().getZ().taylor(dt).getReal(), 1.0e-14);
}
}
use of org.hipparchus.analysis.differentiation.FieldDerivativeStructure 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);
}
use of org.hipparchus.analysis.differentiation.FieldDerivativeStructure 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);
}
}
use of org.hipparchus.analysis.differentiation.FieldDerivativeStructure in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testToDerivativeStructureVector1.
@Test
public void testToDerivativeStructureVector1() 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(1);
Assert.assertEquals(1, fv.getX().getFreeParameters());
Assert.assertEquals(1, 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);
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)), FieldVector3D.getZero(Decimal64Field.getInstance())), new FieldPVCoordinates<>(fv), 1.0e-15);
}
Aggregations