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

Ensure sensor mean plane normal has a deterministic orientation.

parent 08ad7cf3
No related branches found
No related tags found
No related merge requests found
......@@ -114,7 +114,14 @@ public class Sensor {
// extract the left singular vector corresponding to least singular value
// (i.e. last vector since Apache Commons Math returns the values
// in non-increasing order)
normal = new Vector3D(svd.getU().getColumn(2)).normalize();
final Vector3D singularVector = new Vector3D(svd.getU().getColumn(2)).normalize();
// check rotation order
if (Vector3D.dotProduct(singularVector, Vector3D.crossProduct(los.get(0), los.get(los.size() - 1))) >= 0) {
normal = singularVector;
} else {
normal = singularVector.negate();
}
}
......@@ -165,16 +172,21 @@ public class Sensor {
}
/** Get the mean plane normal.
* <p>
* The normal is oriented such traversing pixels in increasing indices
* order corresponds is consistent with trigonometric order (i.e.
* counterclockwise).
* </p>
* @return mean plane normal
*/
public Vector3D getMeanPlaneNormal() {
return normal;
}
/** Get the mean plane reference point.
* @return mean plane reference point
/** Get the sensor reference point.
* @return reference point
*/
public Vector3D getMeanPlaneReferencePoint() {
public Vector3D getReferencePoint() {
return referencePoint;
}
......
......@@ -52,8 +52,8 @@ public class SensorTest {
Assert.assertEquals("perfect line", sensor.getName());
Assert.assertEquals(AbsoluteDate.J2000_EPOCH, sensor.getDate(0.0));
Assert.assertEquals(0.0, Vector3D.dotProduct(normal, center.subtract(sensor.getMeanPlaneReferencePoint())), 1.0e-15);
Assert.assertEquals(0.0, FastMath.sin(Vector3D.angle(normal, sensor.getMeanPlaneNormal())), 1.0e-15);
Assert.assertEquals(0.0, Vector3D.dotProduct(normal, center.subtract(sensor.getReferencePoint())), 1.0e-15);
Assert.assertEquals(0.0, Vector3D.angle(normal, sensor.getMeanPlaneNormal()), 1.0e-15);
}
......@@ -85,8 +85,8 @@ public class SensorTest {
Assert.assertEquals("noisy line", sensor.getName());
Assert.assertEquals(AbsoluteDate.J2000_EPOCH, sensor.getDate(0.0));
Assert.assertEquals(0.0, Vector3D.dotProduct(normal, center.subtract(sensor.getMeanPlaneReferencePoint())), 1.0e-5);
Assert.assertEquals(0.0, FastMath.sin(Vector3D.angle(normal, sensor.getMeanPlaneNormal())), 3.0e-7);
Assert.assertEquals(0.0, Vector3D.dotProduct(normal, center.subtract(sensor.getReferencePoint())), 1.0e-5);
Assert.assertEquals(0.0, Vector3D.angle(normal, sensor.getMeanPlaneNormal()), 3.0e-7);
}
......
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