diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java index 12e3d106a366f26d0e3f2b545811240fbf4f0fec..acdf0fafb777e497fc0ba0bd0ea8386a0225e551 100644 --- a/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java +++ b/rugged-core/src/main/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithm.java @@ -72,7 +72,7 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm { while (current == null) { // find where line-of-sight crosses tile max altitude - final Vector3D entryP = ellipsoid.pointAtAltitude(position, los, tile.getMaxElevation()); + final Vector3D entryP = ellipsoid.pointAtAltitude(position, los, tile.getMaxElevation() + STEP); if (Vector3D.dotProduct(entryP.subtract(position), los) < 0) { // the entry point is behind spacecraft! throw new RuggedException(RuggedMessages.DEM_ENTRY_POINT_IS_BEHIND_SPACECRAFT); @@ -267,7 +267,7 @@ public class DuvenhageAlgorithm implements IntersectionAlgorithm { throws RuggedException, OrekitException { // look for an exit at bottom - Vector3D exitP = ellipsoid.pointAtAltitude(position, los, tile.getMinElevation()); + Vector3D exitP = ellipsoid.pointAtAltitude(position, los, tile.getMinElevation() - STEP); GeodeticPoint exitGP = ellipsoid.transform(exitP, ellipsoid.getBodyFrame(), null); switch (tile.getLocation(exitGP.getLatitude(), exitGP.getLongitude())) { diff --git a/rugged-core/src/test/java/org/orekit/rugged/core/AbstractAlgorithmTest.java b/rugged-core/src/test/java/org/orekit/rugged/core/AbstractAlgorithmTest.java index 204260fa2b0ea85d24f9a667eca18b812d322c08..d940603bb877d9ac8d4498d5d84c7edc6037ffd1 100644 --- a/rugged-core/src/test/java/org/orekit/rugged/core/AbstractAlgorithmTest.java +++ b/rugged-core/src/test/java/org/orekit/rugged/core/AbstractAlgorithmTest.java @@ -149,7 +149,7 @@ public abstract class AbstractAlgorithmTest { } - private void setUpMayonVolcanoContext() + protected void setUpMayonVolcanoContext() throws RuggedException, OrekitException { // Mayon Volcano location according to Wikipedia: 13°15′24″N 123°41′6″E @@ -196,7 +196,7 @@ public abstract class AbstractAlgorithmTest { } - private void setUpCliffsOfMoherContext() + protected void setUpCliffsOfMoherContext() throws RuggedException, OrekitException { // cliffs of Moher location according to Wikipedia: 52°56′10″N 9°28′15″ W @@ -267,8 +267,8 @@ public abstract class AbstractAlgorithmTest { state = null; } - private ExtendedEllipsoid earth; - private TileUpdater updater; - private SpacecraftState state; + protected ExtendedEllipsoid earth; + protected TileUpdater updater; + protected SpacecraftState state; } diff --git a/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithmTest.java b/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithmTest.java index 535bc08a67995dbc9ab82e059c67865c0d485865..40ed68fa9481b80e8c021d85015c08ef5f58d269 100644 --- a/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithmTest.java +++ b/rugged-core/src/test/java/org/orekit/rugged/core/duvenhage/DuvenhageAlgorithmTest.java @@ -17,6 +17,12 @@ package org.orekit.rugged.core.duvenhage; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.junit.Assert; +import org.junit.Test; +import org.orekit.bodies.GeodeticPoint; +import org.orekit.errors.OrekitException; +import org.orekit.rugged.api.RuggedException; import org.orekit.rugged.core.AbstractAlgorithmTest; import org.orekit.rugged.core.raster.IntersectionAlgorithm; @@ -26,4 +32,19 @@ public class DuvenhageAlgorithmTest extends AbstractAlgorithmTest { return new DuvenhageAlgorithm(); } + @Test + public void testNumericalIssueAtTileExit() throws RuggedException, OrekitException { + setUpMayonVolcanoContext(); + final IntersectionAlgorithm algorithm = createAlgorithm(); + algorithm.setUpTilesManagement(updater, 8); + GeodeticPoint intersection = algorithm.intersection(earth, + new Vector3D(-3787079.6453602533, + 5856784.405679551, + 1655869.0582939098), + new Vector3D( 0.5127552821932051, + -0.8254313129088879, + -0.2361041470463311)); + Assert.assertEquals(16.0, intersection.getAltitude(), 1.0e-10); + } + }