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

Use Apache Commons Math 3.6 API for rotations.

parent 512a7f6c
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
......@@ -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);
}
......
......@@ -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();
}
......
......@@ -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();
}
......
......@@ -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);
......
......@@ -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
......
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