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

Improved performance.

parent e5b04072
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
*/ */
package org.orekit.rugged.api; package org.orekit.rugged.api;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure; import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D; import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
...@@ -30,8 +33,17 @@ import org.orekit.utils.PVCoordinates; ...@@ -30,8 +33,17 @@ import org.orekit.utils.PVCoordinates;
/** Class dedicated to when ground point crosses mean sensor plane. */ /** Class dedicated to when ground point crosses mean sensor plane. */
class SensorMeanPlaneCrossing { class SensorMeanPlaneCrossing {
/** Converter between spacecraft and body. */ /** Number of points for frames interpolation. */
private final SpacecraftToObservedBody scToBody; private static final int INTERPOLATION_POINTS = 5;
/** Line numbers of the middle sample point. */
private final int midLine;
/** Transforms sample from observed body frame to inertial frame. */
private final List<Transform> bodyToInertial;
/** Transforms sample from spacecraft frame to inertial frame. */
private final List<Transform> scToInertial;
/** Minimum line number in the search interval. */ /** Minimum line number in the search interval. */
private final int minLine; private final int minLine;
...@@ -54,15 +66,6 @@ class SensorMeanPlaneCrossing { ...@@ -54,15 +66,6 @@ class SensorMeanPlaneCrossing {
/** Accuracy to use for finding crossing line number. */ /** Accuracy to use for finding crossing line number. */
private final double accuracy; private final double accuracy;
/** Middle line. */
private final double midLine;
/** Transform from observed body to inertial frame, for middle line. */
private final Transform midLineBodyToInert;
/** Transform from inertial frame to spacecraft frame, for middle line. */
private final Transform midLineScToInert;
/** Simple constructor. /** Simple constructor.
* @param sensor sensor to consider * @param sensor sensor to consider
* @param scToBody converter between spacecraft and body * @param scToBody converter between spacecraft and body
...@@ -84,7 +87,6 @@ class SensorMeanPlaneCrossing { ...@@ -84,7 +87,6 @@ class SensorMeanPlaneCrossing {
try { try {
this.sensor = sensor; this.sensor = sensor;
this.scToBody = scToBody;
this.minLine = minLine; this.minLine = minLine;
this.maxLine = maxLine; this.maxLine = maxLine;
this.lightTimeCorrection = lightTimeCorrection; this.lightTimeCorrection = lightTimeCorrection;
...@@ -94,10 +96,19 @@ class SensorMeanPlaneCrossing { ...@@ -94,10 +96,19 @@ class SensorMeanPlaneCrossing {
// compute one the transforms for middle line, as they will be reused // compute one the transforms for middle line, as they will be reused
// as the start point for all searches // as the start point for all searches
midLine = 0.5 * (minLine + maxLine); bodyToInertial = new ArrayList<Transform>(INTERPOLATION_POINTS);
final AbsoluteDate date = sensor.getDate(midLine); scToInertial = new ArrayList<Transform>(INTERPOLATION_POINTS);
midLineBodyToInert = scToBody.getInertialToBody(date).getInverse(); int middle = -1;
midLineScToInert = scToBody.getScToInertial(date); for (int i = 0; i < INTERPOLATION_POINTS; ++i) {
final int line = (i * maxLine + (INTERPOLATION_POINTS - i) * minLine) / INTERPOLATION_POINTS;
if (i == INTERPOLATION_POINTS / 2) {
middle = line;
}
final AbsoluteDate date = sensor.getDate(line);
bodyToInertial.add(scToBody.getInertialToBody(date).getInverse());
scToInertial.add(scToBody.getScToInertial(date));
}
midLine = middle;
} catch (OrekitException oe) { } catch (OrekitException oe) {
throw new RuggedException(oe, oe.getSpecifier(), oe.getParts()); throw new RuggedException(oe, oe.getSpecifier(), oe.getParts());
...@@ -173,8 +184,8 @@ class SensorMeanPlaneCrossing { ...@@ -173,8 +184,8 @@ class SensorMeanPlaneCrossing {
// We expect two or three evaluations only. Each new evaluation shows up quickly in // We expect two or three evaluations only. Each new evaluation shows up quickly in
// the performances as it involves frames conversions // the performances as it involves frames conversions
double crossingLine = midLine; double crossingLine = midLine;
Transform bodyToInert = midLineBodyToInert; Transform bodyToInert = bodyToInertial.get(INTERPOLATION_POINTS / 2);
Transform scToInert = midLineScToInert; Transform scToInert = scToInertial.get(INTERPOLATION_POINTS / 2);
boolean atMin = false; boolean atMin = false;
boolean atMax = false; boolean atMax = false;
for (int i = 0; i < maxEval; ++i) { for (int i = 0; i < maxEval; ++i) {
...@@ -213,8 +224,8 @@ class SensorMeanPlaneCrossing { ...@@ -213,8 +224,8 @@ class SensorMeanPlaneCrossing {
} }
final AbsoluteDate date = sensor.getDate(crossingLine); final AbsoluteDate date = sensor.getDate(crossingLine);
bodyToInert = scToBody.getInertialToBody(date).getInverse(); bodyToInert = Transform.interpolate(date, false, false, bodyToInertial);
scToInert = scToBody.getScToInertial(date); scToInert = Transform.interpolate(date, false, false, scToInertial);
} }
return null; return null;
......
...@@ -436,7 +436,7 @@ public class RuggedTest { ...@@ -436,7 +436,7 @@ public class RuggedTest {
throws RuggedException, OrekitException, URISyntaxException { throws RuggedException, OrekitException, URISyntaxException {
long t0 = System.currentTimeMillis(); long t0 = System.currentTimeMillis();
int dimension = 1000; int dimension = 2200;
String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath(); String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath();
DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path))); DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path)));
......
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