Search in sources :

Example 71 with Rotation

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);
    }
}
Also used : Frame(org.orekit.frames.Frame) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 72 with Rotation

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);
}
Also used : Rotation(org.hipparchus.geometry.euclidean.threed.Rotation)

Example 73 with Rotation

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);
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) ICGEMFormatReader(org.orekit.forces.gravity.potential.ICGEMFormatReader) ElevationDetector(org.orekit.propagation.events.ElevationDetector) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) ArrayList(java.util.ArrayList) PVCoordinates(org.orekit.utils.PVCoordinates) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) FieldOrbit(org.orekit.orbits.FieldOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) Test(org.junit.Test)

Example 74 with Rotation

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);
}
Also used : Frame(org.orekit.frames.Frame) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 75 with Rotation

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);
}
Also used : Frame(org.orekit.frames.Frame) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldPVCoordinates(org.orekit.utils.FieldPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)145 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)116 Test (org.junit.Test)100 AbsoluteDate (org.orekit.time.AbsoluteDate)55 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)53 FieldRotation (org.hipparchus.geometry.euclidean.threed.FieldRotation)43 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)38 PVCoordinates (org.orekit.utils.PVCoordinates)30 SpacecraftState (org.orekit.propagation.SpacecraftState)26 DateComponents (org.orekit.time.DateComponents)22 Frame (org.orekit.frames.Frame)21 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)21 RandomGenerator (org.hipparchus.random.RandomGenerator)19 Transform (org.orekit.frames.Transform)19 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)19 CircularOrbit (org.orekit.orbits.CircularOrbit)18 TimeComponents (org.orekit.time.TimeComponents)17 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)16 GeodeticPoint (org.orekit.bodies.GeodeticPoint)15 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)14