diff --git a/rugged-core/src/main/java/org/orekit/rugged/core/BasicScanAlgorithm.java b/rugged-core/src/main/java/org/orekit/rugged/core/BasicScanAlgorithm.java
index 6260474de3f4e4cf8536f4dde44b0184540b807e..49351cbdfc447d206a7523fb3a6e1fe1dcd9fd8c 100644
--- a/rugged-core/src/main/java/org/orekit/rugged/core/BasicScanAlgorithm.java
+++ b/rugged-core/src/main/java/org/orekit/rugged/core/BasicScanAlgorithm.java
@@ -81,12 +81,12 @@ public class BasicScanAlgorithm implements IntersectionAlgorithm {
 
                 scannedTiles.clear();
                 // compute entry and exit points
-                entryPoint = ellipsoid.transform(ellipsoid.pointAtAltitude(position, los, Double.isInfinite(hMin) ? 0.0 : hMin),
+                entryPoint = ellipsoid.transform(ellipsoid.pointAtAltitude(position, los, Double.isInfinite(hMax) ? 0.0 : hMax),
                                                  ellipsoid.getBodyFrame(), null);
                 final SimpleTile entryTile = cache.getTile(entryPoint.getLatitude(), entryPoint.getLongitude());
                 addIfNotPresent(scannedTiles, entryTile);
 
-                exitPoint = ellipsoid.transform(ellipsoid.pointAtAltitude(position, los, Double.isInfinite(hMax) ? 0.0 : hMax),
+                exitPoint = ellipsoid.transform(ellipsoid.pointAtAltitude(position, los, Double.isInfinite(hMin) ? 0.0 : hMin),
                                                 ellipsoid.getBodyFrame(), null);
                 final SimpleTile exitTile = cache.getTile(exitPoint.getLatitude(), exitPoint.getLongitude());
                 addIfNotPresent(scannedTiles, entryTile);
@@ -116,8 +116,8 @@ public class BasicScanAlgorithm implements IntersectionAlgorithm {
             GeodeticPoint intersectionGP = null;
             double intersectionDot = Double.POSITIVE_INFINITY;
             for (final SimpleTile tile : scannedTiles) {
-                for (int i = latitudeIndex(tile, minLatitude); i < latitudeIndex(tile, maxLatitude); ++i) {
-                    for (int j = longitudeIndex(tile, minLongitude); j < longitudeIndex(tile, maxLongitude); ++j) {
+                for (int i = latitudeIndex(tile, minLatitude); i <= latitudeIndex(tile, maxLatitude); ++i) {
+                    for (int j = longitudeIndex(tile, minLongitude); j <= longitudeIndex(tile, maxLongitude); ++j) {
                         GeodeticPoint gp = tile.pixelIntersection(entryPoint, exitPoint, i, j);
                         if (gp != null) {
                             final Vector3D point = ellipsoid.transform(gp);
diff --git a/rugged-core/src/test/java/org/orekit/rugged/core/BasicScanAlgorithmTest.java b/rugged-core/src/test/java/org/orekit/rugged/core/BasicScanAlgorithmTest.java
index af14dd479541ae80b2ea712ed1d2962ac8fd4b63..dbf7e3f36d2c1e0f1f32ede17540584d3dee0738 100644
--- a/rugged-core/src/test/java/org/orekit/rugged/core/BasicScanAlgorithmTest.java
+++ b/rugged-core/src/test/java/org/orekit/rugged/core/BasicScanAlgorithmTest.java
@@ -214,7 +214,7 @@ public class BasicScanAlgorithmTest {
         Vector3D      position = state.getPVCoordinates(earth.getBodyFrame()).getPosition();
         Vector3D      los      = groundP.subtract(position);
         GeodeticPoint result   = basicScan.intersection(earth, position, los);
-        Assert.assertEquals(0.0, groundP.distance(earth.transform(result)), 0.03);
+        Assert.assertEquals(0.0, groundP.distance(earth.transform(result)), 1.0e-10);
 
     }