Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • orekit/rugged
  • sdinot/rugged
  • yzokras/rugged
  • youngcle/rugged-mod
4 results
Show changes
Showing
with 441 additions and 271 deletions
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* This package provides the Digital Elevation Model intersection using
* Bernardt Duvenhage's algorithm.
*
* @author Luc Maisonobe
* @author Guylaine Prat
*
*/
package org.orekit.rugged.intersection.duvenhage;
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* This package provides the interface for Digital Elevation Model intersection
* algorithm, as well as some simple implementations.
*
*
* @author Luc Maisonobe
* @author Guylaine Prat
*
*/
package org.orekit.rugged.intersection;
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -30,6 +30,12 @@ public interface LineDatation {
*/
AbsoluteDate getDate(double lineNumber);
/** Get the line for a given date.
* @param date date
* @return line number
*/
double getLine(AbsoluteDate date);
/** Get the rate of lines scanning.
* @param lineNumber line number
* @return rate of lines scanning (lines / seconds)
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -18,18 +18,19 @@ package org.orekit.rugged.linesensor;
import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.Derivative;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.orekit.rugged.errors.DumpManager;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.los.TimeDependentLOS;
import org.orekit.rugged.utils.DSGenerator;
import org.orekit.rugged.utils.DerivativeGenerator;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Line sensor model.
* @author Luc Maisonobe
* @author Guylaine Prat
*/
public class LineSensor {
......@@ -88,39 +89,83 @@ public class LineSensor {
* @param date current date
* @param i pixel index (must be between 0 and {@link #getNbPixels()} - 1
* @return pixel normalized line-of-sight
* @exception RuggedException if date cannot be handled
*/
public Vector3D getLOS(final AbsoluteDate date, final int i)
throws RuggedException {
public Vector3D getLOS(final AbsoluteDate date, final int i) {
final Vector3D l = los.getLOS(i, date);
DumpManager.dumpSensorLOS(this, date, i, l);
return l;
}
/** Get the pixel normalized interpolated line-of-sight at some date.
* @param date current date
* @param i pixel index (must be between 0 and {@link #getNbPixels()} - 1
* @return pixel normalized line-of-sight
* @since 2.0
*/
public Vector3D getLOS(final AbsoluteDate date, final double i) {
final int iInf = FastMath.max(0, FastMath.min(getNbPixels() - 2, (int) FastMath.floor(i)));
final int iSup = iInf + 1;
final Vector3D interpolatedLos = new Vector3D(iSup - i, los.getLOS(iInf, date),
i - iInf, los.getLOS(iSup, date));
return interpolatedLos;
}
/** Get the pixel normalized line-of-sight at some date,
* and their derivatives with respect to estimated parameters.
* @param <T> derivative type
* @param date current date
* @param i pixel index (must be between 0 and {@link #getNbPixels()} - 1
* @param generator generator to use for building {@link DerivativeStructure} instances
* @param generator generator to use for building {@link Derivative} instances
* @return pixel normalized line-of-sight
*/
public FieldVector3D<DerivativeStructure> getLOSDerivatives(final AbsoluteDate date, final int i,
final DSGenerator generator) {
public <T extends Derivative<T>> FieldVector3D<T> getLOSDerivatives(final AbsoluteDate date, final int i,
final DerivativeGenerator<T> generator) {
return los.getLOSDerivatives(i, date, generator);
}
/** Get the pixel normalized line-of-sight at some date,
* and their derivatives with respect to estimated parameters.
* @param <T> derivative type
* @param date current date
* @param i pixel index (must be between 0 and {@link #getNbPixels()} - 1
* @param generator generator to use for building {@link Derivative} instances
* @return pixel normalized line-of-sight
* @since 2.0
*/
public <T extends Derivative<T>> FieldVector3D<T> getLOSDerivatives(final AbsoluteDate date, final double i,
final DerivativeGenerator<T> generator) {
// find surrounding pixels of pixelB (in order to interpolate LOS from pixelB (that is not an integer)
final int iInf = FastMath.max(0, FastMath.min(getNbPixels() - 2, (int) FastMath.floor(i)));
final int iSup = iInf + 1;
final FieldVector3D<T> interpolatedLos =
new FieldVector3D<> (iSup - i, los.getLOSDerivatives(iInf, date, generator),
i - iInf, los.getLOSDerivatives(iSup, date, generator)).normalize();
return interpolatedLos;
}
/** Get the date.
* @param lineNumber line number
* @return date corresponding to line number
* @exception RuggedException if date cannot be handled
*/
public AbsoluteDate getDate(final double lineNumber)
throws RuggedException {
public AbsoluteDate getDate(final double lineNumber) {
final AbsoluteDate date = datationModel.getDate(lineNumber);
DumpManager.dumpSensorDatation(this, lineNumber, date);
return date;
}
/** Get the line number.
* @param date date
* @return line number corresponding to date
*/
public double getLine(final AbsoluteDate date) {
final double lineNumber = datationModel.getLine(date);
DumpManager.dumpSensorDatation(this, lineNumber, date);
return lineNumber;
}
/** Get the rate of lines scanning.
* @param lineNumber line number
* @return rate of lines scanning (lines / seconds)
......@@ -138,4 +183,11 @@ public class LineSensor {
return position;
}
/** Dump the rate for the current line number.
* @param lineNumber line number
*/
public void dumpRate(final double lineNumber) {
final double rate = datationModel.getRate(lineNumber);
DumpManager.dumpSensorRate(this, lineNumber, rate);
}
}
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -54,6 +54,12 @@ public class LinearLineDatation implements LineDatation {
return referenceDate.shiftedBy((lineNumber - referenceLine) / rate);
}
/** {@inheritDoc} */
@Override
public double getLine(final AbsoluteDate date) {
return referenceLine + rate * date.durationFrom(referenceDate);
}
/** {@inheritDoc} */
@Override
public double getRate(final double lineNumber) {
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -38,7 +38,7 @@ import org.hipparchus.util.FastMath;
import org.hipparchus.util.Precision;
import org.orekit.frames.Transform;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.errors.RuggedExceptionWrapper;
import org.orekit.rugged.errors.RuggedInternalError;
import org.orekit.rugged.utils.SpacecraftToObservedBody;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
......@@ -103,15 +103,13 @@ public class SensorMeanPlaneCrossing {
* @param aberrationOfLightCorrection flag for aberration of light correction.
* @param maxEval maximum number of evaluations
* @param accuracy accuracy to use for finding crossing line number
* @exception RuggedException if some frame conversion fails
*/
public SensorMeanPlaneCrossing(final LineSensor sensor,
final SpacecraftToObservedBody scToBody,
final int minLine, final int maxLine,
final boolean lightTimeCorrection,
final boolean aberrationOfLightCorrection,
final int maxEval, final double accuracy)
throws RuggedException {
final int maxEval, final double accuracy) {
this(sensor, scToBody, minLine, maxLine, lightTimeCorrection, aberrationOfLightCorrection,
maxEval, accuracy, computeMeanPlaneNormal(sensor, minLine, maxLine),
Stream.<CrossingResult>empty());
......@@ -128,7 +126,6 @@ public class SensorMeanPlaneCrossing {
* @param accuracy accuracy to use for finding crossing line number
* @param meanPlaneNormal mean plane normal
* @param cachedResults cached results
* @exception RuggedException if some frame conversion fails
*/
public SensorMeanPlaneCrossing(final LineSensor sensor,
final SpacecraftToObservedBody scToBody,
......@@ -137,8 +134,7 @@ public class SensorMeanPlaneCrossing {
final boolean aberrationOfLightCorrection,
final int maxEval, final double accuracy,
final Vector3D meanPlaneNormal,
final Stream<CrossingResult> cachedResults)
throws RuggedException {
final Stream<CrossingResult> cachedResults) {
this.sensor = sensor;
this.minLine = minLine;
......@@ -156,7 +152,7 @@ public class SensorMeanPlaneCrossing {
this.meanPlaneNormal = meanPlaneNormal;
this.cachedResults = new ArrayList<CrossingResult>(CACHED_RESULTS);
this.cachedResults = new ArrayList<>(CACHED_RESULTS);
cachedResults.forEach(crossingResult -> {
if (crossingResult != null && this.cachedResults.size() < CACHED_RESULTS) {
this.cachedResults.add(crossingResult);
......@@ -174,10 +170,8 @@ public class SensorMeanPlaneCrossing {
* order corresponds to trigonometric order (i.e. counterclockwise).
* </p>
* @return normal of the mean plane
* @exception RuggedException if mid date cannot be handled
*/
private static Vector3D computeMeanPlaneNormal(final LineSensor sensor, final int minLine, final int maxLine)
throws RuggedException {
private static Vector3D computeMeanPlaneNormal(final LineSensor sensor, final int minLine, final int maxLine) {
final AbsoluteDate midDate = sensor.getDate(0.5 * (minLine + maxLine));
......@@ -343,6 +337,7 @@ public class SensorMeanPlaneCrossing {
/** Get the derivative of the normalized target direction in spacecraft frame at crossing.
* @return derivative of the normalized target direction in spacecraft frame at crossing
* with respect to line number
* @since 2.0
*/
public Vector3D getTargetDirectionDerivative() {
return targetDirectionDerivative;
......@@ -354,11 +349,8 @@ public class SensorMeanPlaneCrossing {
* @param target target ground point
* @return line number and target direction at mean plane crossing,
* or null if search interval does not bracket a solution
* @exception RuggedException if geometry cannot be computed for some line or
* if the maximum number of evaluations is exceeded
*/
public CrossingResult find(final Vector3D target)
throws RuggedException {
public CrossingResult find(final Vector3D target) {
double crossingLine = midLine;
Transform bodyToInert = midBodyToInert;
......@@ -523,13 +515,10 @@ public class SensorMeanPlaneCrossing {
* @param initialGuess initial guess for the crossing line
* @return line number and target direction at mean plane crossing,
* or null if search interval does not bracket a solution
* @exception RuggedException if geometry cannot be computed for some line or
* if the maximum number of evaluations is exceeded
*/
private CrossingResult slowFind(final PVCoordinates targetPV, final double initialGuess)
throws RuggedException {
try {
private CrossingResult slowFind(final PVCoordinates targetPV, final double initialGuess) {
try {
// safety check
final double startValue;
if (initialGuess < minLine || initialGuess > maxLine) {
......@@ -539,17 +528,17 @@ public class SensorMeanPlaneCrossing {
}
final UnivariateSolver solver = new BracketingNthOrderBrentSolver(accuracy, 5);
double crossingLine = solver.solve(maxEval, new UnivariateFunction() {
final double crossingLine = solver.solve(maxEval, new UnivariateFunction() {
/** {@inheritDoc} */
@Override
public double value(final double x) throws RuggedExceptionWrapper {
public double value(final double x) {
try {
final AbsoluteDate date = sensor.getDate(x);
final Vector3D[] targetDirection =
evaluateLine(x, targetPV, scToBody.getBodyToInertial(date), scToBody.getScToInertial(date));
return 0.5 * FastMath.PI - FastMath.acos(Vector3D.dotProduct(targetDirection[0], meanPlaneNormal));
} catch (RuggedException re) {
throw new RuggedExceptionWrapper(re);
throw new RuggedInternalError(re);
}
}
}, minLine, maxLine, startValue);
......@@ -562,8 +551,6 @@ public class SensorMeanPlaneCrossing {
} catch (MathIllegalArgumentException nbe) {
return null;
} catch (RuggedExceptionWrapper rew) {
throw rew.getException();
}
}
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -23,7 +23,7 @@ import org.hipparchus.exception.MathIllegalArgumentException;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.errors.RuggedExceptionWrapper;
import org.orekit.rugged.errors.RuggedInternalError;
import org.orekit.time.AbsoluteDate;
/** Class devoted to locate where ground point crosses a sensor line.
......@@ -69,20 +69,19 @@ public class SensorPixelCrossing {
* @param date current date
* @return pixel location ({@code Double.NaN} if the first and last
* pixels of the line do not bracket a location)
* @exception RuggedException if the maximum number of evaluations is exceeded
*/
public double locatePixel(final AbsoluteDate date) throws RuggedException {
public double locatePixel(final AbsoluteDate date) {
try {
// set up function evaluating to 0.0 where target matches pixel
final UnivariateFunction f = new UnivariateFunction() {
/** {@inheritDoc} */
@Override
public double value(final double x) throws RuggedExceptionWrapper {
public double value(final double x) {
try {
return Vector3D.angle(cross, getLOS(date, x)) - 0.5 * FastMath.PI;
} catch (RuggedException re) {
throw new RuggedExceptionWrapper(re);
throw new RuggedInternalError(re);
}
}
};
......@@ -95,8 +94,6 @@ public class SensorPixelCrossing {
} catch (MathIllegalArgumentException nbe) {
// there are no solutions in the search interval
return Double.NaN;
} catch (RuggedExceptionWrapper rew) {
throw rew.getException();
}
}
......@@ -104,10 +101,8 @@ public class SensorPixelCrossing {
* @param date current date
* @param x pixel index
* @return interpolated direction for specified index
* @exception RuggedException if date cannot be handled
*/
private Vector3D getLOS(final AbsoluteDate date, final double x)
throws RuggedException {
private Vector3D getLOS(final AbsoluteDate date, final double x) {
// find surrounding pixels
final int iInf = FastMath.max(0, FastMath.min(sensor.getNbPixels() - 2, (int) FastMath.floor(x)));
......
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* This package provides all the tools needed to deal with line sensor model.
*
* @author Luc Maisonobe
* @author Guylaine Prat
*
*/
package org.orekit.rugged.linesensor;
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -18,16 +18,14 @@ package org.orekit.rugged.los;
import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.Derivative;
import org.hipparchus.geometry.euclidean.threed.FieldRotation;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Rotation;
import org.hipparchus.geometry.euclidean.threed.RotationConvention;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.utils.DSGenerator;
import org.orekit.rugged.utils.DerivativeGenerator;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.ParameterObserver;
......@@ -52,7 +50,7 @@ public class FixedRotation implements TimeIndependentLOSTransform {
private Rotation rotation;
/** Underlying rotation with derivatives. */
private FieldRotation<DerivativeStructure> rDS;
private FieldRotation<?> rDS;
/** Driver for rotation angle. */
private final ParameterDriver angleDriver;
......@@ -66,23 +64,19 @@ public class FixedRotation implements TimeIndependentLOSTransform {
* @param angle rotation angle
*/
public FixedRotation(final String name, final Vector3D axis, final double angle) {
this.axis = axis;
this.rotation = null;
this.rDS = null;
try {
this.angleDriver = new ParameterDriver(name, angle, SCALE, -2 * FastMath.PI, 2 * FastMath.PI);
angleDriver.addObserver(new ParameterObserver() {
@Override
public void valueChanged(final double previousValue, final ParameterDriver driver) {
// reset rotations to null, they will be evaluated lazily if needed
rotation = null;
rDS = null;
}
});
} catch (OrekitException oe) {
// this should never happen
throw RuggedException.createInternalError(oe);
}
this.angleDriver = new ParameterDriver(name, angle, SCALE, -2 * FastMath.PI, 2 * FastMath.PI);
angleDriver.addObserver(new ParameterObserver() {
@Override
public void valueChanged(final double previousValue, final ParameterDriver driver) {
// reset rotations to null, they will be evaluated lazily if needed
rotation = null;
rDS = null;
}
});
}
/** {@inheritDoc} */
......@@ -102,19 +96,31 @@ public class FixedRotation implements TimeIndependentLOSTransform {
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public FieldVector3D<DerivativeStructure> transformLOS(final int i, final FieldVector3D<DerivativeStructure> los,
final DSGenerator generator) {
if (rDS == null) {
public <T extends Derivative<T>> FieldVector3D<T> transformLOS(final int i, final FieldVector3D<T> los,
final DerivativeGenerator<T> generator) {
final FieldRotation<T> rD;
if (rDS == null || !rDS.getQ0().getField().equals(generator.getField())) {
// lazy evaluation of the rotation
final FieldVector3D<DerivativeStructure> axisDS =
new FieldVector3D<DerivativeStructure>(generator.constant(axis.getX()),
generator.constant(axis.getY()),
generator.constant(axis.getZ()));
final DerivativeStructure angleDS = generator.variable(angleDriver);
rDS = new FieldRotation<DerivativeStructure>(axisDS, angleDS, RotationConvention.VECTOR_OPERATOR);
final FieldVector3D<T> axisDS =
new FieldVector3D<>(generator.constant(axis.getX()),
generator.constant(axis.getY()),
generator.constant(axis.getZ()));
final T angleDS = generator.variable(angleDriver);
rD = new FieldRotation<>(axisDS, angleDS, RotationConvention.VECTOR_OPERATOR);
// cache evaluated rotation
rDS = rD;
} else {
// reuse cached value
rD = (FieldRotation<T>) rDS;
}
return rDS.applyTo(los);
return rD.applyTo(los);
}
}
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -18,20 +18,19 @@ package org.orekit.rugged.los;
import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.Derivative;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.utils.DSGenerator;
import org.orekit.rugged.utils.DerivativeGenerator;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.ParameterObserver;
/** {@link TimeIndependentLOSTransform LOS transform} based on a homothety along the Z axis.
* inspired from FixedZHomothety / s2geolib
* @author Lucie Labatallee
* @author Guylaine Prat
* @see LOSBuilder
* @since 2.0
*/
public class FixedZHomothety implements TimeIndependentLOSTransform {
......@@ -41,13 +40,13 @@ public class FixedZHomothety implements TimeIndependentLOSTransform {
* in the multiplications/divisions sequences.
* </p>
*/
private final double SCALE = FastMath.scalb(1.0, -20);
private final double SCALE = FastMath.scalb(1.0, 0);
/** Homothety factor. */
private double factor;
/** Underlying homothety with derivatives. */
private DerivativeStructure factorDS;
private Derivative<?> factorDS;
/** Driver for homothety factor. */
private final ParameterDriver factorDriver;
......@@ -57,26 +56,21 @@ public class FixedZHomothety implements TimeIndependentLOSTransform {
* The single parameter is the homothety factor.
* </p>
* @param name name of the homothety (used for estimated parameters identification)
* @param factor homothety factor
* @param factorvalue homothety factor
*/
public FixedZHomothety(final String name, final double factorvalue) {
this.factor = factorvalue;
this.factorDS = null;
try {
this.factorDriver = new ParameterDriver(name, factorvalue, SCALE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
factorDriver.addObserver(new ParameterObserver() {
@Override
public void valueChanged(final double previousValue, final ParameterDriver driver) {
// reset factor to zero, they will be evaluated lazily if needed
factor = 0.0;
// System.out.format("Value changed: %f %n", factorDriver.getValue());
factorDS = null;
}
});
} catch (OrekitException oe) {
// this should never happen
throw RuggedException.createInternalError(oe);
}
this.factor = factorvalue;
this.factorDS = null;
this.factorDriver = new ParameterDriver(name, factorvalue, SCALE, 0, Double.POSITIVE_INFINITY);
factorDriver.addObserver(new ParameterObserver() {
@Override
public void valueChanged(final double previousValue, final ParameterDriver driver) {
// reset factor to zero, they will be evaluated lazily if needed
factor = 0.0;
factorDS = null;
}
});
}
/** {@inheritDoc} */
......@@ -88,23 +82,35 @@ public class FixedZHomothety implements TimeIndependentLOSTransform {
/** {@inheritDoc} */
@Override
public Vector3D transformLOS(final int i, final Vector3D los) {
if (factor == 0.0) {
// lazy evaluation of the homothety
if (factor == 0.0) {
// lazy evaluation of the homothety
factor = factorDriver.getValue();
}
return new Vector3D(los.getX(), los.getY(), factor*los.getZ());
return new Vector3D(los.getX(), los.getY(), factor * los.getZ());
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public FieldVector3D<DerivativeStructure> transformLOS(final int i, final FieldVector3D<DerivativeStructure> los,
final DSGenerator generator) {
if (factorDS == null) {
public <T extends Derivative<T>> FieldVector3D<T> transformLOS(final int i, final FieldVector3D<T> los,
final DerivativeGenerator<T> generator) {
final T factorD;
if (factorDS == null || !factorDS.getField().equals(generator.getField())) {
// lazy evaluation of the homothety
factorDS = generator.variable(factorDriver);
factorD = generator.variable(factorDriver);
// cache evaluated homothety
factorDS = factorD;
} else {
// reuse cached value
factorD = (T) factorDS;
}
return new FieldVector3D<DerivativeStructure>(los.getX(), los.getY(), factorDS.multiply(los.getZ()));
return new FieldVector3D<>(los.getX(), los.getY(), factorD.multiply(los.getZ()));
}
}
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -21,12 +21,10 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.Derivative;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.orekit.errors.OrekitException;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.utils.DSGenerator;
import org.orekit.rugged.utils.DerivativeGenerator;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.ParameterObserver;
......@@ -51,7 +49,7 @@ import org.orekit.utils.ParameterObserver;
*/
public class LOSBuilder {
/** Raw fixed ine-of-sights. */
/** Raw fixed line-of-sights. */
private final List<Vector3D> rawLOS;
/** Transforms to be applied. */
......@@ -65,7 +63,7 @@ public class LOSBuilder {
*/
public LOSBuilder(final List<Vector3D> rawLOS) {
this.rawLOS = rawLOS;
this.transforms = new ArrayList<LOSTransform>();
this.transforms = new ArrayList<>();
this.timeIndependent = true;
}
......@@ -124,8 +122,8 @@ public class LOSBuilder {
/** {@inheritDoc} */
@Override
public FieldVector3D<DerivativeStructure> transformLOS(final int i, final FieldVector3D<DerivativeStructure> los,
final AbsoluteDate date, final DSGenerator generator) {
public <T extends Derivative<T>> FieldVector3D<T> transformLOS(final int i, final FieldVector3D<T> los,
final AbsoluteDate date, final DerivativeGenerator<T> generator) {
return transform.transformLOS(i, los, generator);
}
......@@ -160,7 +158,7 @@ public class LOSBuilder {
this.raw[i] = raw.get(i);
}
this.transforms = new ArrayList<LOSTransform>(transforms);
this.transforms = new ArrayList<>(transforms);
}
......@@ -181,14 +179,13 @@ public class LOSBuilder {
/** {@inheritDoc} */
@Override
public FieldVector3D<DerivativeStructure> getLOSDerivatives(final int index, final AbsoluteDate date,
final DSGenerator generator) {
public <T extends Derivative<T>> FieldVector3D<T> getLOSDerivatives(final int index, final AbsoluteDate date,
final DerivativeGenerator<T> generator) {
// the raw line of sights are considered to be constant
FieldVector3D<DerivativeStructure> los =
new FieldVector3D<DerivativeStructure>(generator.constant(raw[index].getX()),
generator.constant(raw[index].getY()),
generator.constant(raw[index].getZ()));
FieldVector3D<T> los = new FieldVector3D<>(generator.constant(raw[index].getX()),
generator.constant(raw[index].getY()),
generator.constant(raw[index].getZ()));
// apply the transforms, which depend on parameters and hence may introduce non-zero derivatives
for (final LOSTransform transform : transforms) {
......@@ -234,14 +231,8 @@ public class LOSBuilder {
}
};
getParametersDrivers().forEach(driver -> {
try {
driver.addObserver(resettingObserver);
} catch (OrekitException oe) {
// this should never happen
throw RuggedException.createInternalError(oe);
}
driver.addObserver(resettingObserver);
});
}
/** {@inheritDoc} */
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -18,14 +18,15 @@ package org.orekit.rugged.los;
import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.Derivative;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.orekit.rugged.utils.DSGenerator;
import org.orekit.rugged.utils.DerivativeGenerator;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Interface for lines-of-sight tranforms.
/** Interface for lines-of-sight transforms.
* @author Luc Maisonobe
* @see LOSBuilder
*/
......@@ -46,14 +47,15 @@ public interface LOSTransform {
* are typically polynomials coefficients representing rotation angles.
* These polynomials can be used for example to model thermo-elastic effects.
* </p>
* @param <T> derivative type
* @param index los pixel index
* @param date date
* @param los line-of-sight to transform
* @param date date
* @param generator generator to use for building {@link DerivativeStructure} instances
* @return line of sight, and its first partial derivatives with respect to the parameters
*/
FieldVector3D<DerivativeStructure> transformLOS(int index, FieldVector3D<DerivativeStructure> los,
AbsoluteDate date, DSGenerator generator);
<T extends Derivative<T>> FieldVector3D<T> transformLOS(int index, FieldVector3D<T> los,
AbsoluteDate date, DerivativeGenerator<T> generator);
/** Get the drivers for LOS parameters.
* @return drivers for LOS parameters
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -18,7 +18,8 @@ package org.orekit.rugged.los;
import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.Field;
import org.hipparchus.analysis.differentiation.Derivative;
import org.hipparchus.analysis.polynomials.PolynomialFunction;
import org.hipparchus.geometry.euclidean.threed.FieldRotation;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
......@@ -26,9 +27,8 @@ import org.hipparchus.geometry.euclidean.threed.Rotation;
import org.hipparchus.geometry.euclidean.threed.RotationConvention;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.utils.DSGenerator;
import org.hipparchus.util.MathArrays;
import org.orekit.rugged.utils.DerivativeGenerator;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
import org.orekit.utils.ParameterObserver;
......@@ -54,10 +54,10 @@ public class PolynomialRotation implements LOSTransform {
private PolynomialFunction angle;
/** Rotation axis and derivatives. */
private FieldVector3D<DerivativeStructure> axisDS;
private FieldVector3D<?> axisDS;
/** Rotation angle polynomial and derivatives. */
private DerivativeStructure[] angleDS;
private Derivative<?>[] angleDS;
/** Reference date for polynomial evaluation. */
private final AbsoluteDate referenceDate;
......@@ -81,7 +81,7 @@ public class PolynomialRotation implements LOSTransform {
public PolynomialRotation(final String name,
final Vector3D axis,
final AbsoluteDate referenceDate,
final double ... angleCoeffs) {
final double... angleCoeffs) {
this.axis = axis;
this.referenceDate = referenceDate;
this.coefficientsDrivers = new ParameterDriver[angleCoeffs.length];
......@@ -94,15 +94,10 @@ public class PolynomialRotation implements LOSTransform {
angleDS = null;
}
};
try {
for (int i = 0; i < angleCoeffs.length; ++i) {
coefficientsDrivers[i] = new ParameterDriver(name + "[" + i + "]", angleCoeffs[i], SCALE,
Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
coefficientsDrivers[i].addObserver(resettingObserver);
}
} catch (OrekitException oe) {
// this should never happen
throw RuggedException.createInternalError(oe);
for (int i = 0; i < angleCoeffs.length; ++i) {
coefficientsDrivers[i] = new ParameterDriver(name + "[" + i + "]", angleCoeffs[i], SCALE,
Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
coefficientsDrivers[i].addObserver(resettingObserver);
}
}
......@@ -125,7 +120,9 @@ public class PolynomialRotation implements LOSTransform {
this(name, axis, referenceDate, angle.getCoefficients());
}
/** {@inheritDoc} */
/** {@inheritDoc}
* @since 2.0
*/
@Override
public Stream<ParameterDriver> getParametersDrivers() {
return Stream.of(coefficientsDrivers);
......@@ -148,30 +145,44 @@ public class PolynomialRotation implements LOSTransform {
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public FieldVector3D<DerivativeStructure> transformLOS(final int i, final FieldVector3D<DerivativeStructure> los,
final AbsoluteDate date, final DSGenerator generator) {
public <T extends Derivative<T>> FieldVector3D<T> transformLOS(final int i, final FieldVector3D<T> los,
final AbsoluteDate date,
final DerivativeGenerator<T> generator) {
final Field<T> field = generator.getField();
final FieldVector3D<T> axisD;
final T[] angleD;
if (axisDS == null || !axisDS.getX().getField().equals(field)) {
if (angleDS == null) {
// lazy evaluation of the rotation
axisDS = new FieldVector3D<DerivativeStructure>(generator.constant(axis.getX()),
generator.constant(axis.getY()),
generator.constant(axis.getZ()));
angleDS = new DerivativeStructure[coefficientsDrivers.length];
for (int k = 0; k < angleDS.length; ++k) {
angleDS[k] = generator.variable(coefficientsDrivers[k]);
axisD = new FieldVector3D<>(generator.constant(axis.getX()),
generator.constant(axis.getY()),
generator.constant(axis.getZ()));
angleD = MathArrays.buildArray(field, coefficientsDrivers.length);
for (int k = 0; k < angleD.length; ++k) {
angleD[k] = generator.variable(coefficientsDrivers[k]);
}
// cache evaluated rotation parameters
axisDS = axisD;
angleDS = angleD;
} else {
// reuse cached values
axisD = (FieldVector3D<T>) axisDS;
angleD = (T[]) angleDS;
}
// evaluate polynomial, with all its partial derivatives
final double t = date.durationFrom(referenceDate);
DerivativeStructure alpha = axisDS.getX().getField().getZero();
T alpha = field.getZero();
for (int k = angleDS.length - 1; k >= 0; --k) {
alpha = alpha.multiply(t).add(angleDS[k]);
alpha = alpha.multiply(t).add(angleD[k]);
}
return new FieldRotation<DerivativeStructure>(axisDS,
alpha,
RotationConvention.VECTOR_OPERATOR).applyTo(los);
return new FieldRotation<>(axisD, alpha, RotationConvention.VECTOR_OPERATOR).applyTo(los);
}
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -18,10 +18,10 @@ package org.orekit.rugged.los;
import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.Derivative;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.orekit.rugged.utils.DSGenerator;
import org.orekit.rugged.utils.DerivativeGenerator;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
......@@ -56,13 +56,15 @@ public interface TimeDependentLOS {
* method must have been set to {@code true} for the various parameters returned
* by {@link #getParametersDrivers()} that should be estimated.
* </p>
* @param <T> derivative type
* @param index los pixel index
* @param date date
* @param generator generator to use for building {@link DerivativeStructure} instances
* @param generator generator to use for building {@link Derivative} instances
* @return line of sight, and its first partial derivatives with respect to the parameters
* @since 2.0
*/
FieldVector3D<DerivativeStructure> getLOSDerivatives(int index, AbsoluteDate date,
DSGenerator generator);
<T extends Derivative<T>> FieldVector3D<T> getLOSDerivatives(int index, AbsoluteDate date,
DerivativeGenerator<T> generator);
/** Get the drivers for LOS parameters.
* @return drivers for LOS parameters
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -18,10 +18,10 @@ package org.orekit.rugged.los;
import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.DerivativeStructure;
import org.hipparchus.analysis.differentiation.Derivative;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.orekit.rugged.utils.DSGenerator;
import org.orekit.rugged.utils.DerivativeGenerator;
import org.orekit.utils.ParameterDriver;
/** Interface for lines-of-sight tranforms that do not depend on time.
......@@ -46,19 +46,18 @@ public interface TimeIndependentLOSTransform {
* </p>
* <p>
* Note that in order for the partial derivatives to be properly set up, the
* {@link #setEstimatedParameters(double[], int, int) setEstimatedParameters}
* <em>must</em> have been called at least once before this method and its
* {@code start} parameter will be used to ensure the partial derivatives are
* ordered in the same way in the returned vector as they were in the set
* parameters.
* {@link org.orekit.utils.ParameterDriver#setSelected(boolean) setSelected}
* method must have been set to {@code true} for the various parameters returned
* by {@link #getParametersDrivers()} that should be estimated.
* </p>
* @param <T> derivative type
* @param index los pixel index
* @param los line-of-sight to transform
* @param generator generator to use for building {@link DerivativeStructure} instances
* @param generator generator to use for building {@link Derivative} instances
* @return line of sight, and its first partial derivatives with respect to the parameters
*/
FieldVector3D<DerivativeStructure> transformLOS(int index, FieldVector3D<DerivativeStructure> los,
DSGenerator generator);
<T extends Derivative<T>> FieldVector3D<T> transformLOS(int index, FieldVector3D<T> los,
DerivativeGenerator<T> generator);
/** Get the drivers for LOS parameters.
* @return drivers for LOS parameters
......
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* This package provides all the tools to build lines-of-sight (LOS).
*
* @author Luc Maisonobe
* @author Guylaine Prat
*
*/
package org.orekit.rugged.los;
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -16,12 +16,11 @@
*/
package org.orekit.rugged.raster;
import java.util.Arrays;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.Precision;
import java.util.Arrays;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.rugged.errors.DumpManager;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.errors.RuggedMessages;
......@@ -33,6 +32,7 @@ import org.orekit.rugged.utils.NormalizedGeodeticPoint;
/** Simple implementation of a {@link Tile}.
* @see SimpleTileFactory
* @author Luc Maisonobe
* @author Guylaine Prat
*/
public class SimpleTile implements Tile {
......@@ -90,8 +90,7 @@ public class SimpleTile implements Tile {
@Override
public void setGeometry(final double newMinLatitude, final double newMinLongitude,
final double newLatitudeStep, final double newLongitudeStep,
final int newLatitudeRows, final int newLongitudeColumns)
throws RuggedException {
final int newLatitudeRows, final int newLongitudeColumns) {
this.minLatitude = newMinLatitude;
this.minLongitude = newMinLongitude;
this.latitudeStep = newLatitudeStep;
......@@ -115,7 +114,7 @@ public class SimpleTile implements Tile {
/** {@inheritDoc} */
@Override
public void tileUpdateCompleted() throws RuggedException {
public void tileUpdateCompleted() {
processUpdatedElevation(elevations);
}
......@@ -229,8 +228,8 @@ public class SimpleTile implements Tile {
/** {@inheritDoc} */
@Override
public void setElevation(final int latitudeIndex, final int longitudeIndex, final double elevation)
throws RuggedException {
public void setElevation(final int latitudeIndex, final int longitudeIndex, final double elevation) {
if (latitudeIndex < 0 || latitudeIndex > (latitudeRows - 1) ||
longitudeIndex < 0 || longitudeIndex > (longitudeColumns - 1)) {
throw new RuggedException(RuggedMessages.OUT_OF_TILE_INDICES,
......@@ -265,8 +264,7 @@ public class SimpleTile implements Tile {
* </p>
*/
@Override
public double interpolateElevation(final double latitude, final double longitude)
throws RuggedException {
public double interpolateElevation(final double latitude, final double longitude) {
final double doubleLatitudeIndex = getDoubleLatitudeIndex(latitude);
final double doubleLongitudeIndex = getDoubleLontitudeIndex(longitude);
......@@ -303,9 +301,8 @@ public class SimpleTile implements Tile {
/** {@inheritDoc} */
@Override
public NormalizedGeodeticPoint cellIntersection(final GeodeticPoint p, final Vector3D los,
final int latitudeIndex, final int longitudeIndex)
throws RuggedException {
public NormalizedGeodeticPoint cellIntersection(final NormalizedGeodeticPoint p, final Vector3D los,
final int latitudeIndex, final int longitudeIndex) {
// ensure neighboring cells to not fall out of tile
final int iLat = FastMath.max(0, FastMath.min(latitudeRows - 2, latitudeIndex));
......@@ -319,10 +316,16 @@ public class SimpleTile implements Tile {
final double z10 = getElevationAtIndices(iLat, jLong + 1);
final double z11 = getElevationAtIndices(iLat + 1, jLong + 1);
// normalize back to tile coordinates
final NormalizedGeodeticPoint tileP = new NormalizedGeodeticPoint(p.getLatitude(),
p.getLongitude(),
p.getAltitude(),
x00);
// line-of-sight coordinates at close points
final double dxA = (p.getLongitude() - x00) / longitudeStep;
final double dyA = (p.getLatitude() - y00) / latitudeStep;
final double dzA = p.getAltitude();
final double dxA = (tileP.getLongitude() - x00) / longitudeStep;
final double dyA = (tileP.getLatitude() - y00) / latitudeStep;
final double dzA = tileP.getAltitude();
final double dxB = dxA + los.getX() / longitudeStep;
final double dyB = dyA + los.getY() / latitudeStep;
final double dzB = dzA + los.getZ();
......@@ -370,8 +373,8 @@ public class SimpleTile implements Tile {
}
final NormalizedGeodeticPoint p1 = interpolate(t1, p, dxA, dyA, los, x00);
final NormalizedGeodeticPoint p2 = interpolate(t2, p, dxA, dyA, los, x00);
final NormalizedGeodeticPoint p1 = interpolate(t1, tileP, dxA, dyA, los, x00);
final NormalizedGeodeticPoint p2 = interpolate(t2, tileP, dxA, dyA, los, x00);
// select the first point along line-of-sight
if (p1 == null) {
......@@ -386,7 +389,7 @@ public class SimpleTile implements Tile {
/** Interpolate point along a line.
* @param t abscissa along the line
* @param p start point
* @param tileP start point, normalized to tile area
* @param dxP relative coordinate of the start point with respect to current cell
* @param dyP relative coordinate of the start point with respect to current cell
* @param los direction of the line-of-sight, in geodetic space
......@@ -394,7 +397,7 @@ public class SimpleTile implements Tile {
* be normalized between lc-π and lc+π
* @return interpolated point along the line
*/
private NormalizedGeodeticPoint interpolate(final double t, final GeodeticPoint p,
private NormalizedGeodeticPoint interpolate(final double t, final NormalizedGeodeticPoint tileP,
final double dxP, final double dyP,
final Vector3D los, final double centralLongitude) {
......@@ -405,9 +408,9 @@ public class SimpleTile implements Tile {
final double dx = dxP + t * los.getX() / longitudeStep;
final double dy = dyP + t * los.getY() / latitudeStep;
if (dx >= -TOLERANCE && dx <= 1 + TOLERANCE && dy >= -TOLERANCE && dy <= 1 + TOLERANCE) {
return new NormalizedGeodeticPoint(p.getLatitude() + t * los.getY(),
p.getLongitude() + t * los.getX(),
p.getAltitude() + t * los.getZ(),
return new NormalizedGeodeticPoint(tileP.getLatitude() + t * los.getY(),
tileP.getLongitude() + t * los.getX(),
tileP.getAltitude() + t * los.getZ(),
centralLongitude);
} else {
return null;
......@@ -428,15 +431,15 @@ public class SimpleTile implements Tile {
}
/** Get the latitude index of a point.
* @param latitude geodetic latitude
* @return latitute index (it may lie outside of the tile!)
* @param latitude geodetic latitude (rad)
* @return latitude index (it may lie outside of the tile!)
*/
private double getDoubleLatitudeIndex(final double latitude) {
return (latitude - minLatitude) / latitudeStep;
}
/** Get the longitude index of a point.
* @param longitude geodetic latitude
* @param longitude geodetic longitude (rad)
* @return longitude index (it may lie outside of the tile!)
*/
private double getDoubleLontitudeIndex(final double longitude) {
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -16,8 +16,6 @@
*/
package org.orekit.rugged.raster;
import org.orekit.rugged.raster.TileFactory;
/** Simple implementation of a {@link TileFactory} for {@link SimpleTile}.
* @author Luc Maisonobe
*/
......
/* Copyright 2013-2016 CS Systèmes d'Information
* Licensed to CS Systèmes d'Information (CS) under one or more
/* Copyright 2013-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
......@@ -17,8 +17,6 @@
package org.orekit.rugged.raster;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.utils.NormalizedGeodeticPoint;
/** Interface representing a raster tile.
......@@ -29,6 +27,7 @@ import org.orekit.rugged.utils.NormalizedGeodeticPoint;
* correspond to the <em>center</em> of the most North-East cell.
* </p>
* @author Luc Maisonobe
* @author Guylaine Prat
*/
public interface Tile extends UpdatableTile {
......@@ -113,20 +112,18 @@ public interface Tile extends UpdatableTile {
}
/** Hook called at the end of tile update completion.
* @exception RuggedException if something wrong occurs
* (missing data ...)
*/
void tileUpdateCompleted() throws RuggedException;
void tileUpdateCompleted();
/** Get minimum latitude of grid interpolation points.
* @return minimum latitude of grid interpolation points
* @return minimum latitude of grid interpolation points (rad)
* (latitude of the center of the cells of South row)
*/
double getMinimumLatitude();
/** Get the latitude at some index.
* @param latitudeIndex latitude index
* @return latitude at the specified index
* @return latitude at the specified index (rad)
* (latitude of the center of the cells of specified row)
*/
double getLatitudeAtIndex(int latitudeIndex);
......@@ -140,20 +137,20 @@ public interface Tile extends UpdatableTile {
* {@link Location#NORTH} or {@link Location#NORTH_EAST}, but can
* <em>never</em> return {@link Location#HAS_INTERPOLATION_NEIGHBORS}!
* </p>
* @return maximum latitude
* @return maximum latitude (rad)
* (latitude of the center of the cells of North row)
*/
double getMaximumLatitude();
/** Get minimum longitude.
* @return minimum longitude
* @return minimum longitude (rad)
* (longitude of the center of the cells of West column)
*/
double getMinimumLongitude();
/** Get the longitude at some index.
* @param longitudeIndex longitude index
* @return longitude at the specified index
* @return longitude at the specified index (rad)
* (longitude of the center of the cells of specified column)
*/
double getLongitudeAtIndex(int longitudeIndex);
......@@ -167,18 +164,18 @@ public interface Tile extends UpdatableTile {
* {@link Location#EAST} or {@link Location#NORTH_EAST}, but can
* <em>never</em> return {@link Location#HAS_INTERPOLATION_NEIGHBORS}!
* </p>
* @return maximum longitude
* @return maximum longitude (rad)
* (longitude of the center of the cells of East column)
*/
double getMaximumLongitude();
/** Get step in latitude (size of one raster element).
* @return step in latitude
* @return step in latitude (rad)
*/
double getLatitudeStep();
/** Get step in longitude (size of one raster element).
* @return step in longitude
* @return step in longitude (rad)
*/
double getLongitudeStep();
......@@ -211,7 +208,7 @@ public interface Tile extends UpdatableTile {
int getFloorLongitudeIndex(double longitude);
/** Get the minimum elevation in the tile.
* @return minimum elevation in the tile
* @return minimum elevation in the tile (m)
*/
double getMinElevation();
......@@ -224,7 +221,7 @@ public interface Tile extends UpdatableTile {
int getMinElevationLongitudeIndex();
/** Get the maximum elevation in the tile.
* @return maximum elevation in the tile
* @return maximum elevation in the tile (m)
*/
double getMaxElevation();
......@@ -239,11 +236,9 @@ public interface Tile extends UpdatableTile {
/** Get the elevation of an exact grid point.
* @param latitudeIndex grid point index along latitude
* @param longitudeIndex grid point index along longitude
* @return elevation at grid point
* @exception RuggedException if indices are out of bound
* @return elevation at grid point (m)
*/
double getElevationAtIndices(int latitudeIndex, int longitudeIndex)
throws RuggedException;
double getElevationAtIndices(int latitudeIndex, int longitudeIndex);
/** Interpolate elevation.
* <p>
......@@ -256,25 +251,33 @@ public interface Tile extends UpdatableTile {
* </p>
* @param latitude ground point latitude
* @param longitude ground point longitude
* @return interpolated elevation
* @exception RuggedException if point is farthest from the tile than the tolerance
* @return interpolated elevation (m)
*/
double interpolateElevation(double latitude, double longitude)
throws RuggedException;
double interpolateElevation(double latitude, double longitude);
/** Find the intersection of a line-of-sight and a Digital Elevation Model cell.
* @param p point on the line
* <p>
* Beware that for continuity reasons, the point argument in {@code cellIntersection} is normalized
* with respect to other points used by the caller. This implies that the longitude may be
* outside of the [-π ; +π] interval (or the [0 ; 2π] interval, depending on the DEM). In particular,
* when a Line Of Sight crosses the antimeridian at ±π longitude, the library may call the
* {@code cellIntersection} method with a point having a longitude of -π-ε to ensure this continuity.
* As tiles are stored with longitude clipped to a some DEM specific interval (either [-π ; +π] or [0 ; 2π]),
* implementations MUST take care to clip the input point back to the tile interval using
* {@link org.hipparchus.util.MathUtils#normalizeAngle(double, double) MathUtils.normalizeAngle(p.getLongitude(),
* someLongitudeWithinTheTile)}. The output point normalization should also be made consistent with
* the current tile.
* </p>
* @param p point on the line (beware its longitude is <em>not</em> normalized with respect to tile)
* @param los line-of-sight, in the topocentric frame (East, North, Zenith) of the point,
* scaled to match radians in the horizontal plane and meters along the vertical axis
* @param latitudeIndex latitude index of the Digital Elevation Model cell
* @param longitudeIndex longitude index of the Digital Elevation Model cell
* @return point corresponding to line-of-sight crossing the Digital Elevation Model surface
* if it lies within the cell, null otherwise
* @exception RuggedException if intersection point cannot be computed
*/
NormalizedGeodeticPoint cellIntersection(GeodeticPoint p, Vector3D los,
int latitudeIndex, int longitudeIndex)
throws RuggedException;
NormalizedGeodeticPoint cellIntersection(NormalizedGeodeticPoint p, Vector3D los,
int latitudeIndex, int longitudeIndex);
/** Check if a tile covers a ground point.
* @param latitude ground point latitude
......