Search in sources :

Example 61 with DateComponents

use of org.orekit.time.DateComponents 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 62 with DateComponents

use of org.orekit.time.DateComponents 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 63 with DateComponents

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

the class TargetPointingTest method setUp.

@Before
public void setUp() {
    try {
        Utils.setDataRoot("regular-data");
        // Computation date
        date = new AbsoluteDate(new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getUTC());
        // Body mu
        mu = 3.9860047e14;
        // Reference frame = ITRF
        itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        // Transform from EME2000 to ITRF
        eme2000ToItrf = FramesFactory.getEME2000().getTransformTo(itrf, date);
    } catch (OrekitException oe) {
        Assert.fail(oe.getMessage());
    }
}
Also used : DateComponents(org.orekit.time.DateComponents) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Before(org.junit.Before)

Example 64 with DateComponents

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

the class OneAxisEllipsoidTest method testIntersectionFromPoints.

@Test
public void testIntersectionFromPoints() throws OrekitException {
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2008, 03, 21), TimeComponents.H12, TimeScalesFactory.getUTC());
    Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid earth = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, frame);
    // Satellite on polar position
    // ***************************
    final double mu = 3.9860047e14;
    CircularOrbit circ = new CircularOrbit(7178000.0, 0.5e-4, 0., FastMath.toRadians(90.), FastMath.toRadians(60.), FastMath.toRadians(90.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
    // Transform satellite position to position/velocity parameters in EME2000 and ITRF200B
    PVCoordinates pvSatEME2000 = circ.getPVCoordinates();
    PVCoordinates pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000);
    Vector3D pSatItrf = pvSatItrf.getPosition();
    // Test first visible surface points
    GeodeticPoint geoPoint = new GeodeticPoint(FastMath.toRadians(70.), FastMath.toRadians(60.), 0.);
    Vector3D pointItrf = earth.transform(geoPoint);
    Line line = new Line(pSatItrf, pointItrf, 1.0e-10);
    GeodeticPoint geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
    // Test second visible surface points
    geoPoint = new GeodeticPoint(FastMath.toRadians(65.), FastMath.toRadians(-120.), 0.);
    pointItrf = earth.transform(geoPoint);
    line = new Line(pSatItrf, pointItrf, 1.0e-10);
    geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
    // Test non visible surface points
    geoPoint = new GeodeticPoint(FastMath.toRadians(30.), FastMath.toRadians(60.), 0.);
    pointItrf = earth.transform(geoPoint);
    line = new Line(pSatItrf, pointItrf, 1.0e-10);
    geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    // For polar satellite position, intersection point is at the same longitude but different latitude
    Assert.assertEquals(1.04437199, geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(1.36198012, geoInter.getLatitude(), Utils.epsilonAngle);
    // Satellite on equatorial position
    // ********************************
    circ = new CircularOrbit(7178000.0, 0.5e-4, 0., FastMath.toRadians(1.e-4), FastMath.toRadians(0.), FastMath.toRadians(0.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
    // Transform satellite position to position/velocity parameters in EME2000 and ITRF200B
    pvSatEME2000 = circ.getPVCoordinates();
    pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000);
    pSatItrf = pvSatItrf.getPosition();
    // Test first visible surface points
    geoPoint = new GeodeticPoint(FastMath.toRadians(5.), FastMath.toRadians(0.), 0.);
    pointItrf = earth.transform(geoPoint);
    line = new Line(pSatItrf, pointItrf, 1.0e-10);
    Assert.assertTrue(line.toSubSpace(pSatItrf).getX() < 0);
    geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
    // With the point opposite to satellite point along the line
    GeodeticPoint geoInter2 = earth.getIntersectionPoint(line, line.toSpace(new Vector1D(-line.toSubSpace(pSatItrf).getX())), frame, date);
    Assert.assertTrue(FastMath.abs(geoInter.getLongitude() - geoInter2.getLongitude()) > FastMath.toRadians(0.1));
    Assert.assertTrue(FastMath.abs(geoInter.getLatitude() - geoInter2.getLatitude()) > FastMath.toRadians(0.1));
    // Test second visible surface points
    geoPoint = new GeodeticPoint(FastMath.toRadians(-5.), FastMath.toRadians(0.), 0.);
    pointItrf = earth.transform(geoPoint);
    line = new Line(pSatItrf, pointItrf, 1.0e-10);
    geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
    // Test non visible surface points
    geoPoint = new GeodeticPoint(FastMath.toRadians(40.), FastMath.toRadians(0.), 0.);
    pointItrf = earth.transform(geoPoint);
    line = new Line(pSatItrf, pointItrf, 1.0e-10);
    geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    Assert.assertEquals(-0.00768481, geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(0.32180410, geoInter.getLatitude(), Utils.epsilonAngle);
    // Satellite on any position
    // *************************
    circ = new CircularOrbit(7178000.0, 0.5e-4, 0., FastMath.toRadians(50.), FastMath.toRadians(0.), FastMath.toRadians(90.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
    // Transform satellite position to position/velocity parameters in EME2000 and ITRF200B
    pvSatEME2000 = circ.getPVCoordinates();
    pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000);
    pSatItrf = pvSatItrf.getPosition();
    // Test first visible surface points
    geoPoint = new GeodeticPoint(FastMath.toRadians(40.), FastMath.toRadians(90.), 0.);
    pointItrf = earth.transform(geoPoint);
    line = new Line(pSatItrf, pointItrf, 1.0e-10);
    geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
    // Test second visible surface points
    geoPoint = new GeodeticPoint(FastMath.toRadians(60.), FastMath.toRadians(90.), 0.);
    pointItrf = earth.transform(geoPoint);
    line = new Line(pSatItrf, pointItrf, 1.0e-10);
    geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
    // Test non visible surface points
    geoPoint = new GeodeticPoint(FastMath.toRadians(0.), FastMath.toRadians(90.), 0.);
    pointItrf = earth.transform(geoPoint);
    line = new Line(pSatItrf, pointItrf, 1.0e-10);
    geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
    Assert.assertEquals(FastMath.toRadians(89.5364061088196), geoInter.getLongitude(), Utils.epsilonAngle);
    Assert.assertEquals(FastMath.toRadians(35.555543683351125), geoInter.getLatitude(), Utils.epsilonAngle);
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) Frame(org.orekit.frames.Frame) CircularOrbit(org.orekit.orbits.CircularOrbit) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Vector1D(org.hipparchus.geometry.euclidean.oned.Vector1D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 65 with DateComponents

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

the class TabulatedProviderTest method setUp.

@Before
public void setUp() {
    try {
        Utils.setDataRoot("regular-data");
        // Computation date
        date = new AbsoluteDate(new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getUTC());
        // Body mu
        final double mu = 3.9860047e14;
        // Reference frame = ITRF
        itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        // Satellite position
        circOrbit = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(270.), FastMath.toRadians(5.300), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
        // Elliptic earth shape
        earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
    } catch (OrekitException oe) {
        Assert.fail(oe.getMessage());
    }
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) CircularOrbit(org.orekit.orbits.CircularOrbit) DateComponents(org.orekit.time.DateComponents) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Before(org.junit.Before)

Aggregations

DateComponents (org.orekit.time.DateComponents)148 AbsoluteDate (org.orekit.time.AbsoluteDate)129 Test (org.junit.Test)98 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)87 TimeComponents (org.orekit.time.TimeComponents)87 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)64 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)62 Orbit (org.orekit.orbits.Orbit)47 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)46 SpacecraftState (org.orekit.propagation.SpacecraftState)45 PVCoordinates (org.orekit.utils.PVCoordinates)40 CartesianOrbit (org.orekit.orbits.CartesianOrbit)37 OrekitException (org.orekit.errors.OrekitException)34 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)33 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)28 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)28 CircularOrbit (org.orekit.orbits.CircularOrbit)25 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)25 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)23 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)22