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);
}
}
}
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);
}
}
}
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);
}
}
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);
}
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);
}
Aggregations