use of org.hipparchus.random.Well19937a in project Orekit by CS-SI.
the class TransformTest method testRotPV.
@Test
public void testRotPV() {
RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);
for (int i = 0; i < 10; ++i) {
// Random instant rotation
Rotation instantRot = randomRotation(rnd);
Vector3D normAxis = instantRot.getAxis(RotationConvention.VECTOR_OPERATOR);
double w = FastMath.abs(instantRot.getAngle()) / Constants.JULIAN_DAY;
// random rotation
Rotation rot = randomRotation(rnd);
// so we have a transform
Transform tr = new Transform(AbsoluteDate.J2000_EPOCH, rot, new Vector3D(w, normAxis));
// random position, velocity, acceleration
Vector3D pos = randomVector(1.0e3, rnd);
Vector3D vel = randomVector(1.0, rnd);
Vector3D acc = randomVector(1.0e-3, rnd);
PVCoordinates pvOne = new PVCoordinates(pos, vel, acc);
// we obtain
PVCoordinates pvTwo = tr.transformPVCoordinates(pvOne);
// test inverse
Vector3D resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity();
checkVector(resultvel, vel, 1.0e-15);
}
}
use of org.hipparchus.random.Well19937a in project Orekit by CS-SI.
the class TransformTest method testJacobianP.
@Test
public void testJacobianP() {
// base directions for finite differences
PVCoordinates[] directions = new PVCoordinates[] { new PVCoordinates(Vector3D.PLUS_I, Vector3D.ZERO, Vector3D.ZERO), new PVCoordinates(Vector3D.PLUS_J, Vector3D.ZERO, Vector3D.ZERO), new PVCoordinates(Vector3D.PLUS_K, Vector3D.ZERO, Vector3D.ZERO) };
double h = 0.01;
RandomGenerator random = new Well19937a(0x47fd0d6809f4b173l);
for (int i = 0; i < 20; ++i) {
// generate a random transform
Transform combined = randomTransform(random);
// compute Jacobian
double[][] jacobian = new double[9][9];
for (int l = 0; l < jacobian.length; ++l) {
for (int c = 0; c < jacobian[l].length; ++c) {
jacobian[l][c] = l + 0.1 * c;
}
}
combined.getJacobian(CartesianDerivativesFilter.USE_P, jacobian);
for (int j = 0; j < 100; ++j) {
PVCoordinates pv0 = new PVCoordinates(randomVector(1e3, random), randomVector(1.0, random), randomVector(1.0e-3, random));
double epsilonP = 2.0e-12 * pv0.getPosition().getNorm();
for (int c = 0; c < directions.length; ++c) {
// eight points finite differences estimation of a Jacobian column
PVCoordinates pvm4h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -4 * h, directions[c]));
PVCoordinates pvm3h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -3 * h, directions[c]));
PVCoordinates pvm2h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -2 * h, directions[c]));
PVCoordinates pvm1h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -1 * h, directions[c]));
PVCoordinates pvp1h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +1 * h, directions[c]));
PVCoordinates pvp2h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +2 * h, directions[c]));
PVCoordinates pvp3h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +3 * h, directions[c]));
PVCoordinates pvp4h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +4 * h, directions[c]));
PVCoordinates d4 = new PVCoordinates(pvm4h, pvp4h);
PVCoordinates d3 = new PVCoordinates(pvm3h, pvp3h);
PVCoordinates d2 = new PVCoordinates(pvm2h, pvp2h);
PVCoordinates d1 = new PVCoordinates(pvm1h, pvp1h);
double d = 1.0 / (840 * h);
PVCoordinates estimatedColumn = new PVCoordinates(-3 * d, d4, 32 * d, d3, -168 * d, d2, 672 * d, d1);
// check analytical Jacobian against finite difference reference
Assert.assertEquals(estimatedColumn.getPosition().getX(), jacobian[0][c], epsilonP);
Assert.assertEquals(estimatedColumn.getPosition().getY(), jacobian[1][c], epsilonP);
Assert.assertEquals(estimatedColumn.getPosition().getZ(), jacobian[2][c], epsilonP);
// check the rest of the matrix remains untouched
for (int l = 3; l < jacobian.length; ++l) {
Assert.assertEquals(l + 0.1 * c, jacobian[l][c], 1.0e-15);
}
}
// check the rest of the matrix remains untouched
for (int c = directions.length; c < jacobian[0].length; ++c) {
for (int l = 0; l < jacobian.length; ++l) {
Assert.assertEquals(l + 0.1 * c, jacobian[l][c], 1.0e-15);
}
}
}
}
}
use of org.hipparchus.random.Well19937a in project Orekit by CS-SI.
the class TransformTest method testJacobianPV.
@Test
public void testJacobianPV() {
// base directions for finite differences
PVCoordinates[] directions = new PVCoordinates[] { new PVCoordinates(Vector3D.PLUS_I, Vector3D.ZERO, Vector3D.ZERO), new PVCoordinates(Vector3D.PLUS_J, Vector3D.ZERO, Vector3D.ZERO), new PVCoordinates(Vector3D.PLUS_K, Vector3D.ZERO, Vector3D.ZERO), new PVCoordinates(Vector3D.ZERO, Vector3D.PLUS_I, Vector3D.ZERO), new PVCoordinates(Vector3D.ZERO, Vector3D.PLUS_J, Vector3D.ZERO), new PVCoordinates(Vector3D.ZERO, Vector3D.PLUS_K, Vector3D.ZERO) };
double h = 0.01;
RandomGenerator random = new Well19937a(0xce2bfddfbb9796bel);
for (int i = 0; i < 20; ++i) {
// generate a random transform
Transform combined = randomTransform(random);
// compute Jacobian
double[][] jacobian = new double[9][9];
for (int l = 0; l < jacobian.length; ++l) {
for (int c = 0; c < jacobian[l].length; ++c) {
jacobian[l][c] = l + 0.1 * c;
}
}
combined.getJacobian(CartesianDerivativesFilter.USE_PV, jacobian);
for (int j = 0; j < 100; ++j) {
PVCoordinates pv0 = new PVCoordinates(randomVector(1e3, random), randomVector(1.0, random), randomVector(1.0e-3, random));
double epsilonP = 2.0e-12 * pv0.getPosition().getNorm();
double epsilonV = 6.0e-11 * pv0.getVelocity().getNorm();
for (int c = 0; c < directions.length; ++c) {
// eight points finite differences estimation of a Jacobian column
PVCoordinates pvm4h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -4 * h, directions[c]));
PVCoordinates pvm3h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -3 * h, directions[c]));
PVCoordinates pvm2h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -2 * h, directions[c]));
PVCoordinates pvm1h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -1 * h, directions[c]));
PVCoordinates pvp1h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +1 * h, directions[c]));
PVCoordinates pvp2h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +2 * h, directions[c]));
PVCoordinates pvp3h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +3 * h, directions[c]));
PVCoordinates pvp4h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +4 * h, directions[c]));
PVCoordinates d4 = new PVCoordinates(pvm4h, pvp4h);
PVCoordinates d3 = new PVCoordinates(pvm3h, pvp3h);
PVCoordinates d2 = new PVCoordinates(pvm2h, pvp2h);
PVCoordinates d1 = new PVCoordinates(pvm1h, pvp1h);
double d = 1.0 / (840 * h);
PVCoordinates estimatedColumn = new PVCoordinates(-3 * d, d4, 32 * d, d3, -168 * d, d2, 672 * d, d1);
// check analytical Jacobian against finite difference reference
Assert.assertEquals(estimatedColumn.getPosition().getX(), jacobian[0][c], epsilonP);
Assert.assertEquals(estimatedColumn.getPosition().getY(), jacobian[1][c], epsilonP);
Assert.assertEquals(estimatedColumn.getPosition().getZ(), jacobian[2][c], epsilonP);
Assert.assertEquals(estimatedColumn.getVelocity().getX(), jacobian[3][c], epsilonV);
Assert.assertEquals(estimatedColumn.getVelocity().getY(), jacobian[4][c], epsilonV);
Assert.assertEquals(estimatedColumn.getVelocity().getZ(), jacobian[5][c], epsilonV);
// check the rest of the matrix remains untouched
for (int l = 6; l < jacobian.length; ++l) {
Assert.assertEquals(l + 0.1 * c, jacobian[l][c], 1.0e-15);
}
}
// check the rest of the matrix remains untouched
for (int c = directions.length; c < jacobian[0].length; ++c) {
for (int l = 0; l < jacobian.length; ++l) {
Assert.assertEquals(l + 0.1 * c, jacobian[l][c], 1.0e-15);
}
}
}
}
}
use of org.hipparchus.random.Well19937a in project Orekit by CS-SI.
the class TransformTest method testDecomposeAndRebuild.
@Test
public void testDecomposeAndRebuild() {
RandomGenerator random = new Well19937a(0xb8ee9da1b05198c9l);
for (int i = 0; i < 20; ++i) {
Transform combined = randomTransform(random);
Transform rebuilt = new Transform(combined.getDate(), new Transform(combined.getDate(), combined.getTranslation(), combined.getVelocity(), combined.getAcceleration()), new Transform(combined.getDate(), combined.getRotation(), combined.getRotationRate(), combined.getRotationAcceleration()));
checkNoTransform(new Transform(AbsoluteDate.J2000_EPOCH, combined, rebuilt.getInverse()), random);
}
}
use of org.hipparchus.random.Well19937a in project Orekit by CS-SI.
the class FieldTransformTest method doTestDecomposeAndRebuild.
private <T extends RealFieldElement<T>> void doTestDecomposeAndRebuild(Field<T> field) {
RandomGenerator random = new Well19937a(0xb8ee9da1b05198c9l);
for (int i = 0; i < 20; ++i) {
FieldTransform<T> combined = randomTransform(field, random);
FieldTransform<T> rebuilt = new FieldTransform<>(combined.getFieldDate(), new FieldTransform<>(combined.getFieldDate(), combined.getTranslation(), combined.getVelocity(), combined.getAcceleration()), new FieldTransform<>(combined.getFieldDate(), combined.getRotation(), combined.getRotationRate(), combined.getRotationAcceleration()));
checkNoTransform(new FieldTransform<>(FieldAbsoluteDate.getJ2000Epoch(field), combined, rebuilt.getInverse()), random);
}
}
Aggregations