Skip to content
Snippets Groups Projects
Commit 642679b1 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Fixed a numerical issue at tile exit.

The low point at tile minimum elevation was computed with a tiny
positive error, meaning the point really was above min elevation (at
micrometer level). The line segment between entry and exit stopped just
before traversing the Digital Elevation Model, and an error was
triggered.

The solution was to take some margin when computing the segment
endpoints at entry and exit: we now start above max elevation and end
below min elevation so the intersection should be really on the line. 
parent 53f45682
No related branches found
No related tags found
No related merge requests found
......@@ -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())) {
......
......@@ -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;
}
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment