use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class AngularCoordinatesTest method testDerivativesStructures0.
@Test
public void testDerivativesStructures0() throws OrekitException {
RandomGenerator random = new Well1024a(0x18a0a08fd63f047al);
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(0));
Assert.assertEquals(0.0, Rotation.distance(ac.getRotation(), rebuilt.getRotation()), 1.0e-15);
Assert.assertEquals(0.0, rebuilt.getRotationRate().getNorm(), 1.0e-15);
Assert.assertEquals(0.0, rebuilt.getRotationAcceleration().getNorm(), 1.0e-15);
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class AngularCoordinatesTest method testRandomPVCoordinates.
@Test
public void testRandomPVCoordinates() throws OrekitException {
RandomGenerator generator = new Well1024a(0x49eb5b92d1f94b89l);
for (int i = 0; i < 100; ++i) {
Rotation r = randomRotation(generator);
Vector3D omega = randomVector(generator, 10 * generator.nextDouble() + 1.0);
Vector3D omegaDot = randomVector(generator, 0.1 * generator.nextDouble() + 0.01);
AngularCoordinates ref = new AngularCoordinates(r, omega, omegaDot);
AngularCoordinates inv = ref.revert();
for (int j = 0; j < 100; ++j) {
PVCoordinates v1 = randomPVCoordinates(generator, 1000, 1.0, 0.001);
PVCoordinates v2 = randomPVCoordinates(generator, 1000, 1.0, 0.0010);
PVCoordinates u1 = inv.applyTo(v1);
PVCoordinates u2 = inv.applyTo(v2);
AngularCoordinates rebuilt = new AngularCoordinates(u1, u2, v1, v2, 1.0e-9);
Assert.assertEquals(0.0, Rotation.distance(r, rebuilt.getRotation()), 4.0e-14);
Assert.assertEquals(0.0, Vector3D.distance(omega, rebuilt.getRotationRate()), 3.0e-12 * omega.getNorm());
Assert.assertEquals(0.0, Vector3D.distance(omegaDot, rebuilt.getRotationAcceleration()), 2.0e-6 * omegaDot.getNorm());
}
}
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method RealFieldTest.
/**
*Testing if the propagation between the FieldPropagation and the propagation
* is equivalent.
* Also testing if propagating X+dX with the propagation is equivalent to
* propagation X with the FieldPropagation and then applying the taylor
* expansion of dX to the result.
*/
@Test
public void RealFieldTest() throws OrekitException {
DSFactory factory = new DSFactory(6, 5);
DerivativeStructure a_0 = factory.variable(0, 7e7);
DerivativeStructure e_0 = factory.variable(1, 0.4);
DerivativeStructure i_0 = factory.variable(2, 85 * FastMath.PI / 180);
DerivativeStructure R_0 = factory.variable(3, 0.7);
DerivativeStructure O_0 = factory.variable(4, 0.5);
DerivativeStructure n_0 = factory.variable(5, 0.1);
Field<DerivativeStructure> field = a_0.getField();
DerivativeStructure zero = field.getZero();
FieldAbsoluteDate<DerivativeStructure> J2000 = new FieldAbsoluteDate<>(field);
Frame EME = FramesFactory.getEME2000();
FieldKeplerianOrbit<DerivativeStructure> FKO = new FieldKeplerianOrbit<>(a_0, e_0, i_0, R_0, O_0, n_0, PositionAngle.MEAN, EME, J2000, Constants.EIGEN5C_EARTH_MU);
FieldSpacecraftState<DerivativeStructure> initialState = new FieldSpacecraftState<>(FKO);
SpacecraftState iSR = initialState.toSpacecraftState();
final OrbitType type = OrbitType.KEPLERIAN;
double[][] tolerance = NumericalPropagator.tolerances(10.0, FKO.toOrbit(), type);
AdaptiveStepsizeFieldIntegrator<DerivativeStructure> integrator = new DormandPrince853FieldIntegrator<>(field, 0.001, 200, tolerance[0], tolerance[1]);
integrator.setInitialStepSize(zero.add(60));
AdaptiveStepsizeIntegrator RIntegrator = new DormandPrince853Integrator(0.001, 200, tolerance[0], tolerance[1]);
RIntegrator.setInitialStepSize(60);
FieldNumericalPropagator<DerivativeStructure> FNP = new FieldNumericalPropagator<>(field, integrator);
FNP.setOrbitType(type);
FNP.setInitialState(initialState);
NumericalPropagator NP = new NumericalPropagator(RIntegrator);
NP.setOrbitType(type);
NP.setInitialState(iSR);
final ConstantThrustManeuver forceModel = new ConstantThrustManeuver(J2000.toAbsoluteDate().shiftedBy(100), 100.0, 400.0, 300.0, Vector3D.PLUS_K);
FNP.addForceModel(forceModel);
NP.addForceModel(forceModel);
FieldAbsoluteDate<DerivativeStructure> target = J2000.shiftedBy(1000.);
FieldSpacecraftState<DerivativeStructure> finalState_DS = FNP.propagate(target);
SpacecraftState finalState_R = NP.propagate(target.toAbsoluteDate());
FieldPVCoordinates<DerivativeStructure> finPVC_DS = finalState_DS.getPVCoordinates();
PVCoordinates finPVC_R = finalState_R.getPVCoordinates();
Assert.assertEquals(finPVC_DS.toPVCoordinates().getPosition().getX(), finPVC_R.getPosition().getX(), FastMath.abs(finPVC_R.getPosition().getX()) * 1e-11);
Assert.assertEquals(finPVC_DS.toPVCoordinates().getPosition().getY(), finPVC_R.getPosition().getY(), FastMath.abs(finPVC_R.getPosition().getY()) * 1e-11);
Assert.assertEquals(finPVC_DS.toPVCoordinates().getPosition().getZ(), finPVC_R.getPosition().getZ(), FastMath.abs(finPVC_R.getPosition().getZ()) * 1e-11);
long number = 23091991;
RandomGenerator RG = new Well19937a(number);
GaussianRandomGenerator NGG = new GaussianRandomGenerator(RG);
UncorrelatedRandomVectorGenerator URVG = new UncorrelatedRandomVectorGenerator(new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, new double[] { 1e3, 0.01, 0.01, 0.01, 0.01, 0.01 }, NGG);
double a_R = a_0.getReal();
double e_R = e_0.getReal();
double i_R = i_0.getReal();
double R_R = R_0.getReal();
double O_R = O_0.getReal();
double n_R = n_0.getReal();
for (int ii = 0; ii < 1; ii++) {
double[] rand_next = URVG.nextVector();
double a_shift = a_R + rand_next[0];
double e_shift = e_R + rand_next[1];
double i_shift = i_R + rand_next[2];
double R_shift = R_R + rand_next[3];
double O_shift = O_R + rand_next[4];
double n_shift = n_R + rand_next[5];
KeplerianOrbit shiftedOrb = new KeplerianOrbit(a_shift, e_shift, i_shift, R_shift, O_shift, n_shift, PositionAngle.MEAN, EME, J2000.toAbsoluteDate(), Constants.EIGEN5C_EARTH_MU);
SpacecraftState shift_iSR = new SpacecraftState(shiftedOrb);
NumericalPropagator shift_NP = new NumericalPropagator(RIntegrator);
shift_NP.setInitialState(shift_iSR);
shift_NP.addForceModel(forceModel);
SpacecraftState finalState_shift = shift_NP.propagate(target.toAbsoluteDate());
PVCoordinates finPVC_shift = finalState_shift.getPVCoordinates();
// position check
FieldVector3D<DerivativeStructure> pos_DS = finPVC_DS.getPosition();
double x_DS = pos_DS.getX().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
double y_DS = pos_DS.getY().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
double z_DS = pos_DS.getZ().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
// System.out.println(pos_DS.getX().getPartialDerivative(1));
double x = finPVC_shift.getPosition().getX();
double y = finPVC_shift.getPosition().getY();
double z = finPVC_shift.getPosition().getZ();
Assert.assertEquals(x_DS, x, FastMath.abs(x - pos_DS.getX().getReal()) * 1e-8);
Assert.assertEquals(y_DS, y, FastMath.abs(y - pos_DS.getY().getReal()) * 1e-8);
Assert.assertEquals(z_DS, z, FastMath.abs(z - pos_DS.getZ().getReal()) * 1e-8);
// velocity check
FieldVector3D<DerivativeStructure> vel_DS = finPVC_DS.getVelocity();
double vx_DS = vel_DS.getX().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
double vy_DS = vel_DS.getY().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
double vz_DS = vel_DS.getZ().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
double vx = finPVC_shift.getVelocity().getX();
double vy = finPVC_shift.getVelocity().getY();
double vz = finPVC_shift.getVelocity().getZ();
Assert.assertEquals(vx_DS, vx, FastMath.abs(vx) * 1e-9);
Assert.assertEquals(vy_DS, vy, FastMath.abs(vy) * 1e-9);
Assert.assertEquals(vz_DS, vz, FastMath.abs(vz) * 1e-9);
// acceleration check
FieldVector3D<DerivativeStructure> acc_DS = finPVC_DS.getAcceleration();
double ax_DS = acc_DS.getX().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
double ay_DS = acc_DS.getY().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
double az_DS = acc_DS.getZ().taylor(rand_next[0], rand_next[1], rand_next[2], rand_next[3], rand_next[4], rand_next[5]);
double ax = finPVC_shift.getAcceleration().getX();
double ay = finPVC_shift.getAcceleration().getY();
double az = finPVC_shift.getAcceleration().getZ();
Assert.assertEquals(ax_DS, ax, FastMath.abs(ax) * 1e-8);
Assert.assertEquals(ay_DS, ay, FastMath.abs(ay) * 1e-8);
Assert.assertEquals(az_DS, az, FastMath.abs(az) * 1e-8);
}
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class TopocentricFrameTest method testPointAtDistance.
@Test
public void testPointAtDistance() throws OrekitException {
RandomGenerator random = new Well1024a(0xa1e6bd5cd0578779l);
final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
for (int i = 0; i < 20; ++i) {
// we don't need uniform point on the sphere, just a few different test configurations
double latitude = FastMath.PI * (0.5 - random.nextDouble());
double longitude = 2 * FastMath.PI * random.nextDouble();
TopocentricFrame topo = new TopocentricFrame(earth, new GeodeticPoint(latitude, longitude, 0.0), "topo");
Transform transform = earth.getBodyFrame().getTransformTo(topo, date);
for (int j = 0; j < 20; ++j) {
double elevation = FastMath.PI * (0.5 - random.nextDouble());
double azimuth = 2 * FastMath.PI * random.nextDouble();
double range = 500000.0 * (1.0 + random.nextDouble());
Vector3D absolutePoint = earth.transform(topo.pointAtDistance(azimuth, elevation, range));
Vector3D relativePoint = transform.transformPosition(absolutePoint);
double rebuiltElevation = topo.getElevation(relativePoint, topo, AbsoluteDate.J2000_EPOCH);
double rebuiltAzimuth = topo.getAzimuth(relativePoint, topo, AbsoluteDate.J2000_EPOCH);
double rebuiltRange = topo.getRange(relativePoint, topo, AbsoluteDate.J2000_EPOCH);
Assert.assertEquals(elevation, rebuiltElevation, 1.0e-12);
Assert.assertEquals(azimuth, MathUtils.normalizeAngle(rebuiltAzimuth, azimuth), 1.0e-12);
Assert.assertEquals(range, rebuiltRange, 1.0e-12 * range);
}
}
}
use of org.hipparchus.random.RandomGenerator in project Orekit by CS-SI.
the class TransformTest method testRotation.
@Test
public void testRotation() {
RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);
for (int i = 0; i < 10; ++i) {
Rotation r = randomRotation(rnd);
Vector3D axis = r.getAxis(RotationConvention.VECTOR_OPERATOR);
double angle = r.getAngle();
Transform transform = new Transform(AbsoluteDate.J2000_EPOCH, r);
for (int j = 0; j < 10; ++j) {
Vector3D a = new Vector3D(rnd.nextDouble(), rnd.nextDouble(), rnd.nextDouble());
Vector3D b = transform.transformVector(a);
Assert.assertEquals(Vector3D.angle(axis, a), Vector3D.angle(axis, b), 1.0e-14);
Vector3D aOrtho = Vector3D.crossProduct(axis, a);
Vector3D bOrtho = Vector3D.crossProduct(axis, b);
Assert.assertEquals(angle, Vector3D.angle(aOrtho, bOrtho), 1.0e-14);
Vector3D c = transform.transformPosition(a);
Assert.assertEquals(0, c.subtract(b).getNorm(), 1.0e-14);
}
}
}
Aggregations