use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class CelestialBodyFactoryTest method testEarthInertialFrameAroundJ2000.
@Test
public void testEarthInertialFrameAroundJ2000() throws OrekitException {
Utils.setDataRoot("regular-data");
final Frame earthFrame = CelestialBodyFactory.getEarth().getInertiallyOrientedFrame();
final Frame base = FramesFactory.getGCRF();
final Rotation reference = new Rotation(Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I);
for (double dt = -60; dt <= 60; dt += 1.0) {
final AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
Rotation rotation = base.getTransformTo(earthFrame, date).getRotation();
Assert.assertEquals(0.0, Rotation.distance(reference, rotation), 3.0e-10);
}
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class AttitudesSequenceTest method checkBetweenAttitudes.
private void checkBetweenAttitudes(final Attitude limit1, final Attitude limit2, final Attitude tested) {
final Rotation r1 = limit1.getRotation();
final Rotation r2 = limit2.getRotation();
final Rotation t = tested.getRotation();
final double reorientationAngle = Rotation.distance(r1, r2);
Assert.assertTrue(Rotation.distance(t, r1) < reorientationAngle);
Assert.assertTrue(Rotation.distance(t, r2) < reorientationAngle);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class AttitudesSequenceTest method testResetDuringTransitionForward.
@Test
public void testResetDuringTransitionForward() throws OrekitException {
// Initial state definition : date, orbit
final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
final TopocentricFrame volgograd = new TopocentricFrame(earth, new GeodeticPoint(FastMath.toRadians(48.7), FastMath.toRadians(44.5), 24.0), "Волгоград");
final AttitudesSequence attitudesSequence = new AttitudesSequence();
final double transitionTime = 250.0;
final AttitudeProvider nadirPointing = new NadirPointing(initialOrbit.getFrame(), earth);
final AttitudeProvider targetPointing = new TargetPointing(initialOrbit.getFrame(), volgograd.getPoint(), earth);
final ElevationDetector eventDetector = new ElevationDetector(volgograd).withConstantElevation(FastMath.toRadians(5.0)).withHandler(new ContinueOnEvent<>());
final List<AbsoluteDate> nadirToTarget = new ArrayList<>();
attitudesSequence.addSwitchingCondition(nadirPointing, targetPointing, eventDetector, true, false, transitionTime, AngularDerivativesFilter.USE_RR, (previous, next, state) -> nadirToTarget.add(state.getDate()));
final double[][] tolerance = NumericalPropagator.tolerances(10.0, initialOrbit, initialOrbit.getType());
final AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 300.0, tolerance[0], tolerance[1]);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("g007_eigen_05c_coef", false));
propagator.addForceModel(new HolmesFeatherstoneAttractionModel(earth.getBodyFrame(), GravityFieldFactory.getNormalizedProvider(8, 8)));
propagator.setInitialState(new SpacecraftState(initialOrbit, nadirPointing.getAttitude(initialOrbit, initialOrbit.getDate(), initialOrbit.getFrame())));
propagator.setAttitudeProvider(attitudesSequence);
attitudesSequence.registerSwitchEvents(propagator);
propagator.propagate(initialDate.shiftedBy(6000));
// check that if we restart a forward propagation from an intermediate state
// we properly get an interpolated attitude despite we missed the event trigger
final AbsoluteDate midTransition = nadirToTarget.get(0).shiftedBy(0.5 * transitionTime);
SpacecraftState state = propagator.propagate(midTransition.shiftedBy(-60), midTransition);
Rotation nadirR = nadirPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
Rotation targetR = targetPointing.getAttitude(state.getOrbit(), state.getDate(), state.getFrame()).getRotation();
final double reorientationAngle = Rotation.distance(nadirR, targetR);
Assert.assertEquals(0.5 * reorientationAngle, Rotation.distance(state.getAttitude().getRotation(), nadirR), 0.03 * reorientationAngle);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class FixedRateTest method doTestNonZeroRate.
private <T extends RealFieldElement<T>> void doTestNonZeroRate(final Field<T> field) throws OrekitException {
final T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 3, 2), new TimeComponents(13, 17, 7.865), TimeScalesFactory.getUTC());
final T rate = zero.add(2 * FastMath.PI / (12 * 60));
final Frame frame = FramesFactory.getEME2000();
FixedRate law = new FixedRate(new Attitude(date.toAbsoluteDate(), frame, new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate.getReal(), Vector3D.PLUS_K), Vector3D.ZERO));
FieldPVCoordinates<T> pv = new FieldPVCoordinates<>(field.getOne(), new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0), new Vector3D(0, 0, 3680.853673522056)));
FieldOrbit<T> orbit = new FieldKeplerianOrbit<>(pv, FramesFactory.getEME2000(), date, 3.986004415e14);
FieldRotation<T> attitude0 = law.getAttitude(orbit, date, frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude0.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
FieldRotation<T> attitude1 = law.getAttitude(orbit.shiftedBy(zero.add(10.0)), date.shiftedBy(10.0), frame).getRotation();
Assert.assertEquals(10 * rate.getReal(), Rotation.distance(attitude1.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
FieldRotation<T> attitude2 = law.getAttitude(orbit.shiftedBy(zero.add(-20.0)), date.shiftedBy(-20.0), frame).getRotation();
Assert.assertEquals(20 * rate.getReal(), Rotation.distance(attitude2.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
Assert.assertEquals(30 * rate.getReal(), Rotation.distance(attitude2.toRotation(), attitude1.toRotation()), 1.0e-10);
FieldRotation<T> attitude3 = law.getAttitude(orbit.shiftedBy(zero.add(0.0)), date, frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude3.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class FixedRateTest method doTestZeroRate.
private <T extends RealFieldElement<T>> void doTestZeroRate(final Field<T> field) throws OrekitException {
final T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2004, 3, 2), new TimeComponents(13, 17, 7.865), TimeScalesFactory.getUTC());
final Frame frame = FramesFactory.getEME2000();
FixedRate law = new FixedRate(new Attitude(date.toAbsoluteDate(), frame, new Rotation(0.48, 0.64, 0.36, 0.48, false), Vector3D.ZERO, Vector3D.ZERO));
FieldPVCoordinates<T> pv = new FieldPVCoordinates<>(field.getOne(), new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0), new Vector3D(0, 0, 3680.853673522056)));
FieldOrbit<T> orbit = new FieldKeplerianOrbit<>(pv, frame, date, 3.986004415e14);
FieldRotation<T> attitude0 = law.getAttitude(orbit, date, frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude0.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
FieldRotation<T> attitude1 = law.getAttitude(orbit.shiftedBy(zero.add(10.0)), date.shiftedBy(10.0), frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude1.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
FieldRotation<T> attitude2 = law.getAttitude(orbit.shiftedBy(zero.add(20.0)), date.shiftedBy(20.0), frame).getRotation();
Assert.assertEquals(0, Rotation.distance(attitude2.toRotation(), law.getReferenceAttitude().getRotation()), 1.0e-10);
}
Aggregations