Search in sources :

Example 96 with RandomGenerator

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

the class FieldPVCoordinatesTest method testNormalize.

@Test
public void testNormalize() {
    DSFactory factory = new DSFactory(1, 2);
    RandomGenerator generator = new Well19937a(0x7ede9376e4e1ab5al);
    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(5, 1.0e-3);
    for (int i = 0; i < 200; ++i) {
        final FieldPVCoordinates<DerivativeStructure> pv = randomPVCoordinates(generator, 1e6, 1e3, 1.0);
        DerivativeStructure x = differentiator.differentiate(new UnivariateFunction() {

            public double value(double t) {
                return pv.shiftedBy(t).getPosition().normalize().getX().getValue();
            }
        }).value(factory.variable(0, 0.0));
        DerivativeStructure y = differentiator.differentiate(new UnivariateFunction() {

            public double value(double t) {
                return pv.shiftedBy(t).getPosition().normalize().getY().getValue();
            }
        }).value(factory.variable(0, 0.0));
        DerivativeStructure z = differentiator.differentiate(new UnivariateFunction() {

            public double value(double t) {
                return pv.shiftedBy(t).getPosition().normalize().getZ().getValue();
            }
        }).value(factory.variable(0, 0.0));
        FieldPVCoordinates<DerivativeStructure> normalized = pv.normalize();
        Assert.assertEquals(x.getValue(), normalized.getPosition().getX().getValue(), 1.0e-16);
        Assert.assertEquals(y.getValue(), normalized.getPosition().getY().getValue(), 1.0e-16);
        Assert.assertEquals(z.getValue(), normalized.getPosition().getZ().getValue(), 1.0e-16);
        Assert.assertEquals(x.getPartialDerivative(1), normalized.getVelocity().getX().getValue(), 3.0e-13);
        Assert.assertEquals(y.getPartialDerivative(1), normalized.getVelocity().getY().getValue(), 3.0e-13);
        Assert.assertEquals(z.getPartialDerivative(1), normalized.getVelocity().getZ().getValue(), 3.0e-13);
        Assert.assertEquals(x.getPartialDerivative(2), normalized.getAcceleration().getX().getValue(), 6.0e-10);
        Assert.assertEquals(y.getPartialDerivative(2), normalized.getAcceleration().getY().getValue(), 6.0e-10);
        Assert.assertEquals(z.getPartialDerivative(2), normalized.getAcceleration().getZ().getValue(), 6.0e-10);
    }
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) FieldDerivativeStructure(org.hipparchus.analysis.differentiation.FieldDerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) Test(org.junit.Test)

Example 97 with RandomGenerator

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

the class AngularCoordinatesTest method testRodriguesSymmetry.

@Test
public void testRodriguesSymmetry() {
    // check the two-way conversion result in identity
    RandomGenerator random = new Well1024a(0xb1e615aaa8236b52l);
    for (int i = 0; i < 1000; ++i) {
        Rotation rotation = randomRotation(random);
        Vector3D rotationRate = randomVector(random, 0.01);
        Vector3D rotationAcceleration = randomVector(random, 0.01);
        AngularCoordinates ac = new AngularCoordinates(rotation, rotationRate, rotationAcceleration);
        AngularCoordinates rebuilt = AngularCoordinates.createFromModifiedRodrigues(ac.getModifiedRodrigues(1.0));
        Assert.assertEquals(0.0, Rotation.distance(rotation, rebuilt.getRotation()), 1.0e-14);
        Assert.assertEquals(0.0, Vector3D.distance(rotationRate, rebuilt.getRotationRate()), 1.0e-15);
        Assert.assertEquals(0.0, Vector3D.distance(rotationAcceleration, rebuilt.getRotationAcceleration()), 1.0e-15);
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 98 with RandomGenerator

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

the class AngularCoordinatesTest method testDerivativesStructures2.

@Test
public void testDerivativesStructures2() throws OrekitException {
    RandomGenerator random = new Well1024a(0x1633878dddac047dl);
    Rotation r = randomRotation(random);
    Vector3D o = randomVector(random, 1.0e-2);
    Vector3D oDot = randomVector(random, 1.0e-2);
    AngularCoordinates ac = new AngularCoordinates(r, o, oDot);
    AngularCoordinates rebuilt = new AngularCoordinates(ac.toDerivativeStructureRotation(2));
    Assert.assertEquals(0.0, Rotation.distance(ac.getRotation(), rebuilt.getRotation()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(ac.getRotationRate(), rebuilt.getRotationRate()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(ac.getRotationAcceleration(), rebuilt.getRotationAcceleration()), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 99 with RandomGenerator

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

the class AngularCoordinatesTest method testReverseOffset.

@Test
public void testReverseOffset() {
    RandomGenerator random = new Well1024a(0x4ecca9d57a8f1611l);
    for (int i = 0; i < 100; ++i) {
        Rotation r = randomRotation(random);
        Vector3D o = randomVector(random, 1.0e-3);
        AngularCoordinates ac = new AngularCoordinates(r, o);
        AngularCoordinates sum = ac.addOffset(ac.revert());
        Assert.assertEquals(0.0, sum.getRotation().getAngle(), 1.0e-15);
        Assert.assertEquals(0.0, sum.getRotationRate().getNorm(), 1.0e-15);
        Assert.assertEquals(0.0, sum.getRotationAcceleration().getNorm(), 1.0e-15);
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 100 with RandomGenerator

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

the class AngularCoordinatesTest method testDerivativesStructures1.

@Test
public void testDerivativesStructures1() throws OrekitException {
    RandomGenerator random = new Well1024a(0x8f8fc6d27bbdc46dl);
    Rotation r = randomRotation(random);
    Vector3D o = randomVector(random, 1.0e-2);
    Vector3D oDot = randomVector(random, 1.0e-2);
    AngularCoordinates ac = new AngularCoordinates(r, o, oDot);
    AngularCoordinates rebuilt = new AngularCoordinates(ac.toDerivativeStructureRotation(1));
    Assert.assertEquals(0.0, Rotation.distance(ac.getRotation(), rebuilt.getRotation()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(ac.getRotationRate(), rebuilt.getRotationRate()), 1.0e-15);
    Assert.assertEquals(0.0, rebuilt.getRotationAcceleration().getNorm(), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) 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