Search in sources :

Example 36 with TimeComponents

use of org.orekit.time.TimeComponents in project Orekit by CS-SI.

the class SpinStabilizedTest method testSpin.

@Test
public void testSpin() throws OrekitException {
    AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
    double rate = 2.0 * FastMath.PI / (12 * 60);
    AttitudeProvider law = new SpinStabilized(new InertialProvider(Rotation.IDENTITY), date, Vector3D.PLUS_K, rate);
    KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
    Propagator propagator = new KeplerianPropagator(orbit, law);
    double h = 10.0;
    SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
    SpacecraftState s0 = propagator.propagate(date);
    SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));
    Vector3D spin0 = s0.getAttitude().getSpin();
    // check spin is consistent with attitude evolution
    double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation());
    double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
    Assert.assertTrue(errorAngleMinus <= 1.0e-6 * evolutionAngleMinus);
    double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation());
    double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
    Assert.assertTrue(errorAnglePlus <= 1.0e-6 * evolutionAnglePlus);
    // compute spin axis using finite differences
    Rotation rM = sMinus.getAttitude().getRotation();
    Rotation rP = sPlus.getAttitude().getRotation();
    Vector3D reference = AngularCoordinates.estimateRate(rM, rP, 2 * h);
    Assert.assertEquals(2 * FastMath.PI / reference.getNorm(), 2 * FastMath.PI / spin0.getNorm(), 0.05);
    Assert.assertEquals(0.0, FastMath.toDegrees(Vector3D.angle(reference, spin0)), 1.0e-10);
    Assert.assertEquals(0.0, FastMath.toDegrees(Vector3D.angle(Vector3D.PLUS_K, spin0)), 1.0e-10);
}
Also used : DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) FieldSpacecraftState(org.orekit.propagation.FieldSpacecraftState) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Test(org.junit.Test)

Example 37 with TimeComponents

use of org.orekit.time.TimeComponents in project Orekit by CS-SI.

the class SpinStabilizedTest method testBBQMode.

@Test
public void testBBQMode() throws OrekitException {
    PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
    AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getTAI());
    double rate = 2.0 * FastMath.PI / (12 * 60);
    AttitudeProvider cbp = new CelestialBodyPointed(FramesFactory.getEME2000(), sun, Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_K);
    SpinStabilized bbq = new SpinStabilized(cbp, date, Vector3D.PLUS_K, rate);
    PVCoordinates pv = new PVCoordinates(new Vector3D(28812595.32012577, 5948437.4640250085, 0), new Vector3D(0, 0, 3680.853673522056));
    KeplerianOrbit kep = new KeplerianOrbit(pv, FramesFactory.getEME2000(), date, 3.986004415e14);
    Attitude attitude = bbq.getAttitude(kep, date, kep.getFrame());
    checkField(Decimal64Field.getInstance(), bbq, kep, kep.getDate(), kep.getFrame());
    Vector3D xDirection = attitude.getRotation().applyInverseTo(Vector3D.PLUS_I);
    Assert.assertEquals(FastMath.atan(1.0 / 5000.0), Vector3D.angle(xDirection, sun.getPVCoordinates(date, FramesFactory.getEME2000()).getPosition()), 2.0e-15);
    Assert.assertEquals(rate, attitude.getSpin().getNorm(), 1.0e-6);
    Assert.assertSame(cbp, bbq.getUnderlyingAttitudeProvider());
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 38 with TimeComponents

use of org.orekit.time.TimeComponents 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 39 with TimeComponents

use of org.orekit.time.TimeComponents 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)

Example 40 with TimeComponents

use of org.orekit.time.TimeComponents in project Orekit by CS-SI.

the class FixedRateTest method doTestSpin.

private <T extends RealFieldElement<T>> void doTestSpin(final Field<T> field) throws OrekitException {
    final T zero = field.getZero();
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
    final T rate = zero.add(2 * FastMath.PI / (12 * 60));
    AttitudeProvider law = new FixedRate(new Attitude(date.toAbsoluteDate(), FramesFactory.getEME2000(), new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate.getReal(), Vector3D.PLUS_K), Vector3D.ZERO));
    FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7178000.0), zero.add(1.e-4), zero.add(FastMath.toRadians(50.)), zero.add(FastMath.toRadians(10.)), zero.add(FastMath.toRadians(20.)), zero.add(FastMath.toRadians(30.)), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
    FieldPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, law);
    T h = zero.add(0.01);
    FieldSpacecraftState<T> sMinus = propagator.propagate(date.shiftedBy(h.negate()));
    FieldSpacecraftState<T> s0 = propagator.propagate(date);
    FieldSpacecraftState<T> sPlus = propagator.propagate(date.shiftedBy(h));
    // check spin is consistent with attitude evolution
    double errorAngleMinus = FieldRotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation()).getReal();
    double evolutionAngleMinus = FieldRotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation()).getReal();
    Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus);
    double errorAnglePlus = FieldRotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(h.negate()).getAttitude().getRotation()).getReal();
    double evolutionAnglePlus = FieldRotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation()).getReal();
    Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus);
    FieldVector3D<T> spin0 = s0.getAttitude().getSpin();
    FieldVector3D<T> reference = FieldAngularCoordinates.estimateRate(sMinus.getAttitude().getRotation(), sPlus.getAttitude().getRotation(), h.multiply(2));
    Assert.assertEquals(0.0, spin0.subtract(reference).getNorm().getReal(), 1.0e-14);
}
Also used : 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) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

TimeComponents (org.orekit.time.TimeComponents)88 DateComponents (org.orekit.time.DateComponents)87 AbsoluteDate (org.orekit.time.AbsoluteDate)84 Test (org.junit.Test)72 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)55 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)55 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)47 Orbit (org.orekit.orbits.Orbit)44 SpacecraftState (org.orekit.propagation.SpacecraftState)42 CartesianOrbit (org.orekit.orbits.CartesianOrbit)35 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)35 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)32 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)28 PVCoordinates (org.orekit.utils.PVCoordinates)24 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)22 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)17 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)17 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)17 CircularOrbit (org.orekit.orbits.CircularOrbit)16 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)16