Search in sources :

Example 71 with Well19937a

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

the class TransformProviderUtilTest method testCombine.

@Test
public void testCombine() throws OrekitException {
    RandomGenerator random = new Well19937a(0x6e3b2c793680e7e3l);
    final AbsoluteDate date = 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 Transform(date, new Transform(date, first.getTransform(date), second.getTransform(date)).getInverse(), combined.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 72 with Well19937a

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

the class PVCoordinatesTest method testCrossProduct.

@Test
public void testCrossProduct() {
    DSFactory factory = new DSFactory(1, 2);
    RandomGenerator generator = new Well19937a(0x85c592b3be733d23l);
    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(5, 1.0e-3);
    for (int i = 0; i < 200; ++i) {
        final PVCoordinates pv1 = randomPVCoordinates(generator, 1.0, 1.0, 1.0);
        final PVCoordinates pv2 = randomPVCoordinates(generator, 1.0, 1.0, 1.0);
        DerivativeStructure x = differentiator.differentiate(new UnivariateFunction() {

            public double value(double t) {
                return Vector3D.crossProduct(pv1.shiftedBy(t).getPosition(), pv2.shiftedBy(t).getPosition()).getX();
            }
        }).value(factory.variable(0, 0.0));
        DerivativeStructure y = differentiator.differentiate(new UnivariateFunction() {

            public double value(double t) {
                return Vector3D.crossProduct(pv1.shiftedBy(t).getPosition(), pv2.shiftedBy(t).getPosition()).getY();
            }
        }).value(factory.variable(0, 0.0));
        DerivativeStructure z = differentiator.differentiate(new UnivariateFunction() {

            public double value(double t) {
                return Vector3D.crossProduct(pv1.shiftedBy(t).getPosition(), pv2.shiftedBy(t).getPosition()).getZ();
            }
        }).value(factory.variable(0, 0.0));
        PVCoordinates product = PVCoordinates.crossProduct(pv1, pv2);
        Assert.assertEquals(x.getValue(), product.getPosition().getX(), 1.0e-16);
        Assert.assertEquals(y.getValue(), product.getPosition().getY(), 1.0e-16);
        Assert.assertEquals(z.getValue(), product.getPosition().getZ(), 1.0e-16);
        Assert.assertEquals(x.getPartialDerivative(1), product.getVelocity().getX(), 9.0e-10);
        Assert.assertEquals(y.getPartialDerivative(1), product.getVelocity().getY(), 9.0e-10);
        Assert.assertEquals(z.getPartialDerivative(1), product.getVelocity().getZ(), 9.0e-10);
        Assert.assertEquals(x.getPartialDerivative(2), product.getAcceleration().getX(), 3.0e-9);
        Assert.assertEquals(y.getPartialDerivative(2), product.getAcceleration().getY(), 3.0e-9);
        Assert.assertEquals(z.getPartialDerivative(2), product.getAcceleration().getZ(), 3.0e-9);
    }
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) 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 73 with Well19937a

use of org.hipparchus.random.Well19937a 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)

Aggregations

RandomGenerator (org.hipparchus.random.RandomGenerator)73 Well19937a (org.hipparchus.random.Well19937a)73 Test (org.junit.Test)51 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)22 GeodeticPoint (org.orekit.bodies.GeodeticPoint)19 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)17 PVCoordinates (org.orekit.utils.PVCoordinates)15 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)15 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)14 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)14 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)13 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)13 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 SpacecraftState (org.orekit.propagation.SpacecraftState)8 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)8