From 8526d2247d9af6ab57ddaa0e4e078f0f7f27cda4 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe <luc@orekit.org> Date: Fri, 2 May 2014 21:40:28 +0200 Subject: [PATCH] Fixed inverse localization wrong corrections. --- .../java/org/orekit/rugged/api/Rugged.java | 23 ++++++++++--------- .../org/orekit/rugged/api/RuggedTest.java | 17 +++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/orekit/rugged/api/Rugged.java b/src/main/java/org/orekit/rugged/api/Rugged.java index be8eb29f..06b0e931 100644 --- a/src/main/java/org/orekit/rugged/api/Rugged.java +++ b/src/main/java/org/orekit/rugged/api/Rugged.java @@ -501,17 +501,17 @@ public class Rugged { final GeodeticPoint[] gp = new GeodeticPoint[sensor.getNbPixels()]; for (int i = 0; i < gp.length; ++i) { - final Vector3D pInert = scToInert.transformPosition(sensor.getPosition(i)); + final Vector3D pInert = scToInert.transformPosition(sensor.getPosition(i)); + final Vector3D rawLInert = scToInert.transformVector(sensor.getLos(i)); final Vector3D lInert; if (aberrationOfLightCorrection) { // apply aberration of light correction // as the spacecraft velocity is small with respect to speed of light, // we use classical velocity addition and not relativistic velocity addition - lInert = new Vector3D(Constants.SPEED_OF_LIGHT, scToInert.transformVector(sensor.getLos(i)), - 1.0, spacecraftVelocity).normalize(); + lInert = new Vector3D(Constants.SPEED_OF_LIGHT, rawLInert, 1.0, spacecraftVelocity).normalize(); } else { // don't apply aberration of light correction - lInert = scToInert.transformVector(sensor.getLos(i)); + lInert = rawLInert; } if (lightTimeCorrection) { @@ -535,9 +535,10 @@ public class Rugged { } else { // compute DEM intersection without light time correction - gp[i] = algorithm.intersection(ellipsoid, - inertToBody.transformPosition(pInert), - inertToBody.transformVector(lInert)); + final Vector3D pBody = inertToBody.transformPosition(pInert); + final Vector3D lBody = inertToBody.transformVector(lInert); + gp[i] = algorithm.refineIntersection(ellipsoid, pBody, lBody, + algorithm.intersection(ellipsoid, pBody, lBody)); } } @@ -645,18 +646,18 @@ public class Rugged { } final Vector3D targetInert = shifted.transformPosition(target); - Vector3D lInert; + final Vector3D rawLInert = targetInert.subtract(meanRefInert).normalize(); + final Vector3D lInert; if (aberrationOfLightCorrection) { // apply aberration of light correction // as the spacecraft velocity is small with respect to speed of light, // we use classical velocity addition and not relativistic velocity addition final Vector3D spacecraftVelocity = scToInert.transformPVCoordinates(PVCoordinates.ZERO).getVelocity(); - lInert = new Vector3D(Constants.SPEED_OF_LIGHT, targetInert.subtract(meanRefInert).normalize(), - 1.0, spacecraftVelocity).normalize(); + lInert = new Vector3D(Constants.SPEED_OF_LIGHT, rawLInert, -1.0, spacecraftVelocity).normalize(); } else { // don't apply aberration of light correction - lInert = targetInert.subtract(meanRefInert).normalize(); + lInert = rawLInert; } // direction of the target point in spacecraft frame diff --git a/src/test/java/org/orekit/rugged/api/RuggedTest.java b/src/test/java/org/orekit/rugged/api/RuggedTest.java index eb8433ad..6ee999dd 100644 --- a/src/test/java/org/orekit/rugged/api/RuggedTest.java +++ b/src/test/java/org/orekit/rugged/api/RuggedTest.java @@ -411,9 +411,9 @@ public class RuggedTest { Vector3D pWithout = earth.transform(gpWithoutFlatBodyCorrection[i]); stats.addValue(Vector3D.distance(pWith, pWithout)); } - Assert.assertEquals(0.005, stats.getMin(), 1.0e-3); - Assert.assertEquals(6.503, stats.getMax(), 1.0e-3); - Assert.assertEquals(2.199, stats.getMean(), 1.0e-3); + Assert.assertEquals( 0.005, stats.getMin(), 1.0e-3); + Assert.assertEquals(49.157, stats.getMax(), 1.0e-3); + Assert.assertEquals( 4.870, stats.getMean(), 1.0e-3); } @@ -452,17 +452,16 @@ public class RuggedTest { orbitToPV(orbit, earth, lineDatation, firstLine, lastLine, 0.25), 8, orbitToQ(orbit, earth, lineDatation, firstLine, lastLine, 0.25), 2); rugged.setLightTimeCorrection(true); - rugged.setAberrationOfLightCorrection(false); + rugged.setAberrationOfLightCorrection(true); rugged.setLineSensor("line", los, lineDatation); - double referenceLine = 100.00; + double referenceLine = dimension / 2; GeodeticPoint[] gp = rugged.directLocalization("line", referenceLine); - for (int i = 0; i < gp.length; ++i) { + for (int i = 1; i < gp.length - 1; ++i) { SensorPixel sp = rugged.inverseLocalization("line", gp[i], 0, dimension); - System.out.println(i + " " + (sp.getLineNumber() - referenceLine) + " " + (sp.getPixelNumber() - i)); -// Assert.assertEquals(referenceLine, sp.getLineNumber(), 3.0e-9); -// Assert.assertEquals(i, sp.getPixelNumber(), 8.0e-5); + Assert.assertEquals(referenceLine, sp.getLineNumber(), 5.0e-6); + Assert.assertEquals(i, sp.getPixelNumber(), 1.0e-7); } } -- GitLab