Search in sources :

Example 11 with FieldPVCoordinates

use of org.orekit.utils.FieldPVCoordinates in project Orekit by CS-SI.

the class TransformTest method testTransPV.

@Test
public void testTransPV() {
    RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);
    for (int i = 0; i < 10; ++i) {
        // random position, velocity and acceleration
        Vector3D pos = randomVector(1.0e3, rnd);
        Vector3D vel = randomVector(1.0, rnd);
        Vector3D acc = randomVector(1.0e-3, rnd);
        PVCoordinates pvOne = new PVCoordinates(pos, vel, acc);
        // random transform
        Vector3D transPos = randomVector(1.0e3, rnd);
        Vector3D transVel = randomVector(1.0, rnd);
        Vector3D transAcc = randomVector(1.0e-3, rnd);
        Transform tr = new Transform(AbsoluteDate.J2000_EPOCH, transPos, transVel, transAcc);
        double dt = 1;
        // we should obtain
        Vector3D good = tr.transformPosition(pos.add(new Vector3D(dt, vel))).add(new Vector3D(dt, transVel));
        // we have
        PVCoordinates pvTwo = tr.transformPVCoordinates(pvOne);
        Vector3D result = pvTwo.getPosition().add(new Vector3D(dt, pvTwo.getVelocity()));
        checkVector(good, result, 1.0e-15);
        FieldPVCoordinates<Decimal64> fieldPVOne = new FieldPVCoordinates<Decimal64>(new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getPosition()), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getVelocity()), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getAcceleration()));
        FieldPVCoordinates<Decimal64> fieldPVTwo = tr.transformPVCoordinates(fieldPVOne);
        FieldVector3D<Decimal64> fieldResult = fieldPVTwo.getPosition().add(new FieldVector3D<Decimal64>(dt, fieldPVTwo.getVelocity()));
        checkVector(good, fieldResult.toVector3D(), 1.0e-15);
        TimeStampedFieldPVCoordinates<Decimal64> fieldTPVOne = new TimeStampedFieldPVCoordinates<Decimal64>(tr.getDate(), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getPosition()), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getVelocity()), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getAcceleration()));
        TimeStampedFieldPVCoordinates<Decimal64> fieldTPVTwo = tr.transformPVCoordinates(fieldTPVOne);
        FieldVector3D<Decimal64> fieldTResult = fieldTPVTwo.getPosition().add(new FieldVector3D<Decimal64>(dt, fieldTPVTwo.getVelocity()));
        checkVector(good, fieldTResult.toVector3D(), 1.0e-15);
        // test inverse
        Vector3D resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity();
        checkVector(resultvel, vel, 1.0e-15);
    }
}
Also used : Decimal64(org.hipparchus.util.Decimal64) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) Test(org.junit.Test)

Example 12 with FieldPVCoordinates

use of org.orekit.utils.FieldPVCoordinates in project Orekit by CS-SI.

the class FieldTransformTest method doTestRotPV.

private <T extends RealFieldElement<T>> void doTestRotPV(Field<T> field) {
    RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);
    for (int i = 0; i < 10; ++i) {
        // Random instant rotation
        FieldRotation<T> instantRot = randomRotation(field, rnd);
        FieldVector3D<T> normAxis = instantRot.getAxis(RotationConvention.VECTOR_OPERATOR);
        T w = instantRot.getAngle().abs().divide(Constants.JULIAN_DAY);
        // random rotation
        FieldRotation<T> rot = randomRotation(field, rnd);
        // so we have a transform
        FieldTransform<T> tr = new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), rot, new FieldVector3D<>(w, normAxis));
        // random position, velocity, acceleration
        FieldVector3D<T> pos = randomVector(field, 1.0e3, rnd);
        FieldVector3D<T> vel = randomVector(field, 1.0, rnd);
        FieldVector3D<T> acc = randomVector(field, 1.0e-3, rnd);
        FieldPVCoordinates<T> pvOne = new FieldPVCoordinates<>(pos, vel, acc);
        // we obtain
        FieldPVCoordinates<T> pvTwo = tr.transformPVCoordinates(pvOne);
        // test inverse
        FieldVector3D<T> resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity();
        checkVector(resultvel, vel, 1.0e-15);
    }
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator)

Example 13 with FieldPVCoordinates

use of org.orekit.utils.FieldPVCoordinates in project Orekit by CS-SI.

the class FieldTransformTest method doTestAccelerationComposition.

private <T extends RealFieldElement<T>> void doTestAccelerationComposition(Field<T> field) {
    RandomGenerator random = new Well19937a(0x41fdd07d6c9e9f65l);
    FieldVector3D<T> p1 = randomVector(field, 1.0e3, random);
    FieldVector3D<T> v1 = randomVector(field, 1.0, random);
    FieldVector3D<T> a1 = randomVector(field, 1.0e-3, random);
    FieldRotation<T> r1 = randomRotation(field, random);
    FieldVector3D<T> o1 = randomVector(field, 0.1, random);
    FieldVector3D<T> p2 = randomVector(field, 1.0e3, random);
    FieldVector3D<T> v2 = randomVector(field, 1.0, random);
    FieldVector3D<T> a2 = randomVector(field, 1.0e-3, random);
    FieldRotation<T> r2 = randomRotation(field, random);
    FieldVector3D<T> o2 = randomVector(field, 0.1, random);
    FieldTransform<T> t1 = new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), p1, v1, a1), new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), r1, o1));
    FieldTransform<T> t2 = new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), p2, v2, a2), new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), r2, o2));
    FieldTransform<T> t12 = new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), t1, t2);
    FieldVector3D<T> q = randomVector(field, 1.0e3, random);
    FieldVector3D<T> qDot = randomVector(field, 1.0, random);
    FieldVector3D<T> qDotDot = randomVector(field, 1.0e-3, random);
    FieldPVCoordinates<T> pva0 = new FieldPVCoordinates<>(q, qDot, qDotDot);
    FieldPVCoordinates<T> pva1 = t1.transformPVCoordinates(pva0);
    FieldPVCoordinates<T> pva2 = t2.transformPVCoordinates(pva1);
    FieldPVCoordinates<T> pvac = t12.transformPVCoordinates(pva0);
    checkVector(pva2.getPosition(), pvac.getPosition(), 1.0e-15);
    checkVector(pva2.getVelocity(), pvac.getVelocity(), 1.0e-15);
    checkVector(pva2.getAcceleration(), pvac.getAcceleration(), 1.0e-15);
    // despite neither raw transforms have angular acceleration,
    // the combination does have an angular acceleration,
    // it is due to the cross product Ω₁ ⨯ Ω₂
    Assert.assertEquals(0.0, t1.getAngular().getRotationAcceleration().getNorm().getReal(), 1.0e-15);
    Assert.assertEquals(0.0, t2.getAngular().getRotationAcceleration().getNorm().getReal(), 1.0e-15);
    Assert.assertTrue(t12.getAngular().getRotationAcceleration().getNorm().getReal() > 0.01);
    Assert.assertEquals(0.0, t12.freeze().getCartesian().getVelocity().getNorm().getReal(), 1.0e-15);
    Assert.assertEquals(0.0, t12.freeze().getCartesian().getAcceleration().getNorm().getReal(), 1.0e-15);
    Assert.assertEquals(0.0, t12.freeze().getAngular().getRotationRate().getNorm().getReal(), 1.0e-15);
    Assert.assertEquals(0.0, t12.freeze().getAngular().getRotationAcceleration().getNorm().getReal(), 1.0e-15);
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator)

Example 14 with FieldPVCoordinates

use of org.orekit.utils.FieldPVCoordinates in project Orekit by CS-SI.

the class FieldTransformTest method doTestRandomComposition.

private <T extends RealFieldElement<T>> void doTestRandomComposition(Field<T> field) {
    RandomGenerator random = new Well19937a(0x171c79e323a1123l);
    for (int i = 0; i < 20; ++i) {
        // build a complex transform by composing primitive ones
        int n = random.nextInt(20);
        @SuppressWarnings("unchecked") FieldTransform<T>[] transforms = (FieldTransform<T>[]) Array.newInstance(FieldTransform.class, n);
        FieldTransform<T> combined = FieldTransform.getIdentity(field);
        for (int k = 0; k < n; ++k) {
            transforms[k] = random.nextBoolean() ? new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), randomVector(field, 1.0e3, random), randomVector(field, 1.0, random), randomVector(field, 1.0e-3, random)) : new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), randomRotation(field, random), randomVector(field, 0.01, random), randomVector(field, 1.0e-4, random));
            combined = new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), combined, transforms[k]);
        }
        // check the composition
        for (int j = 0; j < 10; ++j) {
            FieldVector3D<T> a = randomVector(field, 1.0, random);
            FieldVector3D<T> b = randomVector(field, 1.0e3, random);
            FieldPVCoordinates<T> c = new FieldPVCoordinates<>(randomVector(field, 1.0e3, random), randomVector(field, 1.0, random), randomVector(field, 1.0e-3, random));
            FieldVector3D<T> aRef = a;
            FieldVector3D<T> bRef = b;
            FieldPVCoordinates<T> cRef = c;
            for (int k = 0; k < n; ++k) {
                aRef = transforms[k].transformVector(aRef);
                bRef = transforms[k].transformPosition(bRef);
                cRef = transforms[k].transformPVCoordinates(cRef);
            }
            FieldVector3D<T> aCombined = combined.transformVector(a);
            FieldVector3D<T> bCombined = combined.transformPosition(b);
            FieldPVCoordinates<T> cCombined = combined.transformPVCoordinates(c);
            checkVector(aRef, aCombined, 3.0e-15);
            checkVector(bRef, bCombined, 5.0e-15);
            checkVector(cRef.getPosition(), cCombined.getPosition(), 1.0e-14);
            checkVector(cRef.getVelocity(), cCombined.getVelocity(), 1.0e-14);
            checkVector(cRef.getAcceleration(), cCombined.getAcceleration(), 1.0e-14);
        }
    }
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator)

Example 15 with FieldPVCoordinates

use of org.orekit.utils.FieldPVCoordinates in project Orekit by CS-SI.

the class FieldTransformTest method doTestTransPV.

private <T extends RealFieldElement<T>> void doTestTransPV(Field<T> field) {
    RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);
    for (int i = 0; i < 10; ++i) {
        // random position, velocity and acceleration
        FieldVector3D<T> pos = randomVector(field, 1.0e3, rnd);
        FieldVector3D<T> vel = randomVector(field, 1.0, rnd);
        FieldVector3D<T> acc = randomVector(field, 1.0e-3, rnd);
        FieldPVCoordinates<T> pvOne = new FieldPVCoordinates<>(pos, vel, acc);
        // random transform
        FieldVector3D<T> transPos = randomVector(field, 1.0e3, rnd);
        FieldVector3D<T> transVel = randomVector(field, 1.0, rnd);
        FieldVector3D<T> transAcc = randomVector(field, 1.0e-3, rnd);
        FieldTransform<T> tr = new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), transPos, transVel, transAcc);
        double dt = 1;
        // we should obtain
        FieldVector3D<T> good = tr.transformPosition(pos.add(new FieldVector3D<>(dt, vel))).add(new FieldVector3D<>(dt, transVel));
        // we have
        FieldPVCoordinates<T> pvTwo = tr.transformPVCoordinates(pvOne);
        FieldVector3D<T> result = pvTwo.getPosition().add(new FieldVector3D<>(dt, pvTwo.getVelocity()));
        checkVector(good, result, 1.0e-15);
        // test inverse
        FieldVector3D<T> resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity();
        checkVector(resultvel, vel, 1.0e-15);
    }
}
Also used : FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TimeStampedFieldPVCoordinates(org.orekit.utils.TimeStampedFieldPVCoordinates) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator)

Aggregations

FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)41 Frame (org.orekit.frames.Frame)27 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)22 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)19 PVCoordinates (org.orekit.utils.PVCoordinates)17 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)16 RandomGenerator (org.hipparchus.random.RandomGenerator)16 Well19937a (org.hipparchus.random.Well19937a)16 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)16 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)15 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)14 Test (org.junit.Test)14 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)13 OrbitType (org.orekit.orbits.OrbitType)13 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)13 SpacecraftState (org.orekit.propagation.SpacecraftState)13 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)13 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)13 AdaptiveStepsizeIntegrator (org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator)12 DormandPrince853FieldIntegrator (org.hipparchus.ode.nonstiff.DormandPrince853FieldIntegrator)12