use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class ODMMetaData method getFrame.
/**
* Get the reference frame in which data are given: used for state vector and
* Keplerian elements data (and for the covariance reference frame if none is given).
*
* @return the reference frame
* @throws OrekitException if the reference frame cannot be created.
*/
public Frame getFrame() throws OrekitException {
final Frame frame = this.getRefFrame();
final CelestialBody body = this.getCenterBody();
if (body == null) {
throw new OrekitException(OrekitMessages.NO_DATA_LOADED_FOR_CELESTIAL_BODY, this.getCenterName());
}
// Just return frame if we don't need to shift the center based on CENTER_NAME
// MCI and ICRF are the only non-earth centered frames specified in Annex A.
final String frameString = this.getFrameString();
final boolean isMci = "MCI".equals(frameString);
final boolean isIcrf = "ICRF".equals(frameString);
final boolean isSolarSystemBarycenter = CelestialBodyFactory.SOLAR_SYSTEM_BARYCENTER.equals(body.getName());
if ((!(isMci || isIcrf) && CelestialBodyFactory.EARTH.equals(body.getName())) || (isMci && CelestialBodyFactory.MARS.equals(body.getName())) || (isIcrf && isSolarSystemBarycenter)) {
return frame;
}
// else, translate frame to specified center.
return new CcsdsModifiedFrame(frame, frameString, body, this.getCenterName());
}
use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class L1TransformProviderTest method testSunEarth.
@Test
public void testSunEarth() throws OrekitException {
// Load Bodies
final CelestialBody sun = CelestialBodyFactory.getSun();
final CelestialBody earth = CelestialBodyFactory.getEarth();
// Set frames
final Frame sunFrame = sun.getInertiallyOrientedFrame();
final Frame l1Frame = new L1Frame(sun, earth);
// Time settings
final AbsoluteDate date = new AbsoluteDate(2000, 01, 01, 0, 0, 00.000, TimeScalesFactory.getUTC());
// Compute Earth position in Sun centered frame
PVCoordinates pvEarth = earth.getPVCoordinates(date, sunFrame);
Vector3D posEarth = pvEarth.getPosition();
// Compute L1 position in Sun centered frame
// (it is important to use transformPosition(Vector3D.ZERO) and *not* getTranslation()
// because the test should avoid doing wrong interpretation of the meaning and
// particularly on the sign of the translation)
Vector3D posL1 = l1Frame.getTransformTo(sunFrame, date).transformPosition(Vector3D.ZERO);
// check L1 and Earth are aligned as seen from Sun
Assert.assertEquals(0.0, Vector3D.angle(posEarth, posL1), 1.0e-10);
// check if Earth is at least 1 000 000km farther than L1
Assert.assertTrue(posEarth.getNorm() > posL1.getNorm() + 1.0e9);
}
use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class L1TransformProviderTest method testL1Orientation.
@Test
public void testL1Orientation() throws OrekitException {
final AbsoluteDate date0 = new AbsoluteDate(2000, 01, 1, 11, 58, 20.000, TimeScalesFactory.getUTC());
final CelestialBody sun = CelestialBodyFactory.getSun();
final CelestialBody earth = CelestialBodyFactory.getEarth();
final Frame l1Frame = new L1Frame(sun, earth);
for (double dt = -Constants.JULIAN_DAY; dt <= Constants.JULIAN_DAY; dt += 3600.0) {
final AbsoluteDate date = date0.shiftedBy(dt);
final Vector3D sunPositionInL1 = sun.getPVCoordinates(date, l1Frame).getPosition();
final Vector3D earthPositionInL1 = earth.getPVCoordinates(date, l1Frame).getPosition();
Assert.assertEquals(0.0, Vector3D.angle(sunPositionInL1, Vector3D.MINUS_I), 3.0e-14);
Assert.assertEquals(FastMath.PI, Vector3D.angle(earthPositionInL1, Vector3D.MINUS_I), 3.0e-14);
}
}
use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class EclipticProviderTest method checkAlignment.
/**
* Check alignment of ecliptic +z with Earth-Moon barycenter angular momentum. Angular
* difference will be checked every month.
*
* @param start start date of check.
* @param end en date of check.
* @throws OrekitException on error
*/
private void checkAlignment(AbsoluteDate start, AbsoluteDate end) throws OrekitException {
// setup
CelestialBody sun = CelestialBodyFactory.getSun();
CelestialBody emb = CelestialBodyFactory.getEarthMoonBarycenter();
Frame heliocentric = sun.getInertiallyOrientedFrame();
// subject under test
Frame ecliptic = FramesFactory.getEcliptic(IERSConventions.IERS_2010);
// verify
// precise definition is +z is parallel to Earth-Moon barycenter's angular momentum
// over date range of ephemeris, a season at a time
double preciseTol = 0.50 * Constants.ARC_SECONDS_TO_RADIANS;
for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(Constants.JULIAN_YEAR / 12.0)) {
Transform heliocentricToEcliptic = heliocentric.getTransformTo(ecliptic, date);
Vector3D momentum = emb.getPVCoordinates(date, heliocentric).getMomentum();
Vector3D actual = heliocentricToEcliptic.transformVector(momentum);
double angle = Vector3D.angle(Vector3D.PLUS_K, actual);
Assert.assertEquals("Agrees with ephemerides to within " + preciseTol, 0, angle, preciseTol);
}
}
use of org.orekit.bodies.CelestialBody in project Orekit by CS-SI.
the class L2TransformProviderTest method testSunEarth.
@Test
public void testSunEarth() throws OrekitException {
// Load Bodies
final CelestialBody sun = CelestialBodyFactory.getSun();
final CelestialBody earth = CelestialBodyFactory.getEarth();
// Set frames
final Frame sunFrame = sun.getInertiallyOrientedFrame();
final Frame l2Frame = new L2Frame(sun, earth);
// Time settings
final AbsoluteDate date = new AbsoluteDate(2000, 01, 01, 0, 0, 00.000, TimeScalesFactory.getUTC());
// Compute Earth position in Sun centered frame
PVCoordinates pvEarth = earth.getPVCoordinates(date, sunFrame);
Vector3D posEarth = pvEarth.getPosition();
// Compute L2 position in Sun centered frame
// (it is important to use transformPosition(Vector3D.ZERO) and *not* getTranslation()
// because the test should avoid doing wrong interpretation of the meaning and
// particularly on the sign of the translation)
Vector3D posL2 = l2Frame.getTransformTo(sunFrame, date).transformPosition(Vector3D.ZERO);
// check L2 and Earth are aligned as seen from Sun
Assert.assertEquals(0.0, Vector3D.angle(posEarth, posL2), 1.0e-10);
// check L2 if at least 1 000 000km farther than Earth
Assert.assertTrue(posL2.getNorm() > posEarth.getNorm() + 1.0e9);
}
Aggregations