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 @@
</properties>
<body>
<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">
Add AbsoluteDate.toStringWithoutUtcOffset(TimeScale, int) and
DateTimeComponents.toStringWithoutUtcOffset(int, int) to emulate
......
......@@ -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);
// 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);
for (final DoubleArrayDictionary.Entry entry : oldState.getAdditionalStatesValues().getData()) {
newState = newState.addAdditionalState(entry.getKey(), entry.getValue());
......
......@@ -59,7 +59,7 @@ public class ImpulseManeuverTest {
@Test
public void testInclinationManeuver() {
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(),
new AbsoluteDate(new DateComponents(2008, 06, 23),
new TimeComponents(14, 18, 37),
......@@ -77,6 +77,7 @@ public class ImpulseManeuverTest {
new Vector3D(dv, Vector3D.PLUS_J), 400.0));
SpacecraftState propagated = propagator.propagate(initialOrbit.getDate().shiftedBy(8000));
Assert.assertEquals(0.0028257, propagated.getI(), 1.0e-6);
Assert.assertEquals(0.442476 + 6 * FastMath.PI, ((KeplerianOrbit) propagated.getOrbit()).getLv(), 1.0e-6);
}
@Test
......
......@@ -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
public void setUp() {
......
......@@ -73,7 +73,7 @@ public class CircularOrbitTest {
// elliptic orbit
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,
FramesFactory.getEME2000(), date, mu);
Vector3D pos = circ.getPVCoordinates().getPosition();
......@@ -101,7 +101,7 @@ public class CircularOrbitTest {
// circular orbit
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,
FramesFactory.getEME2000(), date, mu);
Vector3D posCir = circCir.getPVCoordinates().getPosition();
......@@ -134,7 +134,7 @@ public class CircularOrbitTest {
double ey = eyTilde * cosRaan - exTilde * sinRaan;
CircularOrbit circ=
new CircularOrbit(42166.712, ex, ey, i, raan,
new CircularOrbit(42166712.0, ex, ey, i, raan,
5.300 - raan, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu);
Vector3D pos = circ.getPVCoordinates().getPosition();
......@@ -145,13 +145,13 @@ public class CircularOrbitTest {
double v = vel.getNorm();
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.350998914352669e+05, pos.getY(), Utils.epsilonTest * r);
Assert.assertEquals(-0.150053723123334e+01, pos.getZ(), Utils.epsilonTest * r);
Assert.assertEquals( 0.233745668678733e+08, pos.getX(), Utils.epsilonTest * r);
Assert.assertEquals(-0.350998914352669e+08, pos.getY(), 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(0.538902268252598e+05, vel.getY(), Utils.epsilonTest * v);
Assert.assertEquals(0.158527938296630e+02, vel.getZ(), Utils.epsilonTest * v);
Assert.assertEquals(2558.7096558809967, vel.getX(), Utils.epsilonTest * v);
Assert.assertEquals(1704.1586039092576, vel.getY(), Utils.epsilonTest * v);
Assert.assertEquals( 0.5013093577879, vel.getZ(), Utils.epsilonTest * v);
}
......@@ -170,12 +170,12 @@ public class CircularOrbitTest {
double ey = eyTilde * cosRaan - exTilde * sinRaan;
CircularOrbit circ=
new CircularOrbit(42166.712, ex, ey, i, raan,
new CircularOrbit(42166712.0, ex, ey, i, raan,
5.300 - raan, PositionAngle.MEAN,
FramesFactory.getEME2000(), date, mu);
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.166901168553917e-03, kep.getI(),
Utils.epsilonAngle * FastMath.abs(kep.getI()));
......@@ -194,7 +194,7 @@ public class CircularOrbitTest {
@Test
public void testHyperbolic1() {
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);
} catch (OrekitIllegalArgumentException oe) {
Assert.assertEquals(OrekitMessages.HYPERBOLIC_ORBIT_NOT_HANDLED_AS, oe.getSpecifier());
......@@ -203,7 +203,7 @@ public class CircularOrbitTest {
@Test
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);
try {
new CircularOrbit(orbit.getPVCoordinates(), orbit.getFrame(), orbit.getMu());
......@@ -320,7 +320,7 @@ public class CircularOrbitTest {
double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy));
double raan = FastMath.atan2(hy, hx);
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,
FramesFactory.getEME2000(), date, mu);
......@@ -377,7 +377,7 @@ public class CircularOrbitTest {
double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy));
double raan = FastMath.atan2(hy, hx);
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,
FramesFactory.getEME2000(), date, mu);
......@@ -408,7 +408,7 @@ public class CircularOrbitTest {
double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy));
double raan = FastMath.atan2(hy, hx);
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,
FramesFactory.getEME2000(), date, mu);
......@@ -452,7 +452,7 @@ public class CircularOrbitTest {
double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy));
double raan = FastMath.atan2(hy, hx);
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,
FramesFactory.getEME2000(), date, mu);
......@@ -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
public void setUp() {
......
......@@ -72,7 +72,7 @@ public class EquinoctialOrbitTest {
// elliptic orbit
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,
FramesFactory.getEME2000(), date, mu);
Vector3D pos = equi.getPVCoordinates().getPosition();
......@@ -106,7 +106,7 @@ public class EquinoctialOrbitTest {
// circular orbit
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,
FramesFactory.getEME2000(), date, mu);
Vector3D posCir = equiCir.getPVCoordinates().getPosition();
......@@ -141,7 +141,7 @@ public class EquinoctialOrbitTest {
double hy = FastMath.tan(inc / 2.) * iy / (2 * FastMath.sin(inc / 2.));
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,
FramesFactory.getEME2000(), date, mu);
Vector3D pos = equi.getPVCoordinates().getPosition();
......@@ -151,19 +151,13 @@ public class EquinoctialOrbitTest {
double oneovera = (2. / pos.getNorm()) - vit.getNorm() * vit.getNorm() / mu;
Assert.assertEquals(oneovera, 1. / equi.getA(), 1.0e-7);
Assert.assertEquals(0.233745668678733e+05, pos.getX(), Utils.epsilonTest
* FastMath.abs(pos.getX()));
Assert.assertEquals(-0.350998914352669e+05, pos.getY(), Utils.epsilonTest
* FastMath.abs(pos.getY()));
Assert.assertEquals(-0.150053723123334e+01, pos.getZ(), Utils.epsilonTest
* FastMath.abs(pos.getZ()));
Assert.assertEquals( 0.233745668678733e+08, pos.getX(), Utils.epsilonTest * FastMath.abs(pos.getX()));
Assert.assertEquals(-0.350998914352669e+08, pos.getY(), Utils.epsilonTest * FastMath.abs(pos.getY()));
Assert.assertEquals(-0.150053723123334e+04, pos.getZ(), Utils.epsilonTest * FastMath.abs(pos.getZ()));
Assert.assertEquals(0.809135038364960e+05, vit.getX(), Utils.epsilonTest
* FastMath.abs(vit.getX()));
Assert.assertEquals(0.538902268252598e+05, vit.getY(), Utils.epsilonTest
* FastMath.abs(vit.getY()));
Assert.assertEquals(0.158527938296630e+02, vit.getZ(), Utils.epsilonTest
* FastMath.abs(vit.getZ()));
Assert.assertEquals(2558.7096558809967, vit.getX(), Utils.epsilonTest * FastMath.abs(vit.getX()));
Assert.assertEquals(1704.1586039092576, vit.getY(), Utils.epsilonTest * FastMath.abs(vit.getY()));
Assert.assertEquals( 0.5013093577879, vit.getZ(), Utils.epsilonTest * FastMath.abs(vit.getZ()));
}
......@@ -177,12 +171,12 @@ public class EquinoctialOrbitTest {
double hy = FastMath.tan(i / 2) * iy / (2 * FastMath.sin(i / 2));
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,
FramesFactory.getEME2000(), date, mu);
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
* FastMath.abs(kep.getE()));
Assert.assertEquals(0.166901168553917e-03, kep.getI(), Utils.epsilonAngle
......@@ -201,7 +195,7 @@ public class EquinoctialOrbitTest {
@Test(expected=IllegalArgumentException.class)
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);
}
......@@ -305,7 +299,7 @@ public class EquinoctialOrbitTest {
// elliptic and non equatorial (i retrograde) orbit
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,
FramesFactory.getEME2000(), date, mu);
......@@ -327,7 +321,7 @@ public class EquinoctialOrbitTest {
// circular and equatorial orbit
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,
FramesFactory.getEME2000(), date, mu);
......@@ -354,7 +348,7 @@ public class EquinoctialOrbitTest {
// elliptic and non equatorial (i retrograde) orbit
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,
FramesFactory.getEME2000(), date, mu);
......@@ -392,7 +386,7 @@ public class EquinoctialOrbitTest {
// circular and equatorial orbit
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,
FramesFactory.getEME2000(), date, mu);
......@@ -438,7 +432,7 @@ public class EquinoctialOrbitTest {
// elliptic and non equatorial (i retrograde) orbit
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,
FramesFactory.getEME2000(), date, mu);
......@@ -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
public void setUp() {
......
......@@ -25,8 +25,8 @@ import java.util.List;
import java.util.function.Function;
import org.hamcrest.MatcherAssert;
import org.hipparchus.Field;
import org.hipparchus.CalculusFieldElement;
import org.hipparchus.Field;
import org.hipparchus.analysis.UnivariateFunction;
import org.hipparchus.analysis.differentiation.DSFactory;
import org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator;
......@@ -196,8 +196,13 @@ public class FieldCartesianOrbitTest {
doTestCopyNonKeplerianAcceleration(Decimal64Field.getInstance());
}
@Test
public void testNormalize() {
doTestNormalize(Decimal64Field.getInstance());
}
private <T extends CalculusFieldElement<T>> void doTestCartesianToCartesian(Field<T> field)
throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
......@@ -877,5 +882,19 @@ public class FieldCartesianOrbitTest {
}
private <T extends CalculusFieldElement<T>> void doTestNormalize(Field<T> field) {
final T zero = field.getZero();
final FieldVector3D<T> position = new FieldVector3D<>(zero.newInstance(42164140.0), zero, zero);
final FieldPVCoordinates<T> pv = new FieldPVCoordinates<>(position,
new FieldVector3D<>(zero,
FastMath.sqrt(position.getNorm().reciprocal().multiply(mu)),
zero));
final FieldOrbit<T> orbit = new FieldCartesianOrbit<>(pv,
FramesFactory.getEME2000(),
FieldAbsoluteDate.getJ2000Epoch(field),
field.getZero().newInstance(mu));
Assert.assertSame(orbit, orbit.getType().normalize(orbit, null));
}
}
......@@ -23,8 +23,8 @@ import java.util.List;
import java.util.function.Function;
import org.hamcrest.MatcherAssert;
import org.hipparchus.Field;
import org.hipparchus.CalculusFieldElement;
import org.hipparchus.Field;
import org.hipparchus.analysis.UnivariateFunction;
import org.hipparchus.analysis.differentiation.DSFactory;
import org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator;
......@@ -220,6 +220,11 @@ public class FieldCircularOrbitTest {
doTestCopyNonKeplerianAcceleration(Decimal64Field.getInstance());
}
@Test
public void testNormalize() {
doTestNormalize(Decimal64Field.getInstance());
}
private <T extends CalculusFieldElement<T>> void doTestCircularToEquinoctialEll(Field<T> field) {
T zero = field.getZero();
......@@ -234,7 +239,7 @@ public class FieldCircularOrbitTest {
// elliptic orbit
FieldCircularOrbit<T> circ =
new FieldCircularOrbit<>(zero.add(42166.712), zero.add(0.5), zero.add(-0.5), i, raan,
new FieldCircularOrbit<>(zero.add(42166712.0), zero.add(0.5), zero.add(-0.5), i, raan,
zero.add(5.300).subtract(raan), PositionAngle.MEAN,
FramesFactory.getEME2000(), date, zero.add(mu));
FieldVector3D<T> pos = circ.getPVCoordinates().getPosition();
......@@ -368,7 +373,7 @@ public class FieldCircularOrbitTest {
// circular orbit
FieldEquinoctialOrbit<T> circCir =
new FieldEquinoctialOrbit<>(zero.add(42166.712), zero.add(0.1e-10), zero.add(-0.1e-10), i, raan,
new FieldEquinoctialOrbit<>(zero.add(42166712.0), zero.add(0.1e-10), zero.add(-0.1e-10), i, raan,
raan.negate().add(5.300), PositionAngle.MEAN,
FramesFactory.getEME2000(), date, zero.add(mu));
FieldVector3D<T> posCir = circCir.getPVCoordinates().getPosition();
......@@ -402,7 +407,7 @@ public class FieldCircularOrbitTest {
T ey = eyTilde.multiply(cosRaan).subtract(exTilde.multiply(sinRaan));
FieldCircularOrbit<T> circ=
new FieldCircularOrbit<>(zero.add(42166.712), ex, ey, i, raan,
new FieldCircularOrbit<>(zero.add(42166712.0), ex, ey, i, raan,
raan.negate().add(5.300), PositionAngle.MEAN,
FramesFactory.getEME2000(), date, zero.add(mu));
FieldVector3D<T> pos = circ.getPVCoordinates().getPosition();
......@@ -413,13 +418,13 @@ public class FieldCircularOrbitTest {
T v = vel.getNorm();
Assert.assertEquals(2 / r.getReal() - v.getReal() * v.getReal() / mu, 1 / circ.getA().getReal(), 1.0e-7);
Assert.assertEquals( 0.233745668678733e+05, pos.getX().getReal(), Utils.epsilonTest * r.getReal());
Assert.assertEquals(-0.350998914352669e+05, pos.getY().getReal(), Utils.epsilonTest * r.getReal());
Assert.assertEquals(-0.150053723123334e+01, pos.getZ().getReal(), Utils.epsilonTest * r.getReal());
Assert.assertEquals( 0.233745668678733e+08, pos.getX().getReal(), Utils.epsilonTest * r.getReal());
Assert.assertEquals(-0.350998914352669e+08, pos.getY().getReal(), Utils.epsilonTest * r.getReal());
Assert.assertEquals(-0.150053723123334e+04, pos.getZ().getReal(), Utils.epsilonTest * r.getReal());
Assert.assertEquals(0.809135038364960e+05, vel.getX().getReal(), Utils.epsilonTest * v.getReal());
Assert.assertEquals(0.538902268252598e+05, vel.getY().getReal(), Utils.epsilonTest * v.getReal());
Assert.assertEquals(0.158527938296630e+02, vel.getZ().getReal(), Utils.epsilonTest * v.getReal());
Assert.assertEquals(2558.7096558809967, vel.getX().getReal(), Utils.epsilonTest * v.getReal());
Assert.assertEquals(1704.1586039092576, vel.getY().getReal(), Utils.epsilonTest * v.getReal());
Assert.assertEquals( 0.5013093577879, vel.getZ().getReal(), Utils.epsilonTest * v.getReal());
}
......@@ -439,12 +444,12 @@ public class FieldCircularOrbitTest {
T ey = eyTilde.multiply(cosRaan).subtract(exTilde.multiply(sinRaan));
FieldCircularOrbit<T> circ=
new FieldCircularOrbit<>(zero.add(42166.712), ex, ey, i, raan,
new FieldCircularOrbit<>(zero.add(42166712.0), ex, ey, i, raan,
raan.negate().add(5.300), PositionAngle.MEAN,
FramesFactory.getEME2000(), date, zero.add(mu));
FieldKeplerianOrbit<T> kep = new FieldKeplerianOrbit<>(circ);
Assert.assertEquals(42166.71200, circ.getA().getReal(), Utils.epsilonTest * kep.getA().getReal());
Assert.assertEquals(42166712.000, circ.getA().getReal(), Utils.epsilonTest * kep.getA().getReal());
Assert.assertEquals(0.110283316961361e-03, kep.getE().getReal(), Utils.epsilonE * FastMath.abs(kep.getE().getReal()));
Assert.assertEquals(0.166901168553917e-03, kep.getI().getReal(),
Utils.epsilonAngle * FastMath.abs(kep.getI().getReal()));
......@@ -465,7 +470,7 @@ public class FieldCircularOrbitTest {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);
try {
new FieldCircularOrbit<>(zero.add(42166.712), zero.add(0.9), zero.add(0.5), zero.add(0.01), zero.add(-0.02), zero.add( 5.300),
new FieldCircularOrbit<>(zero.add(42166712.0), zero.add(0.9), zero.add(0.5), zero.add(0.01), zero.add(-0.02), zero.add( 5.300),
PositionAngle.MEAN, FramesFactory.getEME2000(), date, zero.add(mu));
} catch (OrekitIllegalArgumentException oe) {
Assert.assertEquals(OrekitMessages.HYPERBOLIC_ORBIT_NOT_HANDLED_AS, oe.getSpecifier());
......@@ -475,7 +480,7 @@ public class FieldCircularOrbitTest {
private <T extends CalculusFieldElement<T>> void doTestHyperbolic2(Field<T> field) {
T zero = field.getZero();
FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field);