From 5baf4f705896848df7c844596aefef593003fef9 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe <luc@orekit.org> Date: Sun, 27 Dec 2015 20:40:46 +0100 Subject: [PATCH] Use Apache Commons Math 3.6 API for rotations. --- .../org/orekit/rugged/los/FixedRotation.java | 9 ++++---- .../orekit/rugged/los/PolynomialRotation.java | 9 ++++++-- .../java/org/orekit/rugged/TestUtils.java | 7 ++++-- .../orekit/rugged/api/RuggedBuilderTest.java | 12 ++++++---- .../org/orekit/rugged/api/RuggedTest.java | 22 +++++++++++++------ .../orekit/rugged/errors/DumpManagerTest.java | 4 +++- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/orekit/rugged/los/FixedRotation.java b/src/main/java/org/orekit/rugged/los/FixedRotation.java index 9d38cd34..ab8af7ea 100644 --- a/src/main/java/org/orekit/rugged/los/FixedRotation.java +++ b/src/main/java/org/orekit/rugged/los/FixedRotation.java @@ -20,6 +20,7 @@ import org.apache.commons.math3.analysis.differentiation.DerivativeStructure; import org.apache.commons.math3.geometry.euclidean.threed.FieldRotation; import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D; import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.orekit.rugged.errors.RuggedException; import org.orekit.rugged.errors.RuggedMessages; @@ -50,7 +51,7 @@ public class FixedRotation implements TimeIndependentLOSTransform { */ public FixedRotation(final ParameterType type, final Vector3D axis, final double angle) { this.type = type; - this.rotation = new Rotation(axis, angle); + this.rotation = new Rotation(axis, angle, RotationConvention.VECTOR_OPERATOR); this.rDS = null; } @@ -81,14 +82,14 @@ public class FixedRotation implements TimeIndependentLOSTransform { public void setEstimatedParameters(final double[] parameters, final int start, final int length) throws RuggedException { checkSlice(length); - final Vector3D axis = rotation.getAxis(); - rotation = new Rotation(axis, parameters[start]); + final Vector3D axis = rotation.getAxis(RotationConvention.VECTOR_OPERATOR); + rotation = new Rotation(axis, parameters[start], RotationConvention.VECTOR_OPERATOR); final FieldVector3D<DerivativeStructure> axisDS = new FieldVector3D<DerivativeStructure>(new DerivativeStructure(parameters.length, 1, axis.getX()), new DerivativeStructure(parameters.length, 1, axis.getY()), new DerivativeStructure(parameters.length, 1, axis.getZ())); final DerivativeStructure angleDS = new DerivativeStructure(parameters.length, 1, start, parameters[start]); - rDS = new FieldRotation<DerivativeStructure>(axisDS, angleDS); + rDS = new FieldRotation<DerivativeStructure>(axisDS, angleDS, RotationConvention.VECTOR_OPERATOR); } /** Check the number of parameters of an array slice. diff --git a/src/main/java/org/orekit/rugged/los/PolynomialRotation.java b/src/main/java/org/orekit/rugged/los/PolynomialRotation.java index 6437832e..68899ada 100644 --- a/src/main/java/org/orekit/rugged/los/PolynomialRotation.java +++ b/src/main/java/org/orekit/rugged/los/PolynomialRotation.java @@ -21,6 +21,7 @@ import org.apache.commons.math3.analysis.polynomials.PolynomialFunction; import org.apache.commons.math3.geometry.euclidean.threed.FieldRotation; import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D; import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.orekit.rugged.errors.RuggedException; import org.orekit.rugged.errors.RuggedMessages; @@ -153,7 +154,9 @@ public class PolynomialRotation implements LOSTransform { /** {@inheritDoc} */ @Override public Vector3D transformLOS(final int i, final Vector3D los, final AbsoluteDate date) { - return new Rotation(axis, angle.value(date.durationFrom(referenceDate))).applyTo(los); + return new Rotation(axis, + angle.value(date.durationFrom(referenceDate)), + RotationConvention.VECTOR_OPERATOR).applyTo(los); } /** {@inheritDoc} */ @@ -168,7 +171,9 @@ public class PolynomialRotation implements LOSTransform { alpha = alpha.multiply(t).add(angleDS[k]); } - return new FieldRotation<DerivativeStructure>(axisDS, alpha).applyTo(los); + return new FieldRotation<DerivativeStructure>(axisDS, + alpha, + RotationConvention.VECTOR_OPERATOR).applyTo(los); } diff --git a/src/test/java/org/orekit/rugged/TestUtils.java b/src/test/java/org/orekit/rugged/TestUtils.java index 2e31a38d..8be67ea9 100644 --- a/src/test/java/org/orekit/rugged/TestUtils.java +++ b/src/test/java/org/orekit/rugged/TestUtils.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator; import org.apache.commons.math3.util.FastMath; @@ -154,7 +155,7 @@ public class TestUtils { List<Vector3D> list = new ArrayList<Vector3D>(n); for (int i = 0; i < n; ++i) { double alpha = (halfAperture * (2 * i + 1 - n)) / (n - 1); - list.add(new Rotation(normal, alpha).applyTo(center)); + list.add(new Rotation(normal, alpha, RotationConvention.VECTOR_OPERATOR).applyTo(center)); } return new LOSBuilder(list).build(); } @@ -167,7 +168,9 @@ public class TestUtils { double x = (2.0 * i + 1.0 - n) / (n - 1); double alpha = x * halfAperture; double beta = x * x * sagitta; - list.add(new Rotation(normal, alpha).applyTo(new Rotation(u, beta).applyTo(center))); + list.add(new Rotation(normal, alpha, RotationConvention.VECTOR_OPERATOR). + applyTo(new Rotation(u, beta, RotationConvention.VECTOR_OPERATOR). + applyTo(center))); } return new LOSBuilder(list).build(); } diff --git a/src/test/java/org/orekit/rugged/api/RuggedBuilderTest.java b/src/test/java/org/orekit/rugged/api/RuggedBuilderTest.java index e8cd88ec..c1310a8e 100644 --- a/src/test/java/org/orekit/rugged/api/RuggedBuilderTest.java +++ b/src/test/java/org/orekit/rugged/api/RuggedBuilderTest.java @@ -30,6 +30,7 @@ import java.util.Arrays; import java.util.List; import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator; import org.apache.commons.math3.util.FastMath; @@ -341,7 +342,8 @@ public class RuggedBuilderTest { // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms @@ -409,7 +411,8 @@ public class RuggedBuilderTest { // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms @@ -458,7 +461,8 @@ public class RuggedBuilderTest { // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms @@ -665,7 +669,7 @@ public class RuggedBuilderTest { List<Vector3D> list = new ArrayList<Vector3D>(n); for (int i = 0; i < n; ++i) { double alpha = (halfAperture * (2 * i + 1 - n)) / (n - 1); - list.add(new Rotation(normal, alpha).applyTo(center)); + list.add(new Rotation(normal, alpha, RotationConvention.VECTOR_OPERATOR).applyTo(center)); } return new LOSBuilder(list).build(); } diff --git a/src/test/java/org/orekit/rugged/api/RuggedTest.java b/src/test/java/org/orekit/rugged/api/RuggedTest.java index 853b4088..4ed3492c 100644 --- a/src/test/java/org/orekit/rugged/api/RuggedTest.java +++ b/src/test/java/org/orekit/rugged/api/RuggedTest.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Locale; import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.stat.descriptive.SummaryStatistics; import org.apache.commons.math3.stat.descriptive.rank.Percentile; @@ -321,7 +322,8 @@ public class RuggedTest { // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms @@ -382,7 +384,8 @@ public class RuggedTest { // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms @@ -439,7 +442,8 @@ public class RuggedTest { // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms @@ -499,7 +503,8 @@ public class RuggedTest { // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms @@ -565,7 +570,8 @@ public class RuggedTest { // los: swath in the (YZ) plane, looking roughly at 50° roll (sensor-dependent), 2.6" per pixel Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0 - 0.001 * i)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0 - 0.001 * i), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(dimension * 2.6 / 3600.0), dimension); // linear datation model: at reference time we get roughly middle line, and the rate is one line every 1.5ms @@ -944,7 +950,8 @@ public class RuggedTest { // los: swath in the (YZ) plane, looking at 50° roll, 2.6" per pixel Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(dimension * 2.6 / 3600.0), dimension); @@ -1035,7 +1042,8 @@ public class RuggedTest { // los: swath in the (YZ) plane, looking at 50° roll, 2.6" per pixel Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(dimension * 2.6 / 3600.0), dimension); diff --git a/src/test/java/org/orekit/rugged/errors/DumpManagerTest.java b/src/test/java/org/orekit/rugged/errors/DumpManagerTest.java index 46cb3d98..8f41011a 100644 --- a/src/test/java/org/orekit/rugged/errors/DumpManagerTest.java +++ b/src/test/java/org/orekit/rugged/errors/DumpManagerTest.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.net.URISyntaxException; import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import org.apache.commons.math3.util.FastMath; import org.junit.Assert; @@ -146,7 +147,8 @@ public class DumpManagerTest { // los: swath in the (YZ) plane, looking at 50° roll, ±1° aperture Vector3D position = new Vector3D(1.5, 0, -0.2); TimeDependentLOS los = TestUtils.createLOSPerfectLine(new Rotation(Vector3D.PLUS_I, - FastMath.toRadians(50.0)).applyTo(Vector3D.PLUS_K), + FastMath.toRadians(50.0), + RotationConvention.VECTOR_OPERATOR).applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I, FastMath.toRadians(1.0), dimension); // linear datation model: at reference time we get line 100, and the rate is one line every 1.5ms -- GitLab