Search in sources :

Example 1 with Well1024a

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

the class FieldAngularCoordinatesTest method testRoundTripNoOp.

@Test
public void testRoundTripNoOp() {
    RandomGenerator random = new Well1024a(0x1e610cfe89306669l);
    for (int i = 0; i < 100; ++i) {
        FieldRotation<DerivativeStructure> r1 = randomRotation(random);
        FieldVector3D<DerivativeStructure> o1 = randomVector(random, 1.0e-2);
        FieldVector3D<DerivativeStructure> a1 = randomVector(random, 1.0e-2);
        FieldAngularCoordinates<DerivativeStructure> ac1 = new FieldAngularCoordinates<>(r1, o1, a1);
        FieldRotation<DerivativeStructure> r2 = randomRotation(random);
        FieldVector3D<DerivativeStructure> o2 = randomVector(random, 1.0e-2);
        FieldVector3D<DerivativeStructure> a2 = randomVector(random, 1.0e-2);
        FieldAngularCoordinates<DerivativeStructure> ac2 = new FieldAngularCoordinates<>(r2, o2, a2);
        FieldAngularCoordinates<DerivativeStructure> roundTripSA = ac1.subtractOffset(ac2).addOffset(ac2);
        Assert.assertEquals(0.0, FieldRotation.distance(ac1.getRotation(), roundTripSA.getRotation()).getReal(), 1.0e-15);
        Assert.assertEquals(0.0, FieldVector3D.distance(ac1.getRotationRate(), roundTripSA.getRotationRate()).getReal(), 2.0e-17);
        Assert.assertEquals(0.0, FieldVector3D.distance(ac1.getRotationAcceleration(), roundTripSA.getRotationAcceleration()).getReal(), 2.0e-17);
        FieldAngularCoordinates<DerivativeStructure> roundTripAS = ac1.addOffset(ac2).subtractOffset(ac2);
        Assert.assertEquals(0.0, FieldRotation.distance(ac1.getRotation(), roundTripAS.getRotation()).getReal(), 1.0e-15);
        Assert.assertEquals(0.0, FieldVector3D.distance(ac1.getRotationRate(), roundTripAS.getRotationRate()).getReal(), 2.0e-17);
        Assert.assertEquals(0.0, FieldVector3D.distance(ac1.getRotationAcceleration(), roundTripAS.getRotationAcceleration()).getReal(), 2.0e-17);
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 2 with Well1024a

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

the class FieldAngularCoordinatesTest method testRodriguesSpecialCases.

@Test
public void testRodriguesSpecialCases() {
    // identity
    DerivativeStructure[][] identity = FieldAngularCoordinates.getIdentity(new DSFactory(2, 2).getDerivativeField()).getModifiedRodrigues(1.0);
    for (DerivativeStructure[] row : identity) {
        for (DerivativeStructure element : row) {
            Assert.assertEquals(0.0, element.getReal(), Precision.SAFE_MIN);
        }
    }
    FieldAngularCoordinates<DerivativeStructure> acId = FieldAngularCoordinates.createFromModifiedRodrigues(identity);
    Assert.assertEquals(0.0, acId.getRotation().getAngle().getReal(), Precision.SAFE_MIN);
    Assert.assertEquals(0.0, acId.getRotationRate().getNorm().getReal(), Precision.SAFE_MIN);
    // PI angle rotation (which is singular for non-modified Rodrigues vector)
    RandomGenerator random = new Well1024a(0x4923ec495bca9fb4l);
    for (int i = 0; i < 100; ++i) {
        FieldVector3D<DerivativeStructure> axis = randomVector(random, 1.0);
        final Field<DerivativeStructure> field = axis.getX().getField();
        FieldAngularCoordinates<DerivativeStructure> original = new FieldAngularCoordinates<>(new FieldRotation<>(axis, field.getZero().add(FastMath.PI), RotationConvention.VECTOR_OPERATOR), FieldVector3D.getZero(field), FieldVector3D.getZero(field));
        FieldAngularCoordinates<DerivativeStructure> rebuilt = FieldAngularCoordinates.createFromModifiedRodrigues(original.getModifiedRodrigues(1.0));
        Assert.assertEquals(FastMath.PI, rebuilt.getRotation().getAngle().getReal(), 1.0e-15);
        Assert.assertEquals(0.0, FieldVector3D.angle(axis, rebuilt.getRotation().getAxis(RotationConvention.VECTOR_OPERATOR)).sin().getReal(), 1.0e-15);
        Assert.assertEquals(0.0, rebuilt.getRotationRate().getNorm().getReal(), 1.0e-16);
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 3 with Well1024a

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

the class FieldAngularCoordinatesTest method testToAC.

@Test
public void testToAC() {
    RandomGenerator random = new Well1024a(0xc9b4cf6c371108e0l);
    for (int i = 0; i < 100; ++i) {
        FieldRotation<DerivativeStructure> r = randomRotation(random);
        FieldVector3D<DerivativeStructure> o = randomVector(random, 1.0e-3);
        FieldVector3D<DerivativeStructure> a = randomVector(random, 1.0e-3);
        FieldAngularCoordinates<DerivativeStructure> acds = new FieldAngularCoordinates<>(r, o, a);
        AngularCoordinates ac = acds.toAngularCoordinates();
        Assert.assertEquals(0, Rotation.distance(r.toRotation(), ac.getRotation()), 1.0e-15);
        Assert.assertEquals(0, FieldVector3D.distance(o, ac.getRotationRate()).getReal(), 1.0e-15);
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 4 with Well1024a

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

the class FieldAngularCoordinatesTest method testApplyTo.

@Test
public void testApplyTo() {
    RandomGenerator random = new Well1024a(0xbad5894f4c475905l);
    for (int i = 0; i < 1000; ++i) {
        FieldRotation<DerivativeStructure> rotation = randomRotation(random);
        FieldVector3D<DerivativeStructure> rotationRate = randomVector(random, 0.01);
        FieldVector3D<DerivativeStructure> rotationAcceleration = randomVector(random, 0.01);
        FieldAngularCoordinates<DerivativeStructure> ac = new FieldAngularCoordinates<>(rotation, rotationRate, rotationAcceleration);
        FieldVector3D<DerivativeStructure> p = randomVector(random, 10.0);
        FieldVector3D<DerivativeStructure> v = randomVector(random, 10.0);
        FieldVector3D<DerivativeStructure> a = randomVector(random, 10.0);
        FieldPVCoordinates<DerivativeStructure> pv = new FieldPVCoordinates<>(p, v, a);
        PVCoordinates reference = ac.toAngularCoordinates().applyTo(pv.toPVCoordinates());
        FieldPVCoordinates<DerivativeStructure> res1 = ac.applyTo(pv.toPVCoordinates());
        Assert.assertEquals(0.0, Vector3D.distance(reference.getPosition(), res1.getPosition().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getVelocity(), res1.getVelocity().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getAcceleration(), res1.getAcceleration().toVector3D()), 1.0e-15);
        FieldPVCoordinates<DerivativeStructure> res2 = ac.applyTo(pv);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getPosition(), res2.getPosition().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getVelocity(), res2.getVelocity().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getAcceleration(), res2.getAcceleration().toVector3D()), 1.0e-15);
        TimeStampedFieldPVCoordinates<DerivativeStructure> res3 = ac.applyTo(new TimeStampedFieldPVCoordinates<>(AbsoluteDate.J2000_EPOCH, pv));
        Assert.assertEquals(0.0, AbsoluteDate.J2000_EPOCH.durationFrom(res3.getDate().toAbsoluteDate()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getPosition(), res3.getPosition().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getVelocity(), res3.getVelocity().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getAcceleration(), res3.getAcceleration().toVector3D()), 1.0e-15);
        TimeStampedFieldPVCoordinates<DerivativeStructure> res4 = ac.applyTo(new TimeStampedPVCoordinates(AbsoluteDate.J2000_EPOCH, pv.toPVCoordinates()));
        Assert.assertEquals(0.0, AbsoluteDate.J2000_EPOCH.durationFrom(res4.getDate().toAbsoluteDate()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getPosition(), res4.getPosition().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getVelocity(), res4.getVelocity().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(reference.getAcceleration(), res4.getAcceleration().toVector3D()), 1.0e-15);
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 5 with Well1024a

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

the class FieldAngularCoordinatesTest method testRodriguesVsDouble.

@Test
public void testRodriguesVsDouble() {
    RandomGenerator random = new Well1024a(0x4beeee3d8d2abacal);
    for (int i = 0; i < 1000; ++i) {
        FieldRotation<DerivativeStructure> rotation = randomRotation(random);
        FieldVector3D<DerivativeStructure> rotationRate = randomVector(random, 0.01);
        FieldVector3D<DerivativeStructure> rotationAcceleration = randomVector(random, 0.01);
        FieldAngularCoordinates<DerivativeStructure> ac = new FieldAngularCoordinates<>(rotation, rotationRate, rotationAcceleration);
        DerivativeStructure[][] rod = ac.getModifiedRodrigues(1.0);
        double[][] rodRef = ac.toAngularCoordinates().getModifiedRodrigues(1.0);
        Assert.assertEquals(rodRef.length, rod.length);
        for (int k = 0; k < rodRef.length; ++k) {
            Assert.assertEquals(rodRef[k].length, rod[k].length);
            for (int l = 0; l < rodRef[k].length; ++l) {
                Assert.assertEquals(rodRef[k][l], rod[k][l].getReal(), 1.0e-15 * FastMath.abs(rodRef[k][l]));
            }
        }
        FieldAngularCoordinates<DerivativeStructure> rebuilt = FieldAngularCoordinates.createFromModifiedRodrigues(rod);
        AngularCoordinates rebuiltRef = AngularCoordinates.createFromModifiedRodrigues(rodRef);
        Assert.assertEquals(0.0, Rotation.distance(rebuiltRef.getRotation(), rebuilt.getRotation().toRotation()), 1.0e-14);
        Assert.assertEquals(0.0, Vector3D.distance(rebuiltRef.getRotationRate(), rebuilt.getRotationRate().toVector3D()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(rebuiltRef.getRotationAcceleration(), rebuilt.getRotationAcceleration().toVector3D()), 1.0e-15);
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Aggregations

Well1024a (org.hipparchus.random.Well1024a)28 Test (org.junit.Test)28 RandomGenerator (org.hipparchus.random.RandomGenerator)27 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)17 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)13 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)9 GeodeticPoint (org.orekit.bodies.GeodeticPoint)2 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)1 S2Point (org.hipparchus.geometry.spherical.twod.S2Point)1 UnitSphereRandomVectorGenerator (org.hipparchus.random.UnitSphereRandomVectorGenerator)1 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)1 OrekitException (org.orekit.errors.OrekitException)1 AbsoluteDate (org.orekit.time.AbsoluteDate)1