Search in sources :

Example 36 with RandomGenerator

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

the class TransformTest method testLine.

@Test
public void testLine() {
    RandomGenerator random = new Well19937a(0x4a5ff67426c5731fl);
    for (int i = 0; i < 100; ++i) {
        Transform transform = randomTransform(random);
        for (int j = 0; j < 20; ++j) {
            Vector3D p0 = randomVector(1.0e3, random);
            Vector3D p1 = randomVector(1.0e3, random);
            Line l = new Line(p0, p1, 1.0e-10);
            Line 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)), 1.0e-9);
            }
        }
    }
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) Test(org.junit.Test)

Example 37 with RandomGenerator

use of org.hipparchus.random.RandomGenerator 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 38 with RandomGenerator

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

the class TransformTest method testAccelerationComposition.

@Test
public void testAccelerationComposition() {
    RandomGenerator random = new Well19937a(0x41fdd07d6c9e9f65l);
    Vector3D p1 = randomVector(1.0e3, random);
    Vector3D v1 = randomVector(1.0, random);
    Vector3D a1 = randomVector(1.0e-3, random);
    Rotation r1 = randomRotation(random);
    Vector3D o1 = randomVector(0.1, random);
    Vector3D p2 = randomVector(1.0e3, random);
    Vector3D v2 = randomVector(1.0, random);
    Vector3D a2 = randomVector(1.0e-3, random);
    Rotation r2 = randomRotation(random);
    Vector3D o2 = randomVector(0.1, random);
    Transform t1 = new Transform(AbsoluteDate.J2000_EPOCH, new Transform(AbsoluteDate.J2000_EPOCH, p1, v1, a1), new Transform(AbsoluteDate.J2000_EPOCH, r1, o1));
    Transform t2 = new Transform(AbsoluteDate.J2000_EPOCH, new Transform(AbsoluteDate.J2000_EPOCH, p2, v2, a2), new Transform(AbsoluteDate.J2000_EPOCH, r2, o2));
    Transform t12 = new Transform(AbsoluteDate.J2000_EPOCH, t1, t2);
    Vector3D q = randomVector(1.0e3, random);
    Vector3D qDot = randomVector(1.0, random);
    Vector3D qDotDot = randomVector(1.0e-3, random);
    PVCoordinates pva0 = new PVCoordinates(q, qDot, qDotDot);
    PVCoordinates pva1 = t1.transformPVCoordinates(pva0);
    PVCoordinates pva2 = t2.transformPVCoordinates(pva1);
    PVCoordinates 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(), 1.0e-15);
    Assert.assertEquals(0.0, t2.getAngular().getRotationAcceleration().getNorm(), 1.0e-15);
    Assert.assertTrue(t12.getAngular().getRotationAcceleration().getNorm() > 0.01);
    Assert.assertEquals(0.0, t12.freeze().getCartesian().getVelocity().getNorm(), 1.0e-15);
    Assert.assertEquals(0.0, t12.freeze().getCartesian().getAcceleration().getNorm(), 1.0e-15);
    Assert.assertEquals(0.0, t12.freeze().getAngular().getRotationRate().getNorm(), 1.0e-15);
    Assert.assertEquals(0.0, t12.freeze().getAngular().getRotationAcceleration().getNorm(), 1.0e-15);
}
Also used : FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) 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) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) RandomGenerator(org.hipparchus.random.RandomGenerator) Test(org.junit.Test)

Example 39 with RandomGenerator

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

the class TransformProviderUtilTest method testReverse.

@Test
public void testReverse() throws OrekitException {
    RandomGenerator random = new Well19937a(0xba49d4909717ec6cl);
    final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    for (int i = 0; i < 20; ++i) {
        TransformProvider tp = constantProvider(random);
        TransformProvider reversed = TransformProviderUtils.getReversedProvider(tp);
        checkNoTransform(new Transform(date, tp.getTransform(date), reversed.getTransform(date)), random);
        checkNoTransform(new Transform(date, reversed.getTransform(date), tp.getTransform(date)), random);
    }
}
Also used : Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 40 with RandomGenerator

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

the class TransformProviderUtilTest method testCombineField.

@Test
public void testCombineField() throws OrekitException {
    RandomGenerator random = new Well19937a(0x1f8bf20bfa4b54eal);
    final FieldAbsoluteDate<Decimal64> date = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), AbsoluteDate.J2000_EPOCH);
    for (int i = 0; i < 20; ++i) {
        TransformProvider first = constantProvider(random);
        TransformProvider second = constantProvider(random);
        TransformProvider combined = TransformProviderUtils.getCombinedProvider(first, second);
        checkNoTransform(new FieldTransform<>(date, new FieldTransform<>(date, first.getTransform(date), second.getTransform(date)).getInverse(), combined.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)

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