From 12040aaa65e1e2558bab78c632f24d66620709e8 Mon Sep 17 00:00:00 2001
From: Guylaine Prat <guylaine.prat@c-s.fr>
Date: Wed, 5 Oct 2016 15:44:17 +0200
Subject: [PATCH] Update inverse location example and exercise (due to Wiki
 update)

---
 src/tutorials/java/fr/cs/examples/InverseLocation.java |  9 ++++++---
 .../fr/cs/exercises/InverseLocationToBeCompleted.java  | 10 +++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/tutorials/java/fr/cs/examples/InverseLocation.java b/src/tutorials/java/fr/cs/examples/InverseLocation.java
index 9e630244..5520bff0 100644
--- a/src/tutorials/java/fr/cs/examples/InverseLocation.java
+++ b/src/tutorials/java/fr/cs/examples/InverseLocation.java
@@ -194,16 +194,19 @@ public class InverseLocation {
             Frame pvFrame = ruggedBuilder.getInertialFrame();
             
             // Initialize the RoughVisibilityEstimator
-            RoughVisibilityEstimator roughVisibilityEstimator= new RoughVisibilityEstimator(oneAxisEllipsoid, pvFrame, satellitePVList); 
+            RoughVisibilityEstimator roughVisibilityEstimator = new RoughVisibilityEstimator(oneAxisEllipsoid, pvFrame, satellitePVList); 
             
             // Compute the approximated line with a rough estimator    
             AbsoluteDate roughLineDate = roughVisibilityEstimator.estimateVisibility(gp);
             double roughLine = lineSensor.getLine(roughLineDate);
             
             // Compute the min / max lines interval using a margin around the roughLine
+            int sensorMinLine= 0;
+            int sensorMaxLine = 1000;
+            
             int margin = 100;
-            int minLineRough = (int) FastMath.max(FastMath.floor(roughLine - margin), 0);
-            int maxLineRough = (int) FastMath.floor(roughLine + margin);
+            int minLineRough = (int) FastMath.max(roughLine - margin, sensorMinLine);
+            int maxLineRough = (int) FastMath.min(roughLine + margin, sensorMaxLine);
             SensorPixel sensorPixelRoughLine = rugged.inverseLocation(sensorName, gp, minLineRough, maxLineRough);
 
             System.out.format(Locale.US, "Rough line found = %5.1f; InverseLocation gives (margin of %d around rough line): line = %5.3f, pixel = %5.3f %n", roughLine, margin, sensorPixelRoughLine.getLineNumber(), sensorPixel.getPixelNumber());
diff --git a/src/tutorials/java/fr/cs/exercises/InverseLocationToBeCompleted.java b/src/tutorials/java/fr/cs/exercises/InverseLocationToBeCompleted.java
index 52fa86a4..368abed4 100644
--- a/src/tutorials/java/fr/cs/exercises/InverseLocationToBeCompleted.java
+++ b/src/tutorials/java/fr/cs/exercises/InverseLocationToBeCompleted.java
@@ -194,7 +194,7 @@ public class InverseLocationToBeCompleted {
             // ######################################################################
             // Initialize the RoughVisibilityEstimator
             // ######################################################################
-            RoughVisibilityEstimator roughVisibilityEstimator= null; 
+            RoughVisibilityEstimator roughVisibilityEstimator = null; 
             
             // ######################################################################
             // Compute the approximated line with a rough estimator    
@@ -203,9 +203,13 @@ public class InverseLocationToBeCompleted {
             double roughLine = lineSensor.getLine(roughLineDate);
             
             // Compute the min / max lines interval using a margin around the roughLine
+            int sensorMinLine= 0;
+            int sensorMaxLine = 1000;
+            
             int margin = 100;
-            int minLineRough = (int) FastMath.max(FastMath.floor(roughLine - margin), 0);
-            int maxLineRough = (int) FastMath.floor(roughLine + margin);
+            int minLineRough = (int) FastMath.max(roughLine - margin, sensorMinLine);
+            int maxLineRough = (int) FastMath.min(roughLine + margin, sensorMaxLine);
+
             SensorPixel sensorPixelRoughLine = rugged.inverseLocation(sensorName, gp, minLineRough, maxLineRough);
 
             System.out.format(Locale.US, "Rough line found = %5.1f; InverseLocation gives (margin of %d around rough line): line = %5.3f, pixel = %5.3f %n", roughLine, margin, sensorPixelRoughLine.getLineNumber(), sensorPixel.getPixelNumber());
-- 
GitLab