use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class PVCoordinatesTest method testMomentumDerivative.
@Test
public void testMomentumDerivative() throws OrekitException {
final PVCoordinates pva = new PVCoordinates(new Vector3D(-4947831., -3765382., -3708221.), new Vector3D(-2079., 5291., -7842.));
final Vector3D p = pva.getPosition();
final Vector3D v = pva.getVelocity();
final Vector3D a = pva.getAcceleration();
final double r2 = p.getNormSq();
final double r = FastMath.sqrt(r2);
final Vector3D keplerianJerk = new Vector3D(-3 * Vector3D.dotProduct(p, v) / r2, a, -a.getNorm() / r, v);
final PVCoordinates velocity = new PVCoordinates(v, a, keplerianJerk);
final Vector3D momentumRef = pva.getMomentum();
final Vector3D momentumDotRef = PVCoordinates.crossProduct(pva, velocity).getVelocity();
final FieldVector3D<DerivativeStructure> momentumDot = pva.toDerivativeStructurePV(1).getMomentum();
Assert.assertEquals(momentumRef.getX(), momentumDot.getX().getReal(), 1.0e-15);
Assert.assertEquals(momentumRef.getY(), momentumDot.getY().getReal(), 1.0e-15);
Assert.assertEquals(momentumRef.getZ(), momentumDot.getZ().getReal(), 1.0e-15);
Assert.assertEquals(momentumDotRef.getX(), momentumDot.getX().getPartialDerivative(1), 1.0e-15);
Assert.assertEquals(momentumDotRef.getY(), momentumDot.getY().getPartialDerivative(1), 1.0e-15);
Assert.assertEquals(momentumDotRef.getZ(), momentumDot.getZ().getPartialDerivative(1), 1.0e-15);
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class PVCoordinatesTest method testToDerivativeStructureVector2.
@Test
public void testToDerivativeStructureVector2() throws OrekitException {
FieldVector3D<DerivativeStructure> fv = new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -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), 1.0e-15);
Assert.assertEquals(-0.1, fv.getY().getPartialDerivative(1), 1.0e-15);
Assert.assertEquals(-10.0, fv.getZ().getPartialDerivative(1), 1.0e-15);
Assert.assertEquals(10.0, fv.getX().getPartialDerivative(2), 1.0e-15);
Assert.assertEquals(-1.0, fv.getY().getPartialDerivative(2), 1.0e-15);
Assert.assertEquals(-100.0, fv.getZ().getPartialDerivative(2), 1.0e-15);
checkPV(new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)), new PVCoordinates(fv), 1.0e-15);
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.getX().taylor(dt), 1.0e-14);
Assert.assertEquals(p.getY(), fv.getY().taylor(dt), 1.0e-14);
Assert.assertEquals(p.getZ(), fv.getZ().taylor(dt), 1.0e-14);
}
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D 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.geometry.euclidean.threed.FieldVector3D in project Orekit by CS-SI.
the class FieldPVCoordinatesTest method testGetMomentum.
@Test
public void testGetMomentum() {
// 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).getMomentum(), p.crossProduct(v));
// check simple cases
Assert.assertEquals(new FieldPVCoordinates<>(i, i.scalarMultiply(-1)).getMomentum(), zero);
Assert.assertEquals(new FieldPVCoordinates<>(i, j).getMomentum(), k);
}
use of org.hipparchus.geometry.euclidean.threed.FieldVector3D 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);
}
}
Aggregations