Search in sources :

Example 76 with RandomGenerator

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

the class TransformTest method testDecomposeAndRebuild.

@Test
public void testDecomposeAndRebuild() {
    RandomGenerator random = new Well19937a(0xb8ee9da1b05198c9l);
    for (int i = 0; i < 20; ++i) {
        Transform combined = randomTransform(random);
        Transform rebuilt = new Transform(combined.getDate(), new Transform(combined.getDate(), combined.getTranslation(), combined.getVelocity(), combined.getAcceleration()), new Transform(combined.getDate(), combined.getRotation(), combined.getRotationRate(), combined.getRotationAcceleration()));
        checkNoTransform(new Transform(AbsoluteDate.J2000_EPOCH, combined, rebuilt.getInverse()), random);
    }
}
Also used : Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) Test(org.junit.Test)

Example 77 with RandomGenerator

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

the class FieldTransformTest method doTestDecomposeAndRebuild.

private <T extends RealFieldElement<T>> void doTestDecomposeAndRebuild(Field<T> field) {
    RandomGenerator random = new Well19937a(0xb8ee9da1b05198c9l);
    for (int i = 0; i < 20; ++i) {
        FieldTransform<T> combined = randomTransform(field, random);
        FieldTransform<T> rebuilt = new FieldTransform<>(combined.getFieldDate(), new FieldTransform<>(combined.getFieldDate(), combined.getTranslation(), combined.getVelocity(), combined.getAcceleration()), new FieldTransform<>(combined.getFieldDate(), combined.getRotation(), combined.getRotationRate(), combined.getRotationAcceleration()));
        checkNoTransform(new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), combined, rebuilt.getInverse()), random);
    }
}
Also used : Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator)

Example 78 with RandomGenerator

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

the class FieldTransformTest method doTestTranslationDouble.

private <T extends RealFieldElement<T>> void doTestTranslationDouble(Field<T> field) {
    RandomGenerator rnd = new Well19937a(0x7e9d737ba4147787l);
    for (int i = 0; i < 10; ++i) {
        FieldVector3D<T> delta = randomVector(field, 1.0e3, rnd);
        FieldTransform<T> transform = new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), delta);
        for (int j = 0; j < 10; ++j) {
            Vector3D a = createVector(field, rnd.nextDouble(), rnd.nextDouble(), rnd.nextDouble()).toVector3D();
            FieldVector3D<T> b = transform.transformVector(a);
            Assert.assertEquals(0, b.subtract(a).getNorm().getReal(), 1.0e-15);
            FieldVector3D<T> c = transform.transformPosition(a);
            Assert.assertEquals(0, c.subtract(a).subtract(delta).getNorm().getReal(), 1.0e-14);
        }
    }
}
Also used : 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 79 with RandomGenerator

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

the class FieldTransformTest method doTestLine.

private <T extends RealFieldElement<T>> void doTestLine(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) {
            FieldVector3D<T> p0 = randomVector(field, 1.0e3, random);
            FieldVector3D<T> p1 = randomVector(field, 1.0e3, random);
            FieldLine<T> l = new FieldLine<>(p0, p1, 1.0e-10);
            FieldLine<T> transformed = transform.transformLine(l);
            for (int k = 0; k < 10; ++k) {
                FieldVector3D<T> p = l.pointAt(random.nextDouble() * 1.0e6);
                Assert.assertEquals(0.0, transformed.distance(transform.transformPosition(p)).getReal(), 1.0e-9);
            }
        }
    }
}
Also used : FieldLine(org.hipparchus.geometry.euclidean.threed.FieldLine) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator)

Example 80 with RandomGenerator

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

the class FieldTransformTest method doTestJacobianPVA.

private <T extends RealFieldElement<T>> void doTestJacobianPVA(Field<T> field) {
    // base directions for finite differences
    @SuppressWarnings("unchecked") FieldPVCoordinates<T>[] directions = (FieldPVCoordinates<T>[]) Array.newInstance(FieldPVCoordinates.class, 9);
    directions[0] = new FieldPVCoordinates<>(FieldVector3D.getPlusI(field), FieldVector3D.getZero(field), FieldVector3D.getZero(field));
    directions[1] = new FieldPVCoordinates<>(FieldVector3D.getPlusJ(field), FieldVector3D.getZero(field), FieldVector3D.getZero(field));
    directions[2] = new FieldPVCoordinates<>(FieldVector3D.getPlusK(field), FieldVector3D.getZero(field), FieldVector3D.getZero(field));
    directions[3] = new FieldPVCoordinates<>(FieldVector3D.getZero(field), FieldVector3D.getPlusI(field), FieldVector3D.getZero(field));
    directions[4] = new FieldPVCoordinates<>(FieldVector3D.getZero(field), FieldVector3D.getPlusJ(field), FieldVector3D.getZero(field));
    directions[5] = new FieldPVCoordinates<>(FieldVector3D.getZero(field), FieldVector3D.getPlusK(field), FieldVector3D.getZero(field));
    directions[6] = new FieldPVCoordinates<>(FieldVector3D.getZero(field), FieldVector3D.getZero(field), FieldVector3D.getPlusI(field));
    directions[7] = new FieldPVCoordinates<>(FieldVector3D.getZero(field), FieldVector3D.getZero(field), FieldVector3D.getPlusJ(field));
    directions[8] = new FieldPVCoordinates<>(FieldVector3D.getZero(field), FieldVector3D.getZero(field), FieldVector3D.getPlusK(field));
    double h = 0.01;
    RandomGenerator random = new Well19937a(0xd223e88b6232198fl);
    for (int i = 0; i < 20; ++i) {
        // generate a random transform
        FieldTransform<T> combined = randomTransform(field, random);
        // compute Jacobian
        T[][] jacobian = MathArrays.buildArray(field, 9, 9);
        for (int l = 0; l < jacobian.length; ++l) {
            for (int c = 0; c < jacobian[l].length; ++c) {
                jacobian[l][c] = field.getZero().add(1 + 0.1 * c);
            }
        }
        combined.getJacobian(CartesianDerivativesFilter.USE_PVA, jacobian);
        for (int j = 0; j < 100; ++j) {
            FieldPVCoordinates<T> pv0 = new FieldPVCoordinates<>(randomVector(field, 1e3, random), randomVector(field, 1.0, random), randomVector(field, 1.0e-3, random));
            double epsilonP = 2.0e-12 * pv0.getPosition().getNorm().getReal();
            double epsilonV = 6.0e-11 * pv0.getVelocity().getNorm().getReal();
            double epsilonA = 2.0e-9 * pv0.getAcceleration().getNorm().getReal();
            for (int c = 0; c < directions.length; ++c) {
                // eight points finite differences estimation of a Jacobian column
                FieldPVCoordinates<T> pvm4h = combined.transformPVCoordinates(new FieldPVCoordinates<>(1.0, pv0, -4 * h, directions[c]));
                FieldPVCoordinates<T> pvm3h = combined.transformPVCoordinates(new FieldPVCoordinates<>(1.0, pv0, -3 * h, directions[c]));
                FieldPVCoordinates<T> pvm2h = combined.transformPVCoordinates(new FieldPVCoordinates<>(1.0, pv0, -2 * h, directions[c]));
                FieldPVCoordinates<T> pvm1h = combined.transformPVCoordinates(new FieldPVCoordinates<>(1.0, pv0, -1 * h, directions[c]));
                FieldPVCoordinates<T> pvp1h = combined.transformPVCoordinates(new FieldPVCoordinates<>(1.0, pv0, +1 * h, directions[c]));
                FieldPVCoordinates<T> pvp2h = combined.transformPVCoordinates(new FieldPVCoordinates<>(1.0, pv0, +2 * h, directions[c]));
                FieldPVCoordinates<T> pvp3h = combined.transformPVCoordinates(new FieldPVCoordinates<>(1.0, pv0, +3 * h, directions[c]));
                FieldPVCoordinates<T> pvp4h = combined.transformPVCoordinates(new FieldPVCoordinates<>(1.0, pv0, +4 * h, directions[c]));
                FieldPVCoordinates<T> d4 = new FieldPVCoordinates<>(pvm4h, pvp4h);
                FieldPVCoordinates<T> d3 = new FieldPVCoordinates<>(pvm3h, pvp3h);
                FieldPVCoordinates<T> d2 = new FieldPVCoordinates<>(pvm2h, pvp2h);
                FieldPVCoordinates<T> d1 = new FieldPVCoordinates<>(pvm1h, pvp1h);
                double d = 1.0 / (840 * h);
                FieldPVCoordinates<T> estimatedColumn = new FieldPVCoordinates<>(-3 * d, d4, 32 * d, d3, -168 * d, d2, 672 * d, d1);
                // check analytical Jacobian against finite difference reference
                Assert.assertEquals(estimatedColumn.getPosition().getX().getReal(), jacobian[0][c].getReal(), epsilonP);
                Assert.assertEquals(estimatedColumn.getPosition().getY().getReal(), jacobian[1][c].getReal(), epsilonP);
                Assert.assertEquals(estimatedColumn.getPosition().getZ().getReal(), jacobian[2][c].getReal(), epsilonP);
                Assert.assertEquals(estimatedColumn.getVelocity().getX().getReal(), jacobian[3][c].getReal(), epsilonV);
                Assert.assertEquals(estimatedColumn.getVelocity().getY().getReal(), jacobian[4][c].getReal(), epsilonV);
                Assert.assertEquals(estimatedColumn.getVelocity().getZ().getReal(), jacobian[5][c].getReal(), epsilonV);
                Assert.assertEquals(estimatedColumn.getAcceleration().getX().getReal(), jacobian[6][c].getReal(), epsilonA);
                Assert.assertEquals(estimatedColumn.getAcceleration().getY().getReal(), jacobian[7][c].getReal(), epsilonA);
                Assert.assertEquals(estimatedColumn.getAcceleration().getZ().getReal(), jacobian[8][c].getReal(), epsilonA);
            }
        }
    }
}
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)100 Test (org.junit.Test)78 Well19937a (org.hipparchus.random.Well19937a)73 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)33 Well1024a (org.hipparchus.random.Well1024a)27 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)22 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)22 GeodeticPoint (org.orekit.bodies.GeodeticPoint)20 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)19 PVCoordinates (org.orekit.utils.PVCoordinates)15 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)15 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)14 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)14 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)14 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