use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class FieldAngularCoordinatesTest 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) {
FieldRotation<DerivativeStructure> rotation = randomRotation(random);
FieldVector3D<DerivativeStructure> rotationRate = randomVector(random, 0.01);
FieldVector3D<DerivativeStructure> rotationAcceleration = randomVector(random, 0.01);
FieldAngularCoordinates<DerivativeStructure> ac = new FieldAngularCoordinates<>(rotation, rotationRate, rotationAcceleration);
FieldAngularCoordinates<DerivativeStructure> rebuilt = FieldAngularCoordinates.createFromModifiedRodrigues(ac.getModifiedRodrigues(1.0));
Assert.assertEquals(0.0, FieldRotation.distance(rotation, rebuilt.getRotation()).getReal(), 1.0e-14);
Assert.assertEquals(0.0, FieldVector3D.distance(rotationRate, rebuilt.getRotationRate()).getReal(), 1.0e-15);
Assert.assertEquals(0.0, FieldVector3D.distance(rotationAcceleration, rebuilt.getRotationAcceleration()).getReal(), 1.0e-15);
}
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class FieldAngularCoordinatesTest method testRandomPVCoordinates.
@Test
public void testRandomPVCoordinates() throws OrekitException {
RandomGenerator generator = new Well1024a(0xf978035a328a565bl);
for (int i = 0; i < 100; ++i) {
FieldRotation<DerivativeStructure> r = randomRotation(generator);
FieldVector3D<DerivativeStructure> omega = randomVector(generator, 10 * generator.nextDouble() + 1.0);
FieldVector3D<DerivativeStructure> omegaDot = randomVector(generator, 0.1 * generator.nextDouble() + 0.01);
FieldAngularCoordinates<DerivativeStructure> ref = new FieldAngularCoordinates<>(r, omega, omegaDot);
FieldAngularCoordinates<DerivativeStructure> inv = ref.revert();
for (int j = 0; j < 100; ++j) {
FieldPVCoordinates<DerivativeStructure> v1 = randomPVCoordinates(generator, 1000, 1.0, 0.001);
FieldPVCoordinates<DerivativeStructure> v2 = randomPVCoordinates(generator, 1000, 1.0, 0.0010);
FieldPVCoordinates<DerivativeStructure> u1 = inv.applyTo(v1);
FieldPVCoordinates<DerivativeStructure> u2 = inv.applyTo(v2);
FieldAngularCoordinates<DerivativeStructure> rebuilt = new FieldAngularCoordinates<>(u1, u2, v1, v2, 1.0e-9);
Assert.assertEquals(0.0, FieldRotation.distance(r, rebuilt.getRotation()).getReal(), 6.0e-14);
Assert.assertEquals(0.0, FieldVector3D.distance(omega, rebuilt.getRotationRate()).getReal(), 3.0e-12 * omega.getNorm().getReal());
Assert.assertEquals(0.0, FieldVector3D.distance(omegaDot, rebuilt.getRotationAcceleration()).getReal(), 2.0e-6 * omegaDot.getNorm().getReal());
}
}
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class PVCoordinatesTest method testNormalize.
@Test
public void testNormalize() {
DSFactory factory = new DSFactory(1, 2);
RandomGenerator generator = new Well19937a(0xb2011ffd25412067l);
FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(5, 1.0e-3);
for (int i = 0; i < 200; ++i) {
final PVCoordinates 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();
}
}).value(factory.variable(0, 0.0));
DerivativeStructure y = differentiator.differentiate(new UnivariateFunction() {
public double value(double t) {
return pv.shiftedBy(t).getPosition().normalize().getY();
}
}).value(factory.variable(0, 0.0));
DerivativeStructure z = differentiator.differentiate(new UnivariateFunction() {
public double value(double t) {
return pv.shiftedBy(t).getPosition().normalize().getZ();
}
}).value(factory.variable(0, 0.0));
PVCoordinates normalized = pv.normalize();
Assert.assertEquals(x.getValue(), normalized.getPosition().getX(), 1.0e-16);
Assert.assertEquals(y.getValue(), normalized.getPosition().getY(), 1.0e-16);
Assert.assertEquals(z.getValue(), normalized.getPosition().getZ(), 1.0e-16);
Assert.assertEquals(x.getPartialDerivative(1), normalized.getVelocity().getX(), 3.0e-13);
Assert.assertEquals(y.getPartialDerivative(1), normalized.getVelocity().getY(), 3.0e-13);
Assert.assertEquals(z.getPartialDerivative(1), normalized.getVelocity().getZ(), 3.0e-13);
Assert.assertEquals(x.getPartialDerivative(2), normalized.getAcceleration().getX(), 6.0e-10);
Assert.assertEquals(y.getPartialDerivative(2), normalized.getAcceleration().getY(), 6.0e-10);
Assert.assertEquals(z.getPartialDerivative(2), normalized.getAcceleration().getZ(), 6.0e-10);
}
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class SecularAndHarmonicTest method testReset.
@Test
public void testReset() throws OrekitException {
// Period = 6 months
final double SUN_PULSATION = 4.0 * FastMath.PI / Constants.JULIAN_YEAR;
// Generate two random datasets
final RandomGenerator random = new Well19937a(0x8de2c5d0e210588dl);
final AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH;
final double[][] data = new double[2][200];
for (int iD = 0; iD < data[0].length; ++iD) {
data[0][iD] = random.nextDouble();
data[1][iD] = random.nextDouble();
}
// Generate three SAH models: the first two will fit each dataset
// independently, while the third parses one dataset and then the other
// after being reset. Fitted parameters should match in both cases.
final double[] initialGuess = { 0.0, 0.0, 0.0, 0.0 };
final SecularAndHarmonic[] indepModel = new SecularAndHarmonic[2];
final SecularAndHarmonic resettingModel = new SecularAndHarmonic(1, SUN_PULSATION);
for (int iM = 0; iM < indepModel.length; ++iM) {
indepModel[iM] = new SecularAndHarmonic(1, SUN_PULSATION);
indepModel[iM].resetFitting(t0, initialGuess);
resettingModel.resetFitting(t0, initialGuess);
for (int iD = 0; iD < data[0].length; ++iD) {
final AbsoluteDate t = t0.shiftedBy(iD);
indepModel[iM].addPoint(t, data[iM][iD]);
resettingModel.addPoint(t, data[iM][iD]);
}
indepModel[iM].fit();
resettingModel.fit();
Assert.assertArrayEquals(indepModel[iM].getFittedParameters(), resettingModel.getFittedParameters(), 1e-14);
}
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class TimeStampedAngularCoordinatesTest method testDerivativesStructures2.
@Test
public void testDerivativesStructures2() throws OrekitException {
RandomGenerator random = new Well1024a(0x75fbebbdbf127b3dl);
Rotation r = randomRotation(random);
Vector3D o = randomVector(random, 1.0e-2);
Vector3D oDot = randomVector(random, 1.0e-2);
TimeStampedAngularCoordinates ac = new TimeStampedAngularCoordinates(AbsoluteDate.J2000_EPOCH, r, o, oDot);
TimeStampedAngularCoordinates rebuilt = new TimeStampedAngularCoordinates(AbsoluteDate.J2000_EPOCH, 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);
}
Aggregations