diff --git a/src/main/java/org/orekit/rugged/api/Rugged.java b/src/main/java/org/orekit/rugged/api/Rugged.java index 9820b0ca5dd98b36e60c6c36da67022f571dedc0..ab3a9c4d3fce122a93b5d297f53d2f1c942475f5 100644 --- a/src/main/java/org/orekit/rugged/api/Rugged.java +++ b/src/main/java/org/orekit/rugged/api/Rugged.java @@ -34,6 +34,7 @@ import org.orekit.rugged.linesensor.LineSensor; import org.orekit.rugged.linesensor.SensorMeanPlaneCrossing; import org.orekit.rugged.linesensor.SensorPixel; import org.orekit.rugged.linesensor.SensorPixelCrossing; +import org.orekit.rugged.los.PixelLOS; import org.orekit.rugged.refraction.AtmosphericRefraction; import org.orekit.rugged.utils.DSGenerator; import org.orekit.rugged.utils.ExtendedEllipsoid; @@ -302,24 +303,36 @@ public class Rugged { } if (atmosphericRefraction != null) { - // apply atmospheric refraction correction - final Vector3D pBody = inertToBody.transformPosition(pInert); - final Vector3D lBody = inertToBody.transformVector(lInert); - gp[i] = atmosphericRefraction.applyCorrection(pBody, lBody, (NormalizedGeodeticPoint) gp[i], algorithm); + // compute atmospheric refraction + + // Test if optimization is not required + if (! atmosphericRefraction.isOptimized()) { + + // apply atmospheric refraction correction + final Vector3D pBody = inertToBody.transformPosition(pInert); + final Vector3D lBody = inertToBody.transformVector(lInert); + gp[i] = atmosphericRefraction.applyCorrection(pBody, lBody, (NormalizedGeodeticPoint) gp[i], algorithm); + + } else { // Optimization is required + + // TODO algo with optimization + + } } DumpManager.dumpDirectLocationResult(gp[i]); - } return gp; - } /** Direct location of a single line-of-sight. - * TBN: for simplicity, due to the size of sensor, we consider each pixel to be at sensor position + * <br> + * NB: if (the optionnal) atmospheric refraction must be computed with the optimization algorithm, + * see {@link #directLocation(AbsoluteDate, Vector3D, PixelLOS)}) * @param date date of the location - * @param sensorPosition sensor position in spacecraft frame + * @param sensorPosition sensor position in spacecraft frame. For simplicity, due to the size of sensor, + * we consider each pixel to be at sensor position * @param los normalized line-of-sight in spacecraft frame * @return ground position of intersection point between specified los and ground * @exception RuggedException if line cannot be localized, or sensor is unknown @@ -327,6 +340,24 @@ public class Rugged { public GeodeticPoint directLocation(final AbsoluteDate date, final Vector3D sensorPosition, final Vector3D los) throws RuggedException { + // Set the pixel to null in order not to compute atmosphere with optimization + final PixelLOS pixelLOS = new PixelLOS(null, los); + + return directLocation(date, sensorPosition, pixelLOS); + } + + + /** Direct location of a single line-of-sight. + * @param date date of the location + * @param sensorPosition sensor position in spacecraft frame. For simplicity, due to the size of sensor, + * we consider each pixel to be at sensor position + * @param pixelLOS pixel definition with normalized line-of-sight in spacecraft frame + * @return ground position of intersection point between specified los and ground + * @exception RuggedException if line cannot be localized, or sensor is unknown + */ + public GeodeticPoint directLocation(final AbsoluteDate date, final Vector3D sensorPosition, final PixelLOS pixelLOS) throws RuggedException { + + final Vector3D los = pixelLOS.getLOS(); DumpManager.dumpDirectLocation(date, sensorPosition, los, lightTimeCorrection, aberrationOfLightCorrection, atmosphericRefraction != null); @@ -342,9 +373,10 @@ public class Rugged { // TBN: for simplicity, due to the size of sensor, we consider each pixel to be at sensor position final Vector3D pInert = scToInert.transformPosition(sensorPosition); - // compute location of specified pixel + // compute line of sight in inertial frame final Vector3D obsLInert = scToInert.transformVector(los); final Vector3D lInert; + if (aberrationOfLightCorrection) { // apply aberration of light correction // as the spacecraft velocity is small with respect to speed of light, @@ -363,7 +395,9 @@ public class Rugged { lInert = obsLInert; } + // compute ground location of specified pixel final NormalizedGeodeticPoint gp; + if (lightTimeCorrection) { // compute DEM intersection with light time correction // TBN: for simplicity, due to the size of sensor, we consider each pixel to be at sensor position @@ -392,21 +426,28 @@ public class Rugged { algorithm.intersection(ellipsoid, pBody, lBody)); } - final NormalizedGeodeticPoint result; + // compute the ground location with atmospheric correction if asked for + NormalizedGeodeticPoint result = gp; + if (atmosphericRefraction != null) { - // apply atmospheric refraction correction - final Vector3D pBody = inertToBody.transformPosition(pInert); - final Vector3D lBody = inertToBody.transformVector(lInert); - result = atmosphericRefraction.applyCorrection(pBody, lBody, gp, algorithm); + // compute atmospheric refraction - } else { - // don't apply atmospheric refraction correction - result = gp; + // Test if optimization is not required or if sensor pixel is not defined + if (! atmosphericRefraction.isOptimized() || pixelLOS.getSensorPixel() == null) { + + // apply atmospheric refraction correction + final Vector3D pBody = inertToBody.transformPosition(pInert); + final Vector3D lBody = inertToBody.transformVector(lInert); + result = atmosphericRefraction.applyCorrection(pBody, lBody, gp, algorithm); + + } else { // Optimization is required and sensor pixel is defined + + // TODO algo with optimization + } } DumpManager.dumpDirectLocationResult(result); return result; - } /** Find the date at which sensor sees a ground point. diff --git a/src/main/java/org/orekit/rugged/los/PixelLOS.java b/src/main/java/org/orekit/rugged/los/PixelLOS.java new file mode 100644 index 0000000000000000000000000000000000000000..e68703921b5381ea901d312a779a9126276bbb7f --- /dev/null +++ b/src/main/java/org/orekit/rugged/los/PixelLOS.java @@ -0,0 +1,56 @@ +package org.orekit.rugged.los; + +import java.io.Serializable; + +import org.hipparchus.geometry.euclidean.threed.Vector3D; +import org.orekit.rugged.linesensor.SensorPixel; + + +/** Container for pixel line-of-sight. + * <p> + * Instances of this class are guaranteed to be immutable. + * </p> + * @author Guylaine Prat + * @since 3.0 + */ +public class PixelLOS implements Serializable { + + /** Serializable UID. */ + private static final long serialVersionUID = -6674056279573271367L; + + /** Sensor pixel. */ + private final SensorPixel sensorPixel; + + /** Pixel line-of-sight in spacecraft frame. */ + private final Vector3D los; + + /** + * Build a new instance. + * @param sensorPixel the sensor pixel cell + * @param los the pixel line-of-sight in spacecraft frame + */ + public PixelLOS(final SensorPixel sensorPixel, final Vector3D los) { + this.sensorPixel = sensorPixel; + this.los = los; + } + + /** + * @return the sensorPixel + */ + public SensorPixel getSensorPixel() { + return sensorPixel; + } + + /** + * @return the lOS in spacecraft frame + */ + public Vector3D getLOS() { + return los; + } + + @Override + public String toString() { + return "{Sensor pixel: " + sensorPixel.toString() + + ", LOS: " + los.toString() + "}"; + } +}