Commit 4659fa4a authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Merge branch 'issue-836' into develop

Conflicts:
	src/changes/changes.xml
parents 01a812a7 925c95a8
Pipeline #1654 passed with stages
in 23 minutes and 14 seconds
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
</properties> </properties>
<body> <body>
<release version="11.1" date="TBD" description="TBD"> <release version="11.1" date="TBD" description="TBD">
<action dev="luc" type="fix" issue="836">
Use the orbit normalization feature to reduce discontinuities across impulsive maneuvers.
</action>
<action dev="luc" type="add">
Added an orbit normalization feature.
</action>
<action dev="evan" type="add" issue="881"> <action dev="evan" type="add" issue="881">
Add AbsoluteDate.toStringWithoutUtcOffset(TimeScale, int) and Add AbsoluteDate.toStringWithoutUtcOffset(TimeScale, int) and
DateTimeComponents.toStringWithoutUtcOffset(int, int) to emulate DateTimeComponents.toStringWithoutUtcOffset(int, int) to emulate
......
...@@ -234,7 +234,7 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I ...@@ -234,7 +234,7 @@ public class ImpulseManeuver<T extends EventDetector> extends AbstractDetector<I
final double newMass = oldState.getMass() * FastMath.exp(-sign * deltaV.getNorm() / im.vExhaust); final double newMass = oldState.getMass() * FastMath.exp(-sign * deltaV.getNorm() / im.vExhaust);
// pack everything in a new state // pack everything in a new state
SpacecraftState newState = new SpacecraftState(oldState.getOrbit().getType().convertType(newOrbit), SpacecraftState newState = new SpacecraftState(oldState.getOrbit().getType().normalize(newOrbit, oldState.getOrbit()),
attitude, newMass); attitude, newMass);
for (final DoubleArrayDictionary.Entry entry : oldState.getAdditionalStatesValues().getData()) { for (final DoubleArrayDictionary.Entry entry : oldState.getAdditionalStatesValues().getData()) {
newState = newState.addAdditionalState(entry.getKey(), entry.getValue()); newState = newState.addAdditionalState(entry.getKey(), entry.getValue());
......
...@@ -59,7 +59,7 @@ public class ImpulseManeuverTest { ...@@ -59,7 +59,7 @@ public class ImpulseManeuverTest {
@Test @Test
public void testInclinationManeuver() { public void testInclinationManeuver() {
final Orbit initialOrbit = final Orbit initialOrbit =
new KeplerianOrbit(24532000.0, 0.72, 0.3, FastMath.PI, 0.4, 2.0, new KeplerianOrbit(24532000.0, 0.72, 0.3, FastMath.PI, 0.4, 2.0 + 4 * FastMath.PI,
PositionAngle.MEAN, FramesFactory.getEME2000(), PositionAngle.MEAN, FramesFactory.getEME2000(),
new AbsoluteDate(new DateComponents(2008, 06, 23), new AbsoluteDate(new DateComponents(2008, 06, 23),
new TimeComponents(14, 18, 37), new TimeComponents(14, 18, 37),
...@@ -77,6 +77,7 @@ public class ImpulseManeuverTest { ...@@ -77,6 +77,7 @@ public class ImpulseManeuverTest {
new Vector3D(dv, Vector3D.PLUS_J), 400.0)); new Vector3D(dv, Vector3D.PLUS_J), 400.0));
SpacecraftState propagated = propagator.propagate(initialOrbit.getDate().shiftedBy(8000)); SpacecraftState propagated = propagator.propagate(initialOrbit.getDate().shiftedBy(8000));
Assert.assertEquals(0.0028257, propagated.getI(), 1.0e-6); Assert.assertEquals(0.0028257, propagated.getI(), 1.0e-6);
Assert.assertEquals(0.442476 + 6 * FastMath.PI, ((KeplerianOrbit) propagated.getOrbit()).getLv(), 1.0e-6);
} }
@Test @Test
......
...@@ -741,6 +741,15 @@ public class CartesianOrbitTest { ...@@ -741,6 +741,15 @@ public class CartesianOrbitTest {
} }
@Test
public void testNormalize() {
final Vector3D position = new Vector3D(42164140, 0, 0);
final PVCoordinates pv = new PVCoordinates(position,
new Vector3D(0, FastMath.sqrt(mu / position.getNorm()), 0));
final Orbit orbit = new CartesianOrbit(pv, FramesFactory.getEME2000(), date, mu);
Assert.assertSame(orbit, orbit.getType().normalize(orbit, null));
}
@Before @Before
public void setUp() { public void setUp() {
......
...@@ -73,7 +73,7 @@ public class CircularOrbitTest { ...@@ -73,7 +73,7 @@ public class CircularOrbitTest {
// elliptic orbit // elliptic orbit
CircularOrbit circ = CircularOrbit circ =
new CircularOrbit(42166.712, 0.5, -0.5, i, raan, new CircularOrbit(42166712.0, 0.5, -0.5, i, raan,
5.300 - raan, PositionAngle.MEAN, 5.300 - raan, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
Vector3D pos = circ.getPVCoordinates().getPosition(); Vector3D pos = circ.getPVCoordinates().getPosition();
...@@ -101,7 +101,7 @@ public class CircularOrbitTest { ...@@ -101,7 +101,7 @@ public class CircularOrbitTest {
// circular orbit // circular orbit
EquinoctialOrbit circCir = EquinoctialOrbit circCir =
new EquinoctialOrbit(42166.712, 0.1e-10, -0.1e-10, i, raan, new EquinoctialOrbit(42166712.0, 0.1e-10, -0.1e-10, i, raan,
5.300 - raan, PositionAngle.MEAN, 5.300 - raan, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
Vector3D posCir = circCir.getPVCoordinates().getPosition(); Vector3D posCir = circCir.getPVCoordinates().getPosition();
...@@ -134,7 +134,7 @@ public class CircularOrbitTest { ...@@ -134,7 +134,7 @@ public class CircularOrbitTest {
double ey = eyTilde * cosRaan - exTilde * sinRaan; double ey = eyTilde * cosRaan - exTilde * sinRaan;
CircularOrbit circ= CircularOrbit circ=
new CircularOrbit(42166.712, ex, ey, i, raan, new CircularOrbit(42166712.0, ex, ey, i, raan,
5.300 - raan, PositionAngle.MEAN, 5.300 - raan, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
Vector3D pos = circ.getPVCoordinates().getPosition(); Vector3D pos = circ.getPVCoordinates().getPosition();
...@@ -145,13 +145,13 @@ public class CircularOrbitTest { ...@@ -145,13 +145,13 @@ public class CircularOrbitTest {
double v = vel.getNorm(); double v = vel.getNorm();
Assert.assertEquals(2 / r - v * v / mu, 1 / circ.getA(), 1.0e-7); Assert.assertEquals(2 / r - v * v / mu, 1 / circ.getA(), 1.0e-7);
Assert.assertEquals( 0.233745668678733e+05, pos.getX(), Utils.epsilonTest * r); Assert.assertEquals( 0.233745668678733e+08, pos.getX(), Utils.epsilonTest * r);
Assert.assertEquals(-0.350998914352669e+05, pos.getY(), Utils.epsilonTest * r); Assert.assertEquals(-0.350998914352669e+08, pos.getY(), Utils.epsilonTest * r);
Assert.assertEquals(-0.150053723123334e+01, pos.getZ(), Utils.epsilonTest * r); Assert.assertEquals(-0.150053723123334e+04, pos.getZ(), Utils.epsilonTest * r);
Assert.assertEquals(0.809135038364960e+05, vel.getX(), Utils.epsilonTest * v); Assert.assertEquals(2558.7096558809967, vel.getX(), Utils.epsilonTest * v);
Assert.assertEquals(0.538902268252598e+05, vel.getY(), Utils.epsilonTest * v); Assert.assertEquals(1704.1586039092576, vel.getY(), Utils.epsilonTest * v);
Assert.assertEquals(0.158527938296630e+02, vel.getZ(), Utils.epsilonTest * v); Assert.assertEquals( 0.5013093577879, vel.getZ(), Utils.epsilonTest * v);
} }
...@@ -170,12 +170,12 @@ public class CircularOrbitTest { ...@@ -170,12 +170,12 @@ public class CircularOrbitTest {
double ey = eyTilde * cosRaan - exTilde * sinRaan; double ey = eyTilde * cosRaan - exTilde * sinRaan;
CircularOrbit circ= CircularOrbit circ=
new CircularOrbit(42166.712, ex, ey, i, raan, new CircularOrbit(42166712.0, ex, ey, i, raan,
5.300 - raan, PositionAngle.MEAN, 5.300 - raan, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
KeplerianOrbit kep = new KeplerianOrbit(circ); KeplerianOrbit kep = new KeplerianOrbit(circ);
Assert.assertEquals(42166.71200, circ.getA(), Utils.epsilonTest * kep.getA()); Assert.assertEquals(42166712.000, circ.getA(), Utils.epsilonTest * kep.getA());
Assert.assertEquals(0.110283316961361e-03, kep.getE(), Utils.epsilonE * FastMath.abs(kep.getE())); Assert.assertEquals(0.110283316961361e-03, kep.getE(), Utils.epsilonE * FastMath.abs(kep.getE()));
Assert.assertEquals(0.166901168553917e-03, kep.getI(), Assert.assertEquals(0.166901168553917e-03, kep.getI(),
Utils.epsilonAngle * FastMath.abs(kep.getI())); Utils.epsilonAngle * FastMath.abs(kep.getI()));
...@@ -194,7 +194,7 @@ public class CircularOrbitTest { ...@@ -194,7 +194,7 @@ public class CircularOrbitTest {
@Test @Test
public void testHyperbolic1() { public void testHyperbolic1() {
try { try {
new CircularOrbit(42166.712, 0.9, 0.5, 0.01, -0.02, 5.300, new CircularOrbit(42166712.0, 0.9, 0.5, 0.01, -0.02, 5.300,
PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
} catch (OrekitIllegalArgumentException oe) { } catch (OrekitIllegalArgumentException oe) {
Assert.assertEquals(OrekitMessages.HYPERBOLIC_ORBIT_NOT_HANDLED_AS, oe.getSpecifier()); Assert.assertEquals(OrekitMessages.HYPERBOLIC_ORBIT_NOT_HANDLED_AS, oe.getSpecifier());
...@@ -203,7 +203,7 @@ public class CircularOrbitTest { ...@@ -203,7 +203,7 @@ public class CircularOrbitTest {
@Test @Test
public void testHyperbolic2() { public void testHyperbolic2() {
Orbit orbit = new KeplerianOrbit(42166.712, 0.9, 0.5, 0.01, -0.02, 5.300, Orbit orbit = new KeplerianOrbit(42166712.0, 0.9, 0.5, 0.01, -0.02, 5.300,
PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
try { try {
new CircularOrbit(orbit.getPVCoordinates(), orbit.getFrame(), orbit.getMu()); new CircularOrbit(orbit.getPVCoordinates(), orbit.getFrame(), orbit.getMu());
...@@ -320,7 +320,7 @@ public class CircularOrbitTest { ...@@ -320,7 +320,7 @@ public class CircularOrbitTest {
double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy)); double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy));
double raan = FastMath.atan2(hy, hx); double raan = FastMath.atan2(hy, hx);
CircularOrbit p = CircularOrbit p =
new CircularOrbit(42166.712, 0.5, -0.5, i, raan, new CircularOrbit(42166712.0, 0.5, -0.5, i, raan,
0.67 - raan, PositionAngle.TRUE, 0.67 - raan, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -377,7 +377,7 @@ public class CircularOrbitTest { ...@@ -377,7 +377,7 @@ public class CircularOrbitTest {
double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy)); double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy));
double raan = FastMath.atan2(hy, hx); double raan = FastMath.atan2(hy, hx);
CircularOrbit pCirEqua = CircularOrbit pCirEqua =
new CircularOrbit(42166.712, 0.1e-8, 0.1e-8, i, raan, new CircularOrbit(42166712.0, 0.1e-8, 0.1e-8, i, raan,
0.67 - raan, PositionAngle.TRUE, 0.67 - raan, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -408,7 +408,7 @@ public class CircularOrbitTest { ...@@ -408,7 +408,7 @@ public class CircularOrbitTest {
double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy)); double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy));
double raan = FastMath.atan2(hy, hx); double raan = FastMath.atan2(hy, hx);
CircularOrbit p = CircularOrbit p =
new CircularOrbit(42166.712, 0.5, -0.5, i, raan, new CircularOrbit(42166712.0, 0.5, -0.5, i, raan,
0.67 - raan, PositionAngle.TRUE, 0.67 - raan, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -452,7 +452,7 @@ public class CircularOrbitTest { ...@@ -452,7 +452,7 @@ public class CircularOrbitTest {
double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy)); double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy));
double raan = FastMath.atan2(hy, hx); double raan = FastMath.atan2(hy, hx);
CircularOrbit pCirEqua = CircularOrbit pCirEqua =
new CircularOrbit(42166.712, 0.1e-8, 0.1e-8, i, raan, new CircularOrbit(42166712.0, 0.1e-8, 0.1e-8, i, raan,
0.67 - raan, PositionAngle.TRUE, 0.67 - raan, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -1199,6 +1199,57 @@ public class CircularOrbitTest { ...@@ -1199,6 +1199,57 @@ public class CircularOrbitTest {
} }
@Test
public void testNormalize() {
CircularOrbit withoutDerivatives =
new CircularOrbit(42166712.0, 0.005, -0.025, 1.6,
1.25, 0.4, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu);
CircularOrbit ref =
new CircularOrbit(24000000.0, -0.012, 0.01, 0.2,
-6.28, 6.28, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu);
CircularOrbit normalized1 = (CircularOrbit) OrbitType.CIRCULAR.normalize(withoutDerivatives, ref);
Assert.assertFalse(normalized1.hasDerivatives());
Assert.assertEquals(0.0, normalized1.getA() - withoutDerivatives.getA(), 1.0e-6);
Assert.assertEquals(0.0, normalized1.getCircularEx() - withoutDerivatives.getCircularEx(), 1.0e-10);
Assert.assertEquals(0.0, normalized1.getCircularEy() - withoutDerivatives.getCircularEy(), 1.0e-10);
Assert.assertEquals(0.0, normalized1.getI() - withoutDerivatives.getI(), 1.0e-10);
Assert.assertEquals(-MathUtils.TWO_PI, normalized1.getRightAscensionOfAscendingNode() - withoutDerivatives.getRightAscensionOfAscendingNode(), 1.0e-10);
Assert.assertEquals(+MathUtils.TWO_PI, normalized1.getAlphaV() - withoutDerivatives.getAlphaV(), 1.0e-10);
Assert.assertTrue(Double.isNaN(normalized1.getADot()));
Assert.assertTrue(Double.isNaN(normalized1.getCircularExDot()));
Assert.assertTrue(Double.isNaN(normalized1.getCircularEyDot()));
Assert.assertTrue(Double.isNaN(normalized1.getIDot()));
Assert.assertTrue(Double.isNaN(normalized1.getRightAscensionOfAscendingNodeDot()));
Assert.assertTrue(Double.isNaN(normalized1.getAlphaVDot()));
double[] p = new double[6];
OrbitType.CIRCULAR.mapOrbitToArray(withoutDerivatives, PositionAngle.TRUE, p, null);
CircularOrbit withDerivatives = (CircularOrbit) OrbitType.CIRCULAR.mapArrayToOrbit(p,
new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 },
PositionAngle.TRUE,
withoutDerivatives.getDate(),
withoutDerivatives.getMu(),
withoutDerivatives.getFrame());
CircularOrbit normalized2 = (CircularOrbit) OrbitType.CIRCULAR.normalize(withDerivatives, ref);
Assert.assertTrue(normalized2.hasDerivatives());
Assert.assertEquals(0.0, normalized2.getA() - withDerivatives.getA(), 1.0e-6);
Assert.assertEquals(0.0, normalized2.getCircularEx() - withDerivatives.getCircularEx(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getCircularEy() - withDerivatives.getCircularEy(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getI() - withDerivatives.getI(), 1.0e-10);
Assert.assertEquals(-MathUtils.TWO_PI, normalized2.getRightAscensionOfAscendingNode() - withDerivatives.getRightAscensionOfAscendingNode(), 1.0e-10);
Assert.assertEquals(+MathUtils.TWO_PI, normalized2.getAlphaV() - withDerivatives.getAlphaV(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getADot() - withDerivatives.getADot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getCircularExDot() - withDerivatives.getCircularExDot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getCircularEyDot() - withDerivatives.getCircularEyDot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getIDot() - withDerivatives.getIDot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getRightAscensionOfAscendingNodeDot() - withDerivatives.getRightAscensionOfAscendingNodeDot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getAlphaVDot() - withDerivatives.getAlphaVDot(), 1.0e-10);
}
@Before @Before
public void setUp() { public void setUp() {
......
...@@ -72,7 +72,7 @@ public class EquinoctialOrbitTest { ...@@ -72,7 +72,7 @@ public class EquinoctialOrbitTest {
// elliptic orbit // elliptic orbit
EquinoctialOrbit equi = EquinoctialOrbit equi =
new EquinoctialOrbit(42166.712, 0.5, -0.5, hx, hy, new EquinoctialOrbit(42166712.0, 0.5, -0.5, hx, hy,
5.300, PositionAngle.MEAN, 5.300, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
Vector3D pos = equi.getPVCoordinates().getPosition(); Vector3D pos = equi.getPVCoordinates().getPosition();
...@@ -106,7 +106,7 @@ public class EquinoctialOrbitTest { ...@@ -106,7 +106,7 @@ public class EquinoctialOrbitTest {
// circular orbit // circular orbit
EquinoctialOrbit equiCir = EquinoctialOrbit equiCir =
new EquinoctialOrbit(42166.712, 0.1e-10, -0.1e-10, hx, hy, new EquinoctialOrbit(42166712.0, 0.1e-10, -0.1e-10, hx, hy,
5.300, PositionAngle.MEAN, 5.300, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
Vector3D posCir = equiCir.getPVCoordinates().getPosition(); Vector3D posCir = equiCir.getPVCoordinates().getPosition();
...@@ -141,7 +141,7 @@ public class EquinoctialOrbitTest { ...@@ -141,7 +141,7 @@ public class EquinoctialOrbitTest {
double hy = FastMath.tan(inc / 2.) * iy / (2 * FastMath.sin(inc / 2.)); double hy = FastMath.tan(inc / 2.) * iy / (2 * FastMath.sin(inc / 2.));
EquinoctialOrbit equi = EquinoctialOrbit equi =
new EquinoctialOrbit(42166.712, -7.900e-06, 1.100e-04, hx, hy, new EquinoctialOrbit(42166712.0, -7.900e-06, 1.100e-04, hx, hy,
5.300, PositionAngle.MEAN, 5.300, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
Vector3D pos = equi.getPVCoordinates().getPosition(); Vector3D pos = equi.getPVCoordinates().getPosition();
...@@ -151,19 +151,13 @@ public class EquinoctialOrbitTest { ...@@ -151,19 +151,13 @@ public class EquinoctialOrbitTest {
double oneovera = (2. / pos.getNorm()) - vit.getNorm() * vit.getNorm() / mu; double oneovera = (2. / pos.getNorm()) - vit.getNorm() * vit.getNorm() / mu;
Assert.assertEquals(oneovera, 1. / equi.getA(), 1.0e-7); Assert.assertEquals(oneovera, 1. / equi.getA(), 1.0e-7);
Assert.assertEquals(0.233745668678733e+05, pos.getX(), Utils.epsilonTest Assert.assertEquals( 0.233745668678733e+08, pos.getX(), Utils.epsilonTest * FastMath.abs(pos.getX()));
* FastMath.abs(pos.getX())); Assert.assertEquals(-0.350998914352669e+08, pos.getY(), Utils.epsilonTest * FastMath.abs(pos.getY()));
Assert.assertEquals(-0.350998914352669e+05, pos.getY(), Utils.epsilonTest Assert.assertEquals(-0.150053723123334e+04, pos.getZ(), Utils.epsilonTest * FastMath.abs(pos.getZ()));
* FastMath.abs(pos.getY()));
Assert.assertEquals(-0.150053723123334e+01, pos.getZ(), Utils.epsilonTest
* FastMath.abs(pos.getZ()));
Assert.assertEquals(0.809135038364960e+05, vit.getX(), Utils.epsilonTest Assert.assertEquals(2558.7096558809967, vit.getX(), Utils.epsilonTest * FastMath.abs(vit.getX()));
* FastMath.abs(vit.getX())); Assert.assertEquals(1704.1586039092576, vit.getY(), Utils.epsilonTest * FastMath.abs(vit.getY()));
Assert.assertEquals(0.538902268252598e+05, vit.getY(), Utils.epsilonTest Assert.assertEquals( 0.5013093577879, vit.getZ(), Utils.epsilonTest * FastMath.abs(vit.getZ()));
* FastMath.abs(vit.getY()));
Assert.assertEquals(0.158527938296630e+02, vit.getZ(), Utils.epsilonTest
* FastMath.abs(vit.getZ()));
} }
...@@ -177,12 +171,12 @@ public class EquinoctialOrbitTest { ...@@ -177,12 +171,12 @@ public class EquinoctialOrbitTest {
double hy = FastMath.tan(i / 2) * iy / (2 * FastMath.sin(i / 2)); double hy = FastMath.tan(i / 2) * iy / (2 * FastMath.sin(i / 2));
EquinoctialOrbit equi = EquinoctialOrbit equi =
new EquinoctialOrbit(42166.712, -7.900e-6, 1.100e-4, hx, hy, new EquinoctialOrbit(42166712.0, -7.900e-6, 1.100e-4, hx, hy,
5.300, PositionAngle.MEAN, 5.300, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
KeplerianOrbit kep = new KeplerianOrbit(equi); KeplerianOrbit kep = new KeplerianOrbit(equi);
Assert.assertEquals(42166.71200, equi.getA(), Utils.epsilonTest * kep.getA()); Assert.assertEquals(42166712.000, equi.getA(), Utils.epsilonTest * kep.getA());
Assert.assertEquals(0.110283316961361e-03, kep.getE(), Utils.epsilonE Assert.assertEquals(0.110283316961361e-03, kep.getE(), Utils.epsilonE
* FastMath.abs(kep.getE())); * FastMath.abs(kep.getE()));
Assert.assertEquals(0.166901168553917e-03, kep.getI(), Utils.epsilonAngle Assert.assertEquals(0.166901168553917e-03, kep.getI(), Utils.epsilonAngle
...@@ -201,7 +195,7 @@ public class EquinoctialOrbitTest { ...@@ -201,7 +195,7 @@ public class EquinoctialOrbitTest {
@Test(expected=IllegalArgumentException.class) @Test(expected=IllegalArgumentException.class)
public void testHyperbolic() { public void testHyperbolic() {
new EquinoctialOrbit(42166.712, 0.9, 0.5, 0.01, -0.02, 5.300, new EquinoctialOrbit(42166712.0, 0.9, 0.5, 0.01, -0.02, 5.300,
PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
} }
...@@ -305,7 +299,7 @@ public class EquinoctialOrbitTest { ...@@ -305,7 +299,7 @@ public class EquinoctialOrbitTest {
// elliptic and non equatorial (i retrograde) orbit // elliptic and non equatorial (i retrograde) orbit
EquinoctialOrbit p = EquinoctialOrbit p =
new EquinoctialOrbit(42166.712, 0.5, -0.5, 1.200, 2.1, new EquinoctialOrbit(42166712.0, 0.5, -0.5, 1.200, 2.1,
0.67, PositionAngle.TRUE, 0.67, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -327,7 +321,7 @@ public class EquinoctialOrbitTest { ...@@ -327,7 +321,7 @@ public class EquinoctialOrbitTest {
// circular and equatorial orbit // circular and equatorial orbit
EquinoctialOrbit pCirEqua = EquinoctialOrbit pCirEqua =
new EquinoctialOrbit(42166.712, 0.1e-8, 0.1e-8, 0.1e-8, 0.1e-8, new EquinoctialOrbit(42166712.0, 0.1e-8, 0.1e-8, 0.1e-8, 0.1e-8,
0.67, PositionAngle.TRUE, 0.67, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -354,7 +348,7 @@ public class EquinoctialOrbitTest { ...@@ -354,7 +348,7 @@ public class EquinoctialOrbitTest {
// elliptic and non equatorial (i retrograde) orbit // elliptic and non equatorial (i retrograde) orbit
EquinoctialOrbit p = EquinoctialOrbit p =
new EquinoctialOrbit(42166.712, 0.5, -0.5, 1.200, 2.1, new EquinoctialOrbit(42166712.0, 0.5, -0.5, 1.200, 2.1,
0.67, PositionAngle.TRUE, 0.67, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -392,7 +386,7 @@ public class EquinoctialOrbitTest { ...@@ -392,7 +386,7 @@ public class EquinoctialOrbitTest {
// circular and equatorial orbit // circular and equatorial orbit
EquinoctialOrbit pCirEqua = EquinoctialOrbit pCirEqua =
new EquinoctialOrbit(42166.712, 0.1e-8, 0.1e-8, 0.1e-8, 0.1e-8, new EquinoctialOrbit(42166712.0, 0.1e-8, 0.1e-8, 0.1e-8, 0.1e-8,
0.67, PositionAngle.TRUE, 0.67, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -438,7 +432,7 @@ public class EquinoctialOrbitTest { ...@@ -438,7 +432,7 @@ public class EquinoctialOrbitTest {
// elliptic and non equatorial (i retrograde) orbit // elliptic and non equatorial (i retrograde) orbit
EquinoctialOrbit p = EquinoctialOrbit p =
new EquinoctialOrbit(42166.712, 0.5, -0.5, 1.200, 2.1, new EquinoctialOrbit(42166712.0, 0.5, -0.5, 1.200, 2.1,
0.67, PositionAngle.TRUE, 0.67, PositionAngle.TRUE,
FramesFactory.getEME2000(), date, mu); FramesFactory.getEME2000(), date, mu);
...@@ -1134,6 +1128,58 @@ public class EquinoctialOrbitTest { ...@@ -1134,6 +1128,58 @@ public class EquinoctialOrbitTest {
} }
@Test
public void testNormalize() {
EquinoctialOrbit withoutDerivatives =
new EquinoctialOrbit(42166712.0, 0.005, -0.025, 0.17, 0.34,
0.4, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu);
EquinoctialOrbit ref =
new EquinoctialOrbit(24000000.0, -0.012, 0.01, 0.2, 0.1,
-6.28, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu);
EquinoctialOrbit normalized1 = (EquinoctialOrbit) OrbitType.EQUINOCTIAL.normalize(withoutDerivatives, ref);
Assert.assertFalse(normalized1.hasDerivatives());
Assert.assertEquals(0.0, normalized1.getA() - withoutDerivatives.getA(), 1.0e-6);
Assert.assertEquals(0.0, normalized1.getEquinoctialEx() - withoutDerivatives.getEquinoctialEx(), 1.0e-10);
Assert.assertEquals(0.0, normalized1.getEquinoctialEy() - withoutDerivatives.getEquinoctialEy(), 1.0e-10);
Assert.assertEquals(0.0, normalized1.getHx() - withoutDerivatives.getHx(), 1.0e-10);
Assert.assertEquals(0.0, normalized1.getHy() - withoutDerivatives.getHy(), 1.0e-10);
Assert.assertEquals(-MathUtils.TWO_PI, normalized1.getLv() - withoutDerivatives.getLv(), 1.0e-10);
Assert.assertTrue(Double.isNaN(normalized1.getADot()));
Assert.assertTrue(Double.isNaN(normalized1.getEquinoctialExDot()));
Assert.assertTrue(Double.isNaN(normalized1.getEquinoctialEyDot()));
Assert.assertTrue(Double.isNaN(normalized1.getHxDot()));
Assert.assertTrue(Double.isNaN(normalized1.getHyDot()));
Assert.assertTrue(Double.isNaN(normalized1.getLvDot()));
double[] p = new double[6];
OrbitType.EQUINOCTIAL.mapOrbitToArray(withoutDerivatives, PositionAngle.TRUE, p, null);
EquinoctialOrbit withDerivatives = (EquinoctialOrbit) OrbitType.EQUINOCTIAL.mapArrayToOrbit(p,
new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 },
PositionAngle.TRUE,
withoutDerivatives.getDate(),
withoutDerivatives.getMu(),
withoutDerivatives.getFrame());
EquinoctialOrbit normalized2 = (EquinoctialOrbit) OrbitType.EQUINOCTIAL.normalize(withDerivatives, ref);
Assert.assertTrue(normalized2.hasDerivatives());
Assert.assertFalse(normalized1.hasDerivatives());
Assert.assertEquals(0.0, normalized1.getA() - withoutDerivatives.getA(), 1.0e-6);
Assert.assertEquals(0.0, normalized1.getEquinoctialEx() - withoutDerivatives.getEquinoctialEx(), 1.0e-10);
Assert.assertEquals(0.0, normalized1.getEquinoctialEy() - withoutDerivatives.getEquinoctialEy(), 1.0e-10);
Assert.assertEquals(0.0, normalized1.getHx() - withoutDerivatives.getHx(), 1.0e-10);
Assert.assertEquals(0.0, normalized1.getHy() - withoutDerivatives.getHy(), 1.0e-10);
Assert.assertEquals(-MathUtils.TWO_PI, normalized1.getLv() - withoutDerivatives.getLv(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getADot() - withDerivatives.getADot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getEquinoctialExDot() - withDerivatives.getEquinoctialExDot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getEquinoctialEyDot() - withDerivatives.getEquinoctialEyDot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getHxDot() - withDerivatives.getHxDot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getHyDot() - withDerivatives.getHyDot(), 1.0e-10);
Assert.assertEquals(0.0, normalized2.getLvDot() - withDerivatives.getLvDot(), 1.0e-10);
}
@Before @Before
public void setUp() {