From 8dd9f830ad13a07a818e3057b64d379969329356 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Tue, 19 Feb 2013 15:07:04 +0000 Subject: [PATCH] Added a conversion from RotationDS to Rotation. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1447753 13f79535-47bb-0310-9956-ffa450edef68 --- .../math3/geometry/euclidean/threed/RotationDS.java | 7 +++++++ .../geometry/euclidean/threed/RotationDSTest.java | 12 ++---------- 2 files changed, 9 insertions(+), 10 deletions(-) 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) {