From 8cc8c265bd9a2f6eb832bb2fb069bb94dded04b4 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe <luc@orekit.org> Date: Tue, 23 Aug 2016 15:00:12 +0200 Subject: [PATCH] Fixed a singular matrix occurrence problem. When the same inverse location problem was performed several times in raw, the same result was added several times in the cache. This lead to singular matrices being created as sample points were not independent. --- .../linesensor/SensorMeanPlaneCrossing.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/orekit/rugged/linesensor/SensorMeanPlaneCrossing.java b/src/main/java/org/orekit/rugged/linesensor/SensorMeanPlaneCrossing.java index 96bf4d97..7715ca6d 100644 --- a/src/main/java/org/orekit/rugged/linesensor/SensorMeanPlaneCrossing.java +++ b/src/main/java/org/orekit/rugged/linesensor/SensorMeanPlaneCrossing.java @@ -419,12 +419,22 @@ public class SensorMeanPlaneCrossing { } if (FastMath.abs(deltaL) <= accuracy) { // return immediately, without doing any additional evaluation! - if (cachedResults.size() >= CACHED_RESULTS) { - cachedResults.remove(cachedResults.size() - 1); + final CrossingResult crossingResult = + new CrossingResult(sensor.getDate(crossingLine), crossingLine, target, + targetDirection[0], targetDirection[1]); + boolean isNew = true; + for (final CrossingResult existing : cachedResults) { + isNew = isNew && FastMath.abs(crossingLine - existing.crossingLine) > accuracy; } - cachedResults.add(0, new CrossingResult(sensor.getDate(crossingLine), crossingLine, target, - targetDirection[0], targetDirection[1])); - return cachedResults.get(0); + if (isNew) { + // this result is different from the existing ones, + // it brings new sampling data to the cache + if (cachedResults.size() >= CACHED_RESULTS) { + cachedResults.remove(cachedResults.size() - 1); + } + cachedResults.add(0, crossingResult); + } + return crossingResult; } for (int j = 0; j < i; ++j) { if (FastMath.abs(crossingLine - crossingLineHistory[j]) <= 1.0) { -- GitLab