use of org.hipparchus.random.RandomGenerator 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);
}
}
use of org.hipparchus.random.RandomGenerator 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);
}
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class AngularCoordinatesTest method testDerivativesStructures2.
@Test
public void testDerivativesStructures2() throws OrekitException {
RandomGenerator random = new Well1024a(0x1633878dddac047dl);
Rotation r = randomRotation(random);
Vector3D o = randomVector(random, 1.0e-2);
Vector3D oDot = randomVector(random, 1.0e-2);
AngularCoordinates ac = new AngularCoordinates(r, o, oDot);
AngularCoordinates rebuilt = new AngularCoordinates(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);
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class AngularCoordinatesTest 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);
AngularCoordinates ac = new AngularCoordinates(r, o);
AngularCoordinates 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.RandomGenerator in project Orekit by CS-SI.
the class AngularCoordinatesTest method testDerivativesStructures1.
@Test
public void testDerivativesStructures1() throws OrekitException {
RandomGenerator random = new Well1024a(0x8f8fc6d27bbdc46dl);
Rotation r = randomRotation(random);
Vector3D o = randomVector(random, 1.0e-2);
Vector3D oDot = randomVector(random, 1.0e-2);
AngularCoordinates ac = new AngularCoordinates(r, o, oDot);
AngularCoordinates rebuilt = new AngularCoordinates(ac.toDerivativeStructureRotation(1));
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, rebuilt.getRotationAcceleration().getNorm(), 1.0e-15);
}
Aggregations