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);
}
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());
}
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());
}
}
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);
}
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());
}
}
Aggregations