Search in sources :

Example 16 with Well1024a

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

the class EllipsoidTest method testLimb.

@Test
public void testLimb() throws OrekitException {
    final Ellipsoid ellipsoid = new Ellipsoid(FramesFactory.getEME2000(), 1, 2, 3);
    RandomGenerator random = new Well1024a(0xa69c430a67475af7l);
    for (int i = 0; i < 5000; ++i) {
        Vector3D observer = new Vector3D((random.nextDouble() - 0.5) * 5, (random.nextDouble() - 0.5) * 5, (random.nextDouble() - 0.5) * 5);
        Vector3D outside = new Vector3D((random.nextDouble() - 0.5) * 5, (random.nextDouble() - 0.5) * 5, (random.nextDouble() - 0.5) * 5);
        if (ellipsoid.isInside(observer)) {
            try {
                ellipsoid.pointOnLimb(observer, outside);
                Assert.fail("an exception should have been thrown");
            } catch (OrekitException oe) {
                Assert.assertEquals(OrekitMessages.POINT_INSIDE_ELLIPSOID, oe.getSpecifier());
            }
        } else {
            final Vector3D onLimb = ellipsoid.pointOnLimb(observer, outside);
            Assert.assertEquals(0, FastMath.sin(Vector3D.angle(Vector3D.crossProduct(observer, outside), Vector3D.crossProduct(observer, onLimb))), 2e-14);
            final double scaledX = onLimb.getX() / ellipsoid.getA();
            final double scaledY = onLimb.getY() / ellipsoid.getB();
            final double scaledZ = onLimb.getZ() / ellipsoid.getC();
            Assert.assertEquals(1.0, scaledX * scaledX + scaledY * scaledY + scaledZ * scaledZ, 9e-11);
            final Vector3D normal = new Vector3D(scaledX / ellipsoid.getA(), scaledY / ellipsoid.getB(), scaledZ / ellipsoid.getC()).normalize();
            final Vector3D lineOfSight = onLimb.subtract(observer).normalize();
            Assert.assertEquals(0.0, Vector3D.dotProduct(normal, lineOfSight), 5e-10);
        }
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) OrekitException(org.orekit.errors.OrekitException) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 17 with Well1024a

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

the class FieldOfViewTest method testSquare.

@Test
public void testSquare() throws OrekitException {
    FieldOfView square1 = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, 0.25, Vector3D.MINUS_J, 0.25, 0.0);
    FieldOfView square2 = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, 0.25, 4, 0.0);
    Assert.assertEquals(square1.getZone().getSize(), square2.getZone().getSize(), 1.0e-15);
    Assert.assertEquals(square1.getZone().getBoundarySize(), square2.getZone().getBoundarySize(), 1.0e-15);
    UnitSphereRandomVectorGenerator random = new UnitSphereRandomVectorGenerator(3, new Well1024a(0x17df21c7598b114bl));
    for (int i = 0; i < 1000; ++i) {
        Vector3D v = new Vector3D(random.nextVector()).scalarMultiply(1.0e6);
        Assert.assertEquals(square1.offsetFromBoundary(v), square2.offsetFromBoundary(v), 1.0e-15);
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnitSphereRandomVectorGenerator(org.hipparchus.random.UnitSphereRandomVectorGenerator) S2Point(org.hipparchus.geometry.spherical.twod.S2Point) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 18 with Well1024a

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

the class NutationCodecTest method testKeySymmetry.

@Test
public void testKeySymmetry() {
    RandomGenerator random = new Well1024a(0x8fef7f6f99ad5d56l);
    int[] multipliers = new int[15];
    for (int i = 0; i < 100000; ++i) {
        Arrays.fill(multipliers, 0);
        int nb = 1 + random.nextInt(7);
        for (int k = 0; k < nb; ++k) {
            int index = random.nextInt(15);
            while (multipliers[index] == 0) {
                multipliers[index] = random.nextInt(128) - 64;
            }
        }
        long key = NutationCodec.encode(multipliers);
        int[] rebuilt = NutationCodec.decode(key);
        for (int k = 0; k < multipliers.length; ++k) {
            Assert.assertEquals(multipliers[k], rebuilt[k]);
        }
    }
}
Also used : RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 19 with Well1024a

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

the class FieldAngularCoordinatesTest method testRandomInverseCrossProducts.

@Test
public void testRandomInverseCrossProducts() throws OrekitException {
    RandomGenerator generator = new Well1024a(0xda0ee5b245efd438l);
    for (int i = 0; i < 10000; ++i) {
        FieldVector3D<DerivativeStructure> omega = randomVector(generator, 10 * generator.nextDouble() + 1.0);
        FieldVector3D<DerivativeStructure> v1 = randomVector(generator, 10 * generator.nextDouble() + 1.0);
        FieldVector3D<DerivativeStructure> v2 = randomVector(generator, 10 * generator.nextDouble() + 1.0);
        checkInverse(omega, v1, v2);
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 20 with Well1024a

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

the class FieldAngularCoordinatesTest method testReverseOffset.

@Test
public void testReverseOffset() {
    RandomGenerator random = new Well1024a(0x4ecca9d57a8f1611l);
    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> ac = new FieldAngularCoordinates<>(r, o, a);
        FieldAngularCoordinates<DerivativeStructure> sum = ac.addOffset(ac.revert());
        Assert.assertEquals(0.0, sum.getRotation().getAngle().getReal(), 1.0e-15);
        Assert.assertEquals(0.0, sum.getRotationRate().getNorm().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)

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