use of org.hipparchus.random.Well1024a in project Orekit by CS-SI.
the class TimeStampedAngularCoordinatesTest method testOnePair.
@Test
public void testOnePair() throws OrekitException, java.io.IOException {
RandomGenerator random = new Well1024a(0xed7dd911a44c5197l);
for (int i = 0; i < 20; ++i) {
Rotation r = randomRotation(random);
Vector3D o = randomVector(random, 1.0e-2);
Vector3D a = randomVector(random, 1.0e-2);
TimeStampedAngularCoordinates reference = new TimeStampedAngularCoordinates(AbsoluteDate.J2000_EPOCH, r, o, a);
PVCoordinates u = randomPVCoordinates(random, 1000, 1.0, 0.001);
PVCoordinates v = reference.applyTo(u);
TimeStampedAngularCoordinates ac = new TimeStampedAngularCoordinates(AbsoluteDate.J2000_EPOCH, u, v);
Assert.assertEquals(0, Vector3D.distance(v.getPosition().normalize(), ac.applyTo(u).getPosition().normalize()), 1.0e-14);
Assert.assertEquals(0, Vector3D.distance(v.getVelocity().normalize(), ac.applyTo(u).getVelocity().normalize()), 4.0e-14);
Assert.assertEquals(0, Vector3D.distance(v.getAcceleration().normalize(), ac.applyTo(u).getAcceleration().normalize()), 1.0e-14);
}
}
use of org.hipparchus.random.Well1024a in project Orekit by CS-SI.
the class TimeStampedAngularCoordinatesTest method testTwoPairs.
@Test
public void testTwoPairs() throws OrekitException, java.io.IOException {
RandomGenerator random = new Well1024a(0x976ad943966c9f00l);
for (int i = 0; i < 20; ++i) {
Rotation r = randomRotation(random);
Vector3D o = randomVector(random, 1.0e-2);
Vector3D a = randomVector(random, 1.0e-2);
TimeStampedAngularCoordinates reference = new TimeStampedAngularCoordinates(AbsoluteDate.J2000_EPOCH, r, o, a);
PVCoordinates u1 = randomPVCoordinates(random, 1000, 1.0, 0.001);
PVCoordinates u2 = randomPVCoordinates(random, 1000, 1.0, 0.001);
PVCoordinates v1 = reference.applyTo(u1);
PVCoordinates v2 = reference.applyTo(u2);
TimeStampedAngularCoordinates ac = new TimeStampedAngularCoordinates(AbsoluteDate.J2000_EPOCH, u1, u2, v1, v2, 1.0e-9);
Assert.assertEquals(0, Vector3D.distance(v1.getPosition().normalize(), ac.applyTo(u1).getPosition().normalize()), 1.0e-14);
Assert.assertEquals(0, Vector3D.distance(v1.getVelocity().normalize(), ac.applyTo(u1).getVelocity().normalize()), 1.0e-14);
Assert.assertEquals(0, Vector3D.distance(v1.getAcceleration().normalize(), ac.applyTo(u1).getAcceleration().normalize()), 1.0e-14);
Assert.assertEquals(0, Vector3D.distance(v2.getPosition().normalize(), ac.applyTo(u2).getPosition().normalize()), 1.0e-14);
Assert.assertEquals(0, Vector3D.distance(v2.getVelocity().normalize(), ac.applyTo(u2).getVelocity().normalize()), 1.0e-14);
Assert.assertEquals(0, Vector3D.distance(v2.getAcceleration().normalize(), ac.applyTo(u2).getAcceleration().normalize()), 1.0e-14);
}
}
use of org.hipparchus.random.Well1024a in project Orekit by CS-SI.
the class TimeStampedAngularCoordinatesTest 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);
Vector3D a = randomVector(random, 1.0e-3);
TimeStampedAngularCoordinates ac = new TimeStampedAngularCoordinates(AbsoluteDate.J2000_EPOCH, r, o, a);
TimeStampedAngularCoordinates 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);
}
}
use of org.hipparchus.random.Well1024a in project Orekit by CS-SI.
the class UTCScaleTest method testMultithreading.
@Test
public void testMultithreading() {
// generate reference offsets using a single thread
RandomGenerator random = new Well1024a(6392073424l);
List<AbsoluteDate> datesList = new ArrayList<AbsoluteDate>();
List<Double> offsetsList = new ArrayList<Double>();
AbsoluteDate reference = utc.getFirstKnownLeapSecond().shiftedBy(-Constants.JULIAN_YEAR);
double testRange = utc.getLastKnownLeapSecond().durationFrom(reference) + Constants.JULIAN_YEAR;
for (int i = 0; i < 10000; ++i) {
AbsoluteDate randomDate = reference.shiftedBy(random.nextDouble() * testRange);
datesList.add(randomDate);
offsetsList.add(utc.offsetFromTAI(randomDate));
}
// check the offsets in multi-threaded mode
ExecutorService executorService = Executors.newFixedThreadPool(100);
for (int i = 0; i < datesList.size(); ++i) {
final AbsoluteDate date = datesList.get(i);
final double offset = offsetsList.get(i);
executorService.execute(new Runnable() {
public void run() {
Assert.assertEquals(offset, utc.offsetFromTAI(date), 1.0e-12);
}
});
}
try {
executorService.shutdown();
executorService.awaitTermination(3, TimeUnit.SECONDS);
} catch (InterruptedException ie) {
Assert.fail(ie.getLocalizedMessage());
}
}
use of org.hipparchus.random.Well1024a 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);
}
}
Aggregations