Skip to content
Snippets Groups Projects
Commit f4852d9b authored by LabatAllee Lucie's avatar LabatAllee Lucie
Browse files

distanceBetweenLOS() & Derivatives: formulate LOS and position into inertial frame

parent de2622f0
No related branches found
No related tags found
No related merge requests found
...@@ -590,6 +590,7 @@ public class Rugged { ...@@ -590,6 +590,7 @@ public class Rugged {
* @param sensorA line sensor A * @param sensorA line sensor A
* @param dateA current date for sensor A * @param dateA current date for sensor A
* @param pixelA pixel index for sensor A * @param pixelA pixel index for sensor A
* @param scToBodyA spacecraftToBody transform for sensor A
* @param sensorB line sensor B * @param sensorB line sensor B
* @param dateB current date for sensor B * @param dateB current date for sensor B
* @param pixelB pixel index for sensor B * @param pixelB pixel index for sensor B
...@@ -598,6 +599,7 @@ public class Rugged { ...@@ -598,6 +599,7 @@ public class Rugged {
*/ */
public double distanceBetweenLOS(final LineSensor sensorA, public double distanceBetweenLOS(final LineSensor sensorA,
final AbsoluteDate dateA, final int pixelA, final AbsoluteDate dateA, final int pixelA,
final SpacecraftToObservedBody scToBodyA,
final LineSensor sensorB, final LineSensor sensorB,
final AbsoluteDate dateB, final int pixelB) final AbsoluteDate dateB, final int pixelB)
throws RuggedException { throws RuggedException {
...@@ -605,34 +607,21 @@ public class Rugged { ...@@ -605,34 +607,21 @@ public class Rugged {
//final LineSensor sensorA = getLineSensor(sensorNameA); //final LineSensor sensorA = getLineSensor(sensorNameA);
//final LineSensor sensorB = getLineSensor(sensorNameB); //final LineSensor sensorB = getLineSensor(sensorNameB);
// Get sensors's position and LOS // Compute the approximate transforms between spacecraft and observed body
// compute the approximate transform between spacecraft and observed body final Transform scToInertA = scToBodyA.getScToInertial(dateA); // from rugged instance A
final Transform scToInertB = scToBody.getScToInertial(dateB); // from (current) rugged instance B
final Transform scToInertA = scToBody.getScToInertial(dateA);
//final Transform inertToBodyA = scToBody.getInertialToBody(dateA); // Get sensors's position and LOS into local frame
//final Transform approximate = new Transform(dateA, scToInertA, inertToBodyA); final Vector3D vALocal = sensorA.getLOS(dateA, pixelA); // V_a : line of sight's vectorA
final Vector3D vBLocal = sensorB.getLOS(dateB, pixelB); // V_b
final Vector3D sALocal = sensorA.getPosition(); // S_a : sensorA 's position
// compute location of each pixel final Vector3D sBLocal = sensorB.getPosition(); // S_b
final Vector3D sA = scToInertA.transformPosition(sensorA.getPosition());
final Vector3D vA = scToInertA.transformVector(sensorA.getLOS(dateA, pixelA)); // Get sensors's position and LOS into inertial frame
final Vector3D sA = scToInertA.transformPosition(sALocal);
//TODO scToBody should be found from ruggedB instance final Vector3D vA = scToInertA.transformVector(vALocal);
final Transform scToInertB = scToBody.getScToInertial(dateB); final Vector3D sB = scToInertB.transformPosition(sBLocal);
//final Transform inertToBodyB = scToBody.getInertialToBody(dateB); final Vector3D vB = scToInertB.transformVector(vBLocal);
//final Transform approximate = new Transform(dateA, scToInert, inertToBody);
// compute location of each pixel
final Vector3D sB = scToInertB.transformPosition(sensorB.getPosition());
final Vector3D vB = scToInertB.transformVector(sensorB.getLOS(dateB, pixelB));
//final Vector3D vA = sensorA.getLOS(dateA, pixelA); // V_a : line of sight's vectorA
//final Vector3D vB = sensorB.getLOS(dateB, pixelB); // V_b
//final Vector3D sA = sensorA.getPosition(); // S_a : sensorA 's position
//final Vector3D sB = sensorB.getPosition(); // S_b
final Vector3D vBase= sB.subtract(sA); // S_b - S_a final Vector3D vBase= sB.subtract(sA); // S_b - S_a
final double svA = Vector3D.dotProduct(vBase, vA); // SV_a = (S_b - S_a).V_a final double svA = Vector3D.dotProduct(vBase, vA); // SV_a = (S_b - S_a).V_a
...@@ -659,6 +648,7 @@ public class Rugged { ...@@ -659,6 +648,7 @@ public class Rugged {
* @param sensorA line sensor A * @param sensorA line sensor A
* @param dateA current date for sensor A * @param dateA current date for sensor A
* @param pixelA pixel index for sensor A * @param pixelA pixel index for sensor A
* @param scToBodyA spacecraftToBody transform for sensor A
* @param sensorB line sensor B * @param sensorB line sensor B
* @param dateB current date for sensor B * @param dateB current date for sensor B
* @param pixelB pixel index for sensor B * @param pixelB pixel index for sensor B
...@@ -669,6 +659,7 @@ public class Rugged { ...@@ -669,6 +659,7 @@ public class Rugged {
*/ */
private DerivativeStructure[] distanceBetweenLOSDerivatives(final LineSensor sensorA, private DerivativeStructure[] distanceBetweenLOSDerivatives(final LineSensor sensorA,
final AbsoluteDate dateA, final int pixelA, final AbsoluteDate dateA, final int pixelA,
final SpacecraftToObservedBody scToBodyA,
final LineSensor sensorB, final LineSensor sensorB,
final AbsoluteDate dateB, final int pixelB, final AbsoluteDate dateB, final int pixelB,
final DSGenerator generator) final DSGenerator generator)
...@@ -677,18 +668,31 @@ public class Rugged { ...@@ -677,18 +668,31 @@ public class Rugged {
//final LineSensor sensorA = getLineSensor(sensorNameA); //final LineSensor sensorA = getLineSensor(sensorNameA);
//final LineSensor sensorB = getLineSensor(sensorNameB); //final LineSensor sensorB = getLineSensor(sensorNameB);
// Get sensors's LOS // Compute the approximate transforms between spacecraft and observed body
final FieldVector3D<DerivativeStructure> vA = sensorA.getLOSDerivatives(dateA, pixelA, generator); // V_a : line of sight's vectorA final Transform scToInertA = scToBodyA.getScToInertial(dateA); // from rugged instance A
final FieldVector3D<DerivativeStructure> vB = sensorB.getLOSDerivatives(dateB, pixelB, generator); // V_b final Transform scToInertB = scToBody.getScToInertial(dateB); // from (current) rugged instance B
// Get sensors's LOS into local frame
final FieldVector3D<DerivativeStructure> vALocal = sensorA.getLOSDerivatives(dateA, pixelA, generator);
final FieldVector3D<DerivativeStructure> vBLocal = sensorB.getLOSDerivatives(dateB, pixelB, generator);
// Get sensors's LOS into inertial frame
final FieldVector3D<DerivativeStructure> vA = scToInertA.transformPosition(vALocal); // V_a : line of sight's vectorA
final FieldVector3D<DerivativeStructure> vB = scToInertB.transformPosition(vBLocal); // V_b
// Get sensors's position. TODO: check if we have to implement getPositionDerivatives() method & CO // Get sensors's position into local frame TODO: check if we have to implement getPositionDerivatives() method & CO
final Vector3D sAtmp = sensorA.getPosition(); // S_a : sensorA 's position final Vector3D sAtmp = sensorA.getPosition(); // S_a : sensorA 's position
final Vector3D sBtmp = sensorB.getPosition(); // S_b final Vector3D sBtmp = sensorB.getPosition(); // S_b : sensorB 's position
final DerivativeStructure scaleFactor = FieldVector3D.dotProduct(vA.normalize(), vA.normalize()); // V_a.V_a=1 final DerivativeStructure scaleFactor = FieldVector3D.dotProduct(vA.normalize(), vA.normalize()); // V_a.V_a=1
// Build a vector from position vector and a scale factor (equals to 1). // Build a vector from position vector and a scale factor (equals to 1).
// The vector built will be scaleFactor * sA for example. // The vector built will be scaleFactor * sAtmp for example.
final FieldVector3D<DerivativeStructure> sA = new FieldVector3D<DerivativeStructure>(scaleFactor, sAtmp); final FieldVector3D<DerivativeStructure> sALocal = new FieldVector3D<DerivativeStructure>(scaleFactor, sAtmp);
final FieldVector3D<DerivativeStructure> sB = new FieldVector3D<DerivativeStructure>(scaleFactor, sBtmp); final FieldVector3D<DerivativeStructure> sBLocal = new FieldVector3D<DerivativeStructure>(scaleFactor, sBtmp);
// Get sensors's position into inertial frame
final FieldVector3D<DerivativeStructure> sA = scToInertA.transformPosition(sALocal);
final FieldVector3D<DerivativeStructure> sB = scToInertB.transformPosition(sBLocal);
// final FieldVector3D<DerivativeStructure> sA = sensorA.getPositionDerivatives(); // S_a : sensorA 's position // final FieldVector3D<DerivativeStructure> sA = sensorA.getPositionDerivatives(); // S_a : sensorA 's position
// final FieldVector3D<DerivativeStructure> sB = sensorB.getPositionDerivatives(); // S_b // final FieldVector3D<DerivativeStructure> sB = sensorB.getPositionDerivatives(); // S_b
...@@ -815,11 +819,13 @@ public class Rugged { ...@@ -815,11 +819,13 @@ public class Rugged {
final AbsoluteDate dateB = lineSensorB.getDate(spB.getLineNumber()); final AbsoluteDate dateB = lineSensorB.getDate(spB.getLineNumber());
final int pixelA = (int)spA.getPixelNumber(); // Note: Rugged don't deal with half-pixel final int pixelA = (int)spA.getPixelNumber(); // Note: Rugged don't deal with half-pixel
final int pixelB = (int)spB.getPixelNumber(); final int pixelB = (int)spB.getPixelNumber();
final SpacecraftToObservedBody scToBodyA = ruggedA.getScToBody();
final DerivativeStructure[] ilResult = final DerivativeStructure[] ilResult =
distanceBetweenLOSDerivatives(lineSensorA, distanceBetweenLOSDerivatives(lineSensorA,
dateA, dateA,
pixelA, pixelA,
scToBodyA,
lineSensorB, lineSensorB,
dateB, dateB,
pixelB, pixelB,
...@@ -1296,5 +1302,12 @@ public class Rugged { ...@@ -1296,5 +1302,12 @@ public class Rugged {
} }
return sensor; return sensor;
} }
/** Get converter between spacecraft and body
* @return the scToBody
*/
public SpacecraftToObservedBody getScToBody() {
return scToBody;
}
} }
...@@ -32,6 +32,7 @@ import org.hipparchus.random.Well19937a; ...@@ -32,6 +32,7 @@ import org.hipparchus.random.Well19937a;
import org.hipparchus.util.FastMath; import org.hipparchus.util.FastMath;
import org.orekit.bodies.GeodeticPoint; import org.orekit.bodies.GeodeticPoint;
import org.orekit.rugged.utils.DSGenerator; import org.orekit.rugged.utils.DSGenerator;
import org.orekit.rugged.utils.SpacecraftToObservedBody;
import java.util.Locale; import java.util.Locale;
...@@ -133,8 +134,12 @@ public class SensorToSensorMeasureGenerator { ...@@ -133,8 +134,12 @@ public class SensorToSensorMeasureGenerator {
// TODO test if distance is 0.0 with crossing LOS // TODO test if distance is 0.0 with crossing LOS
final AbsoluteDate dateB = sensorB.getDate(sensorPixelB.getLineNumber()); final AbsoluteDate dateB = sensorB.getDate(sensorPixelB.getLineNumber());
double pixelB = sensorPixelB.getPixelNumber(); double pixelB = sensorPixelB.getPixelNumber();
// Get spacecraft to body transform of rugged instance A
final SpacecraftToObservedBody scToBodyA = ruggedA.getScToBody();
//TODO work with double pixel values //TODO work with double pixel values
double distance = ruggedA.distanceBetweenLOS(sensorA,dateA, pixelA, sensorB ,dateB,(int) pixelB); double distance = ruggedB.distanceBetweenLOS(sensorA,dateA, pixelA, scToBodyA, sensorB ,dateB,(int) pixelB);
System.out.format(Locale.US,"distance %f %n",distance); System.out.format(Locale.US,"distance %f %n",distance);
mapping.addMapping(new SensorPixel(line, pixelA), mapping.addMapping(new SensorPixel(line, pixelA),
......
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