diff --git a/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/RotationDS.java b/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/RotationDS.java index 485dca054..2ba8a4def 100644 --- a/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/RotationDS.java +++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/RotationDS.java @@ -786,6 +786,13 @@ public class RotationDS implements Serializable { } + /** Convert to a constant vector without derivatives. + * @return a constant vector + */ + public Rotation toRotation() { + return new Rotation(q0.getValue(), q1.getValue(), q2.getValue(), q3.getValue(), false); + } + /** Apply the rotation to a vector. * @param u vector to apply the rotation to * @return a new vector which is the image of u by the rotation diff --git a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationDSTest.java b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationDSTest.java index cd1497694..924baff34 100644 --- a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationDSTest.java +++ b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationDSTest.java @@ -486,11 +486,7 @@ public class RotationDSTest { RotationDS r1 = new RotationDS(createVector(2, -3, 5), createAngle(1.7)); RotationDS r2 = new RotationDS(createVector(-1, 3, 2), createAngle(0.3)); RotationDS r3 = r2.applyTo(r1); - RotationDS r3Double = r2.applyTo(new Rotation(r1.getQ0().getValue(), - r1.getQ1().getValue(), - r1.getQ2().getValue(), - r1.getQ3().getValue(), - false)); + RotationDS r3Double = r2.applyTo(r1.toRotation()); for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) { @@ -510,11 +506,7 @@ public class RotationDSTest { RotationDS r1 = new RotationDS(createVector(2, -3, 5), createAngle(1.7)); RotationDS r2 = new RotationDS(createVector(-1, 3, 2), createAngle(0.3)); RotationDS r3 = r2.applyInverseTo(r1); - RotationDS r3Double = r2.applyInverseTo(new Rotation(r1.getQ0().getValue(), - r1.getQ1().getValue(), - r1.getQ2().getValue(), - r1.getQ3().getValue(), - false)); + RotationDS r3Double = r2.applyInverseTo(r1.toRotation()); for (double x = -0.9; x < 0.9; x += 0.2) { for (double y = -0.9; y < 0.9; y += 0.2) {