Search in sources :

Example 26 with Well19937a

use of org.hipparchus.random.Well19937a in project Orekit by CS-SI.

the class TransformProviderUtilTest method testIdentityField.

@Test
public void testIdentityField() throws OrekitException {
    RandomGenerator random = new Well19937a(0x7086a8e4ad1265b0l);
    final FieldAbsoluteDate<Decimal64> date = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), AbsoluteDate.J2000_EPOCH);
    checkNoTransform(TransformProviderUtils.IDENTITY_PROVIDER.getTransform(date), random);
}
Also used : Decimal64(org.hipparchus.util.Decimal64) Well19937a(org.hipparchus.random.Well19937a) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) RandomGenerator(org.hipparchus.random.RandomGenerator) Test(org.junit.Test)

Example 27 with Well19937a

use of org.hipparchus.random.Well19937a 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 28 with Well19937a

use of org.hipparchus.random.Well19937a in project Orekit by CS-SI.

the class FieldTransformTest method doTestLineDouble.

private <T extends RealFieldElement<T>> void doTestLineDouble(Field<T> field) {
    RandomGenerator random = new Well19937a(0x4a5ff67426c5731fl);
    for (int i = 0; i < 100; ++i) {
        FieldTransform<T> transform = randomTransform(field, random);
        for (int j = 0; j < 20; ++j) {
            Vector3D p0 = randomVector(field, 1.0e3, random).toVector3D();
            Vector3D p1 = randomVector(field, 1.0e3, random).toVector3D();
            Line l = new Line(p0, p1, 1.0e-10);
            FieldLine<T> transformed = transform.transformLine(l);
            for (int k = 0; k < 10; ++k) {
                Vector3D p = l.pointAt(random.nextDouble() * 1.0e6);
                Assert.assertEquals(0.0, transformed.distance(transform.transformPosition(p)).getReal(), 1.0e-9);
            }
        }
    }
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) FieldLine(org.hipparchus.geometry.euclidean.threed.FieldLine) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator)

Example 29 with Well19937a

use of org.hipparchus.random.Well19937a 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 30 with Well19937a

use of org.hipparchus.random.Well19937a 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)

Aggregations

RandomGenerator (org.hipparchus.random.RandomGenerator)73 Well19937a (org.hipparchus.random.Well19937a)73 Test (org.junit.Test)51 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)22 GeodeticPoint (org.orekit.bodies.GeodeticPoint)19 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)17 PVCoordinates (org.orekit.utils.PVCoordinates)15 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)15 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)14 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)14 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)13 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)13 Frame (org.orekit.frames.Frame)10 GaussianRandomGenerator (org.hipparchus.random.GaussianRandomGenerator)8 UncorrelatedRandomVectorGenerator (org.hipparchus.random.UncorrelatedRandomVectorGenerator)8 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)8 OrbitType (org.orekit.orbits.OrbitType)8 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)8 SpacecraftState (org.orekit.propagation.SpacecraftState)8 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)8