Search in sources :

Example 21 with FieldVector3D

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);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) Test(org.junit.Test)

Example 22 with FieldVector3D

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);
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) Test(org.junit.Test)

Example 23 with FieldVector3D

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);
    }
}
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 24 with FieldVector3D

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);
}
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 25 with FieldVector3D

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);
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Decimal64(org.hipparchus.util.Decimal64) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

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