use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class CIRFProvider method getTransform.
/**
* {@inheritDoc}
*/
@Override
public Transform getTransform(final AbsoluteDate date) throws OrekitException {
final double[] xys = xysPxy2Function.value(date);
final double[] dxdy = eopHistory.getNonRotatinOriginNutationCorrection(date);
// position of the Celestial Intermediate Pole (CIP)
final double xCurrent = xys[0] + dxdy[0];
final double yCurrent = xys[1] + dxdy[1];
// position of the Celestial Intermediate Origin (CIO)
final double sCurrent = xys[2] - xCurrent * yCurrent / 2;
// set up the bias, precession and nutation rotation
final double x2Py2 = xCurrent * xCurrent + yCurrent * yCurrent;
final double zP1 = 1 + FastMath.sqrt(1 - x2Py2);
final double r = FastMath.sqrt(x2Py2);
final double sPe2 = 0.5 * (sCurrent + FastMath.atan2(yCurrent, xCurrent));
final double cos = FastMath.cos(sPe2);
final double sin = FastMath.sin(sPe2);
final double xPr = xCurrent + r;
final double xPrCos = xPr * cos;
final double xPrSin = xPr * sin;
final double yCos = yCurrent * cos;
final double ySin = yCurrent * sin;
final Rotation bpn = new Rotation(zP1 * (xPrCos + ySin), -r * (yCos + xPrSin), r * (xPrCos - ySin), zP1 * (yCos - xPrSin), true);
return new Transform(date, bpn, Vector3D.ZERO);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class ITRFProvider method getTransform.
/**
* {@inheritDoc}
*/
@Override
public Transform getTransform(final AbsoluteDate date) throws OrekitException {
// offset from J2000 epoch in Julian centuries
final double tts = date.durationFrom(AbsoluteDate.J2000_EPOCH);
final double ttc = tts / Constants.JULIAN_CENTURY;
// pole correction parameters
final PoleCorrection eop = eopHistory.getPoleCorrection(date);
// pole motion in terrestrial frame
final Rotation wRot = new Rotation(RotationOrder.XYZ, RotationConvention.FRAME_TRANSFORM, eop.getYp(), eop.getXp(), -S_PRIME_RATE * ttc);
// combined effects
final Rotation combined = wRot.revert();
// set up the transform from parent TIRF
return new Transform(date, combined, Vector3D.ZERO);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class GroundStationTest method doTestAngularDerivatives.
private void doTestAngularDerivatives(double latitude, double longitude, double altitude, double stepFactor, double toleranceRotationValue, double toleranceRotationDerivative, double toleranceRotationRateValue, double toleranceRotationRateDerivative, String... parameterPattern) throws OrekitException {
Utils.setDataRoot("regular-data");
final Frame eme2000 = FramesFactory.getEME2000();
final AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
final AbsoluteDate date0 = date.shiftedBy(50000);
final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
final GroundStation station = new GroundStation(new TopocentricFrame(earth, new GeodeticPoint(latitude, longitude, altitude), "dummy"));
final DSFactory factory = new DSFactory(parameterPattern.length, 1);
final FieldAbsoluteDate<DerivativeStructure> dateDS = new FieldAbsoluteDate<>(factory.getDerivativeField(), date);
ParameterDriver[] selectedDrivers = new ParameterDriver[parameterPattern.length];
UnivariateDifferentiableVectorFunction[] dFAngular = new UnivariateDifferentiableVectorFunction[parameterPattern.length];
final ParameterDriver[] allDrivers = selectAllDrivers(station);
for (ParameterDriver driver : allDrivers) {
driver.setReferenceDate(date0);
}
Map<String, Integer> indices = new HashMap<>();
for (int k = 0; k < dFAngular.length; ++k) {
for (int i = 0; i < allDrivers.length; ++i) {
if (allDrivers[i].getName().matches(parameterPattern[k])) {
selectedDrivers[k] = allDrivers[i];
dFAngular[k] = differentiatedTransformAngular(station, eme2000, date, selectedDrivers[k], stepFactor);
indices.put(selectedDrivers[k].getName(), k);
}
}
}
;
DSFactory factory11 = new DSFactory(1, 1);
RandomGenerator generator = new Well19937a(0xa01a1d8fe5d80af7l);
double maxRotationValueError = 0;
double maxRotationDerivativeError = 0;
double maxRotationRateValueError = 0;
double maxRotationRateDerivativeError = 0;
for (int i = 0; i < 1000; ++i) {
// randomly change one parameter
ParameterDriver changed = allDrivers[generator.nextInt(allDrivers.length)];
changed.setNormalizedValue(2 * generator.nextDouble() - 1);
// transform to check
FieldTransform<DerivativeStructure> t = station.getOffsetToInertial(eme2000, dateDS, factory, indices);
for (int k = 0; k < dFAngular.length; ++k) {
// reference values and derivatives computed using finite differences
DerivativeStructure[] refAngular = dFAngular[k].value(factory11.variable(0, selectedDrivers[k].getValue()));
// rotation
final Rotation refQ = new Rotation(refAngular[0].getValue(), refAngular[1].getValue(), refAngular[2].getValue(), refAngular[3].getValue(), true);
final Rotation resQ = t.getRotation().toRotation();
maxRotationValueError = FastMath.max(maxRotationValueError, Rotation.distance(refQ, resQ));
double sign = FastMath.copySign(1.0, refAngular[0].getValue() * t.getRotation().getQ0().getValue() + refAngular[1].getValue() * t.getRotation().getQ1().getValue() + refAngular[2].getValue() * t.getRotation().getQ2().getValue() + refAngular[3].getValue() * t.getRotation().getQ3().getValue());
maxRotationDerivativeError = FastMath.max(maxRotationDerivativeError, FastMath.abs(sign * refAngular[0].getPartialDerivative(1) - t.getRotation().getQ0().getAllDerivatives()[k + 1]));
maxRotationDerivativeError = FastMath.max(maxRotationDerivativeError, FastMath.abs(sign * refAngular[1].getPartialDerivative(1) - t.getRotation().getQ1().getAllDerivatives()[k + 1]));
maxRotationDerivativeError = FastMath.max(maxRotationDerivativeError, FastMath.abs(sign * refAngular[2].getPartialDerivative(1) - t.getRotation().getQ2().getAllDerivatives()[k + 1]));
maxRotationDerivativeError = FastMath.max(maxRotationDerivativeError, FastMath.abs(sign * refAngular[3].getPartialDerivative(1) - t.getRotation().getQ3().getAllDerivatives()[k + 1]));
// rotation rate
final Vector3D refRate = new Vector3D(refAngular[4].getValue(), refAngular[5].getValue(), refAngular[6].getValue());
final Vector3D resRate = t.getRotationRate().toVector3D();
final Vector3D refRateD = new Vector3D(refAngular[4].getPartialDerivative(1), refAngular[5].getPartialDerivative(1), refAngular[6].getPartialDerivative(1));
final Vector3D resRateD = new Vector3D(t.getRotationRate().getX().getAllDerivatives()[k + 1], t.getRotationRate().getY().getAllDerivatives()[k + 1], t.getRotationRate().getZ().getAllDerivatives()[k + 1]);
maxRotationRateValueError = FastMath.max(maxRotationRateValueError, Vector3D.distance(refRate, resRate));
maxRotationRateDerivativeError = FastMath.max(maxRotationRateDerivativeError, Vector3D.distance(refRateD, resRateD));
}
}
Assert.assertEquals(0.0, maxRotationValueError, toleranceRotationValue);
Assert.assertEquals(0.0, maxRotationDerivativeError, toleranceRotationDerivative);
Assert.assertEquals(0.0, maxRotationRateValueError, toleranceRotationRateValue);
Assert.assertEquals(0.0, maxRotationRateDerivativeError, toleranceRotationRateDerivative);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method testRoughBehaviour.
@Test
public void testRoughBehaviour() throws OrekitException {
final double isp = 318;
final double mass = 2500;
final double a = 24396159;
final double e = 0.72831215;
final double i = FastMath.toRadians(7);
final double omega = FastMath.toRadians(180);
final double OMEGA = FastMath.toRadians(261);
final double lv = 0;
final double duration = 3653.99;
final double f = 420;
final double delta = FastMath.toRadians(-7.4978);
final double alpha = FastMath.toRadians(351);
final AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
Assert.assertEquals(f, maneuver.getThrust(), 1.0e-10);
Assert.assertEquals(isp, maneuver.getISP(), 1.0e-10);
double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, absTolerance, relTolerance);
integrator.setInitialStepSize(60);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setInitialState(initialState);
propagator.setAttitudeProvider(law);
propagator.addForceModel(maneuver);
final SpacecraftState finalorb = propagator.propagate(fireDate.shiftedBy(3800));
final double massTolerance = FastMath.abs(maneuver.getFlowRate()) * maneuver.getEventsDetectors().findFirst().get().getThreshold();
Assert.assertEquals(2007.8824544261233, finalorb.getMass(), massTolerance);
Assert.assertEquals(2.6872, FastMath.toDegrees(MathUtils.normalizeAngle(finalorb.getI(), FastMath.PI)), 1e-4);
Assert.assertEquals(28970, finalorb.getA() / 1000, 1);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class ConstantThrustManeuverTest method testInertialManeuver.
@Test
public void testInertialManeuver() throws OrekitException {
final double isp = 318;
final double mass = 2500;
final double a = 24396159;
final double e = 0.72831215;
final double i = FastMath.toRadians(7);
final double omega = FastMath.toRadians(180);
final double OMEGA = FastMath.toRadians(261);
final double lv = 0;
final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
final double duration = 3653.99;
final double f = 420;
final double delta = FastMath.toRadians(-7.4978);
final double alpha = FastMath.toRadians(351);
final AttitudeProvider inertialLaw = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
final AttitudeProvider lofLaw = new LofOffset(orbit.getFrame(), LOFType.VNC);
final SpacecraftState initialState = new SpacecraftState(orbit, inertialLaw.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
final ConstantThrustManeuver maneuverWithoutOverride = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
Assert.assertEquals(f, maneuverWithoutOverride.getThrust(), 1.0e-10);
Assert.assertEquals(isp, maneuverWithoutOverride.getISP(), 1.0e-10);
// reference propagation:
// propagator already uses inertial law
// maneuver does not need to override it to get an inertial maneuver
double[][] tol = NumericalPropagator.tolerances(1.0, orbit, OrbitType.KEPLERIAN);
AdaptiveStepsizeIntegrator integrator1 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator1.setInitialStepSize(60);
final NumericalPropagator propagator1 = new NumericalPropagator(integrator1);
propagator1.setInitialState(initialState);
propagator1.setAttitudeProvider(inertialLaw);
propagator1.addForceModel(maneuverWithoutOverride);
final SpacecraftState finalState1 = propagator1.propagate(fireDate.shiftedBy(3800));
// test propagation:
// propagator uses a LOF-aligned law
// maneuver needs to override it to get an inertial maneuver
final ConstantThrustManeuver maneuverWithOverride = new ConstantThrustManeuver(fireDate, duration, f, isp, inertialLaw, Vector3D.PLUS_I);
Assert.assertEquals(f, maneuverWithoutOverride.getThrust(), 1.0e-10);
Assert.assertEquals(isp, maneuverWithoutOverride.getISP(), 1.0e-10);
AdaptiveStepsizeIntegrator integrator2 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator2.setInitialStepSize(60);
final NumericalPropagator propagator2 = new NumericalPropagator(integrator2);
propagator2.setInitialState(initialState);
propagator2.setAttitudeProvider(lofLaw);
propagator2.addForceModel(maneuverWithOverride);
final SpacecraftState finalState2 = propagator2.propagate(finalState1.getDate());
Assert.assertThat(finalState2.getPVCoordinates(), OrekitMatchers.pvCloseTo(finalState1.getPVCoordinates(), 1.0e-10));
// intentionally wrong propagation, that will produce a very different state
// propagator uses LOF attitude,
// maneuver forget to override it, so maneuver will be LOF-aligned in this case
AdaptiveStepsizeIntegrator integrator3 = new DormandPrince853Integrator(0.001, 1000, tol[0], tol[1]);
integrator3.setInitialStepSize(60);
final NumericalPropagator propagator3 = new NumericalPropagator(integrator3);
propagator3.setInitialState(initialState);
propagator3.setAttitudeProvider(lofLaw);
propagator3.addForceModel(maneuverWithoutOverride);
final SpacecraftState finalState3 = propagator3.propagate(finalState1.getDate());
Assert.assertEquals(345859.0, Vector3D.distance(finalState1.getPVCoordinates().getPosition(), finalState3.getPVCoordinates().getPosition()), 1.0);
}
Aggregations