Search in sources :

Example 31 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class TransformTest method testRandomComposition.

@Test
public void testRandomComposition() {
    RandomGenerator random = new Well19937a(0x171c79e323a1123l);
    for (int i = 0; i < 20; ++i) {
        // build a complex transform by composing primitive ones
        int n = random.nextInt(20);
        Transform[] transforms = new Transform[n];
        Transform combined = Transform.IDENTITY;
        for (int k = 0; k < n; ++k) {
            transforms[k] = random.nextBoolean() ? new Transform(AbsoluteDate.J2000_EPOCH, randomVector(1.0e3, random), randomVector(1.0, random), randomVector(1.0e-3, random)) : new Transform(AbsoluteDate.J2000_EPOCH, randomRotation(random), randomVector(0.01, random), randomVector(1.0e-4, random));
            combined = new Transform(AbsoluteDate.J2000_EPOCH, combined, transforms[k]);
        }
        // check the composition
        for (int j = 0; j < 10; ++j) {
            Vector3D a = randomVector(1.0, random);
            FieldVector3D<Decimal64> aF = new FieldVector3D<>(Decimal64Field.getInstance(), a);
            Vector3D b = randomVector(1.0e3, random);
            PVCoordinates c = new PVCoordinates(randomVector(1.0e3, random), randomVector(1.0, random), randomVector(1.0e-3, random));
            Vector3D aRef = a;
            FieldVector3D<Decimal64> aFRef = aF;
            Vector3D bRef = b;
            PVCoordinates cRef = c;
            for (int k = 0; k < n; ++k) {
                aRef = transforms[k].transformVector(aRef);
                aFRef = transforms[k].transformVector(aFRef);
                bRef = transforms[k].transformPosition(bRef);
                cRef = transforms[k].transformPVCoordinates(cRef);
            }
            Vector3D aCombined = combined.transformVector(a);
            FieldVector3D<Decimal64> aFCombined = combined.transformVector(aF);
            Vector3D bCombined = combined.transformPosition(b);
            PVCoordinates cCombined = combined.transformPVCoordinates(c);
            checkVector(aRef, aCombined, 3.0e-15);
            checkVector(aFRef.toVector3D(), aFCombined.toVector3D(), 3.0e-15);
            checkVector(bRef, bCombined, 5.0e-15);
            checkVector(cRef.getPosition(), cCombined.getPosition(), 1.0e-14);
            checkVector(cRef.getVelocity(), cCombined.getVelocity(), 1.0e-14);
            checkVector(cRef.getAcceleration(), cCombined.getAcceleration(), 1.0e-14);
        }
    }
}
Also used : FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) 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) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) RandomGenerator(org.hipparchus.random.RandomGenerator) Test(org.junit.Test)

Example 32 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class EOPHistoryTest method testFieldUTCLeap.

@Test
public void testFieldUTCLeap() throws OrekitException {
    EOPHistory history = FramesFactory.getEOPHistory(IERSConventions.IERS_2010, true);
    FieldAbsoluteDate<Decimal64> endLeap = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), 2006, 1, 1, TimeScalesFactory.getUTC());
    for (double dt = -200; dt < 200; dt += 3) {
        final FieldAbsoluteDate<Decimal64> date = endLeap.shiftedBy(dt);
        Decimal64 dtu1 = history.getUT1MinusUTC(date);
        if (dt <= 0) {
            Assert.assertEquals(-0.6612, dtu1.getReal(), 3.0e-5);
        } else {
            Assert.assertEquals(0.3388, dtu1.getReal(), 3.0e-5);
        }
    }
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) Test(org.junit.Test)

Example 33 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class TransformProviderUtilTest method testReverseField.

@Test
public void testReverseField() throws OrekitException {
    RandomGenerator random = new Well19937a(0xd74443b3079403e7l);
    final FieldAbsoluteDate<Decimal64> date = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), AbsoluteDate.J2000_EPOCH);
    for (int i = 0; i < 20; ++i) {
        TransformProvider tp = constantProvider(random);
        TransformProvider reversed = TransformProviderUtils.getReversedProvider(tp);
        checkNoTransform(new FieldTransform<>(date, tp.getTransform(date), reversed.getTransform(date)), random);
        checkNoTransform(new FieldTransform<>(date, reversed.getTransform(date), tp.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)

Example 34 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class IERSConventionsTest method checkFieldGMSTRate.

private void checkFieldGMSTRate(final TimeScalarFunction gmst, final TimeScalarFunction gmstRate, final AbsoluteDate date, final double span, final double sampleStep, final double h, final double tolerance) throws OrekitException {
    double maxError = 0;
    for (double dt = 0; dt < span; dt += sampleStep) {
        double rateDouble = gmstRate.value(date.shiftedBy(dt));
        double rateDecimal64 = gmstRate.value(new FieldAbsoluteDate<>(date, new Decimal64(dt))).doubleValue();
        maxError = FastMath.max(maxError, FastMath.abs(rateDouble - rateDecimal64));
    }
    Assert.assertEquals(0, maxError, tolerance);
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 35 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class FieldPVCoordinatesTest method testConversionConstructor.

@Test
public void testConversionConstructor() {
    PVCoordinates pv = new PVCoordinates(new Vector3D(1, 2, 3), new Vector3D(4, 5, 6), new Vector3D(7, 8, 9));
    FieldPVCoordinates<Decimal64> pv64 = new FieldPVCoordinates<>(Decimal64Field.getInstance(), pv);
    Assert.assertEquals(0.0, Vector3D.distance(pv.getPosition(), pv64.getPosition().toVector3D()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(pv.getVelocity(), pv64.getVelocity().toVector3D()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(pv.getAcceleration(), pv64.getAcceleration().toVector3D()), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Decimal64(org.hipparchus.util.Decimal64) Test(org.junit.Test)

Aggregations

Decimal64 (org.hipparchus.util.Decimal64)41 Test (org.junit.Test)37 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)21 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)18 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)12 FieldDerivativeStructure (org.hipparchus.analysis.differentiation.FieldDerivativeStructure)10 AbsoluteDate (org.orekit.time.AbsoluteDate)9 RandomGenerator (org.hipparchus.random.RandomGenerator)5 Well19937a (org.hipparchus.random.Well19937a)5 GeodeticPoint (org.orekit.bodies.GeodeticPoint)4 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)4 Frame (org.orekit.frames.Frame)4 FieldCartesianOrbit (org.orekit.orbits.FieldCartesianOrbit)3 TimeScale (org.orekit.time.TimeScale)3 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)3 PVCoordinates (org.orekit.utils.PVCoordinates)3 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)3 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)2 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)2 CelestialBody (org.orekit.bodies.CelestialBody)2