commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [1/3] [math] Added a RotationConvention enumerate.
Date Sat, 26 Dec 2015 20:29:26 GMT
Repository: commons-math
Updated Branches:
  refs/heads/MATH_3_X cc893e499 -> 971a77865


http://git-wip-us.apache.org/repos/asf/commons-math/blob/971a7786/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java
b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java
index 5141d3e..55f2f23 100644
--- a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java
+++ b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java
@@ -55,7 +55,8 @@ public class FieldRotationDfpTest {
     }
 
     @Test
-    public void testAxisAngle() throws MathIllegalArgumentException {
+    @Deprecated
+    public void testAxisAngleDeprecated() throws MathIllegalArgumentException {
 
         FieldRotation<Dfp> r = new FieldRotation<Dfp>(createAxis(10, 10, 10),
createAngle(2 * FastMath.PI / 3));
         checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0));
@@ -84,6 +85,88 @@ public class FieldRotationDfpTest {
     }
 
     @Test
+    public void testAxisAngleVectorOperator() throws MathIllegalArgumentException {
+
+        FieldRotation<Dfp> r = new FieldRotation<Dfp>(createAxis(10, 10, 10),
+                                                      createAngle(2 * FastMath.PI / 3) ,
+                                                      RotationConvention.VECTOR_OPERATOR);
+        checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 1, 0));
+        checkVector(r.applyTo(createVector(0, 1, 0)), createVector(0, 0, 1));
+        checkVector(r.applyTo(createVector(0, 0, 1)), createVector(1, 0, 0));
+        double s = 1 / FastMath.sqrt(3);
+        checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector( s,  s, 
s));
+        checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(-s, -s, -s));
+        checkAngle(r.getAngle(), 2 * FastMath.PI / 3);
+
+        try {
+            new FieldRotation<Dfp>(createAxis(0, 0, 0),
+                                   createAngle(2 * FastMath.PI / 3),
+                                   RotationConvention.VECTOR_OPERATOR);
+            Assert.fail("an exception should have been thrown");
+        } catch (MathIllegalArgumentException e) {
+        }
+
+        r = new FieldRotation<Dfp>(createAxis(0, 0, 1),
+                                   createAngle(1.5 * FastMath.PI),
+                                   RotationConvention.VECTOR_OPERATOR);
+        checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, -1));
+        checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, +1));
+        checkAngle(r.getAngle(), 0.5 * FastMath.PI);
+
+        r = new FieldRotation<Dfp>(createAxis(0, 1, 0),
+                                   createAngle(FastMath.PI),
+                                   RotationConvention.VECTOR_OPERATOR);
+        checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, +1, 0));
+        checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, -1, 0));
+        checkAngle(r.getAngle(), FastMath.PI);
+
+        checkVector(createRotation(1, 0, 0, 0, false).getAxis(RotationConvention.VECTOR_OPERATOR),
createVector(+1, 0, 0));
+        checkVector(createRotation(1, 0, 0, 0, false).getAxis(RotationConvention.FRAME_TRANSFORM),
createVector(-1, 0, 0));
+
+    }
+
+    @Test
+    public void testAxisAngleFrameTransform() throws MathIllegalArgumentException {
+
+        FieldRotation<Dfp> r = new FieldRotation<Dfp>(createAxis(10, 10, 10),
+                                                      createAngle(2 * FastMath.PI / 3) ,
+                                                      RotationConvention.FRAME_TRANSFORM);
+        checkVector(r.applyTo(createVector(1, 0, 0)), createVector(0, 0, 1));
+        checkVector(r.applyTo(createVector(0, 1, 0)), createVector(1, 0, 0));
+        checkVector(r.applyTo(createVector(0, 0, 1)), createVector(0, 1, 0));
+        double s = 1 / FastMath.sqrt(3);
+        checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector( s,  s, 
s));
+        checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(-s, -s, -s));
+        checkAngle(r.getAngle(), 2 * FastMath.PI / 3);
+
+        try {
+            new FieldRotation<Dfp>(createAxis(0, 0, 0),
+                                   createAngle(2 * FastMath.PI / 3),
+                                   RotationConvention.FRAME_TRANSFORM);
+            Assert.fail("an exception should have been thrown");
+        } catch (MathIllegalArgumentException e) {
+        }
+
+        r = new FieldRotation<Dfp>(createAxis(0, 0, 1),
+                                   createAngle(1.5 * FastMath.PI),
+                                   RotationConvention.FRAME_TRANSFORM);
+        checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, 0, -1));
+        checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, 0, +1));
+        checkAngle(r.getAngle(), 0.5 * FastMath.PI);
+
+        r = new FieldRotation<Dfp>(createAxis(0, 1, 0),
+                                   createAngle(FastMath.PI),
+                                   RotationConvention.FRAME_TRANSFORM);
+        checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), createVector(0, +1, 0));
+        checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), createVector(0, -1, 0));
+        checkAngle(r.getAngle(), FastMath.PI);
+
+        checkVector(createRotation(1, 0, 0, 0, false).getAxis(RotationConvention.FRAME_TRANSFORM),
createVector(-1, 0, 0));
+        checkVector(createRotation(1, 0, 0, 0, false).getAxis(RotationConvention.VECTOR_OPERATOR),
createVector(+1, 0, 0));
+
+    }
+
+    @Test
     public void testRevert() {
         double a = 0.001;
         double b = 0.36;
@@ -96,7 +179,10 @@ public class FieldRotationDfpTest {
         FieldRotation<Dfp> rTr = reverted.applyTo(r);
         checkRotationDS(rTr, 1, 0, 0, 0);
         Assert.assertEquals(r.getAngle().getReal(), reverted.getAngle().getReal(), 1.0e-15);
-        Assert.assertEquals(-1, FieldVector3D.dotProduct(r.getAxis(), reverted.getAxis()).getReal(),
1.0e-15);
+        Assert.assertEquals(-1,
+                            FieldVector3D.dotProduct(r.getAxis(RotationConvention.VECTOR_OPERATOR),
+                                                     reverted.getAxis(RotationConvention.VECTOR_OPERATOR)).getReal(),
+                            1.0e-15);
     }
 
     @Test
@@ -130,7 +216,7 @@ public class FieldRotationDfpTest {
         checkVector(r.applyTo(createVector(0, 1, 0)), createVector(-1, 0, 0));
 
         r = new FieldRotation<Dfp>(u1, u2, u1.negate(), u2.negate());
-        FieldVector3D<Dfp> axis = r.getAxis();
+        FieldVector3D<Dfp> axis = r.getAxis(RotationConvention.VECTOR_OPERATOR);
         if (FieldVector3D.dotProduct(axis, createVector(0, 0, 1)).getReal() > 0) {
             checkVector(axis, createVector(0, 0, 1));
         } else {
@@ -305,7 +391,8 @@ public class FieldRotationDfpTest {
     }
 
     @Test
-    public void testAngles()
+    @Deprecated
+    public void testAnglesDeprecated()
             throws CardanEulerSingularityException {
 
         DfpField field = new DfpField(15);
@@ -357,62 +444,123 @@ public class FieldRotationDfpTest {
     }
 
     @Test
-    public void testSingularities() {
+    public void testAngles()
+        throws CardanEulerSingularityException {
 
-        DfpField field = new DfpField(20);
-        RotationOrder[] CardanOrders = {
-            RotationOrder.XYZ, RotationOrder.XZY, RotationOrder.YXZ,
-            RotationOrder.YZX, RotationOrder.ZXY, RotationOrder.ZYX
-        };
+        DfpField field = new DfpField(15);
 
-        double[] singularCardanAngle = { FastMath.PI / 2, -FastMath.PI / 2 };
-        for (int i = 0; i < CardanOrders.length; ++i) {
-            for (int j = 0; j < singularCardanAngle.length; ++j) {
-                FieldRotation<Dfp> r = new FieldRotation<Dfp>(CardanOrders[i],
-                                                              field.newDfp(0.1),
-                                                              field.newDfp(singularCardanAngle[j]),
-                                                              field.newDfp(0.3));
-                try {
-                    r.getAngles(CardanOrders[i]);
-                    Assert.fail("an exception should have been caught");
-                } catch (CardanEulerSingularityException cese) {
-                    // expected behavior
+        for (RotationConvention convention : RotationConvention.values()) {
+            RotationOrder[] CardanOrders = {
+                RotationOrder.XYZ, RotationOrder.XZY, RotationOrder.YXZ,
+                RotationOrder.YZX, RotationOrder.ZXY, RotationOrder.ZYX
+            };
+
+            for (int i = 0; i < CardanOrders.length; ++i) {
+                for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) {
+                    for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.8) {
+                        for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) {
+                            FieldRotation<Dfp> r = new FieldRotation<Dfp>(CardanOrders[i],
+                                                                          convention,
+                                                                          field.newDfp(alpha1),
+                                                                          field.newDfp(alpha2),
+                                                                          field.newDfp(alpha3));
+                            Dfp[] angles = r.getAngles(CardanOrders[i], convention);
+                            checkAngle(angles[0], alpha1);
+                            checkAngle(angles[1], alpha2);
+                            checkAngle(angles[2], alpha3);
+                        }
+                    }
+                }
+            }
+
+            RotationOrder[] EulerOrders = {
+                RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
+                RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
+            };
+
+            for (int i = 0; i < EulerOrders.length; ++i) {
+                for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 2.0) {
+                    for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.8) {
+                        for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 2.0) {
+                            FieldRotation<Dfp> r = new FieldRotation<Dfp>(EulerOrders[i],
+                                                                          convention,
+                                                                          field.newDfp(alpha1),
+                                                                          field.newDfp(alpha2),
+                                                                          field.newDfp(alpha3));
+                            Dfp[] angles = r.getAngles(EulerOrders[i], convention);
+                            checkAngle(angles[0], alpha1);
+                            checkAngle(angles[1], alpha2);
+                            checkAngle(angles[2], alpha3);
+                        }
+                    }
                 }
             }
         }
 
-        RotationOrder[] EulerOrders = {
-            RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
-            RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
-        };
+    }
 
-        double[] singularEulerAngle = { 0, FastMath.PI };
-        for (int i = 0; i < EulerOrders.length; ++i) {
-            for (int j = 0; j < singularEulerAngle.length; ++j) {
-                FieldRotation<Dfp> r = new FieldRotation<Dfp>(EulerOrders[i],
-                                                              field.newDfp(0.1),
-                                                              field.newDfp(singularEulerAngle[j]),
-                                                              field.newDfp(0.3));
-                try {
-                    r.getAngles(EulerOrders[i]);
-                    Assert.fail("an exception should have been caught");
-                } catch (CardanEulerSingularityException cese) {
-                    // expected behavior
+    @Test
+    public void testSingularities() {
+
+        DfpField field = new DfpField(20);
+        for (RotationConvention convention : RotationConvention.values()) {
+            RotationOrder[] CardanOrders = {
+                RotationOrder.XYZ, RotationOrder.XZY, RotationOrder.YXZ,
+                RotationOrder.YZX, RotationOrder.ZXY, RotationOrder.ZYX
+            };
+
+            double[] singularCardanAngle = { FastMath.PI / 2, -FastMath.PI / 2 };
+            for (int i = 0; i < CardanOrders.length; ++i) {
+                for (int j = 0; j < singularCardanAngle.length; ++j) {
+                    FieldRotation<Dfp> r = new FieldRotation<Dfp>(CardanOrders[i],
+                                                                  convention,
+                                                                  field.newDfp(0.1),
+                                                                  field.newDfp(singularCardanAngle[j]),
+                                                                  field.newDfp(0.3));
+                    try {
+                        r.getAngles(CardanOrders[i], convention);
+                        Assert.fail("an exception should have been caught");
+                    } catch (CardanEulerSingularityException cese) {
+                        // expected behavior
+                    }
                 }
             }
-        }
 
+            RotationOrder[] EulerOrders = {
+                RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
+                RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
+            };
+
+            double[] singularEulerAngle = { 0, FastMath.PI };
+            for (int i = 0; i < EulerOrders.length; ++i) {
+                for (int j = 0; j < singularEulerAngle.length; ++j) {
+                    FieldRotation<Dfp> r = new FieldRotation<Dfp>(EulerOrders[i],
+                                                                  convention,
+                                                                  field.newDfp(0.1),
+                                                                  field.newDfp(singularEulerAngle[j]),
+                                                                  field.newDfp(0.3));
+                    try {
+                        r.getAngles(EulerOrders[i], convention);
+                        Assert.fail("an exception should have been caught");
+                    } catch (CardanEulerSingularityException cese) {
+                        // expected behavior
+                    }
+                }
+            }
 
+        }
     }
 
     @Test
     public void testQuaternion() throws MathIllegalArgumentException {
 
-        FieldRotation<Dfp> r1 = new FieldRotation<Dfp>(createVector(2, -3, 5),
createAngle(1.7));
+        FieldRotation<Dfp> r1 = new FieldRotation<Dfp>(createVector(2, -3, 5),
+                                                       createAngle(1.7),
+                                                       RotationConvention.VECTOR_OPERATOR);
         double n = 23.5;
         FieldRotation<Dfp> r2 = new FieldRotation<Dfp>(r1.getQ0().multiply(n),
r1.getQ1().multiply(n),
-                                       r1.getQ2().multiply(n), r1.getQ3().multiply(n),
-                                       true);
+                                                       r1.getQ2().multiply(n), r1.getQ3().multiply(n),
+                                                       true);
         for (double x = -0.9; x < 0.9; x += 0.2) {
             for (double y = -0.9; y < 0.9; y += 0.2) {
                 for (double z = -0.9; z < 0.9; z += 0.2) {
@@ -432,8 +580,12 @@ public class FieldRotationDfpTest {
     @Test
     public void testCompose() throws MathIllegalArgumentException {
 
-        FieldRotation<Dfp> r1       = new FieldRotation<Dfp>(createVector(2,
-3, 5), createAngle(1.7));
-        FieldRotation<Dfp> r2       = new FieldRotation<Dfp>(createVector(-1,
3, 2), createAngle(0.3));
+        FieldRotation<Dfp> r1       = new FieldRotation<Dfp>(createVector(2,
-3, 5),
+                                                             createAngle(1.7),
+                                                             RotationConvention.VECTOR_OPERATOR);
+        FieldRotation<Dfp> r2       = new FieldRotation<Dfp>(createVector(-1,
3, 2),
+                                                             createAngle(0.3),
+                                                             RotationConvention.VECTOR_OPERATOR);
         FieldRotation<Dfp> r3       = r2.applyTo(r1);
         FieldRotation<Dfp> r3Double = r2.applyTo(new Rotation(r1.getQ0().getReal(),
                                                       r1.getQ1().getReal(),
@@ -456,8 +608,12 @@ public class FieldRotationDfpTest {
     @Test
     public void testComposeInverse() throws MathIllegalArgumentException {
 
-        FieldRotation<Dfp> r1 = new FieldRotation<Dfp>(createVector(2, -3, 5),
createAngle(1.7));
-        FieldRotation<Dfp> r2 = new FieldRotation<Dfp>(createVector(-1, 3, 2),
createAngle(0.3));
+        FieldRotation<Dfp> r1 = new FieldRotation<Dfp>(createVector(2, -3, 5),
+                                                       createAngle(1.7),
+                                                       RotationConvention.VECTOR_OPERATOR);
+        FieldRotation<Dfp> r2 = new FieldRotation<Dfp>(createVector(-1, 3, 2),
+                                                       createAngle(0.3),
+                                                       RotationConvention.VECTOR_OPERATOR);
         FieldRotation<Dfp> r3 = r2.applyInverseTo(r1);
         FieldRotation<Dfp> r3Double = r2.applyInverseTo(new Rotation(r1.getQ0().getReal(),
                                                              r1.getQ1().getReal(),
@@ -485,7 +641,8 @@ public class FieldRotationDfpTest {
         for (int i = 0; i < 10; ++i) {
             double[] unit = g.nextVector();
             FieldRotation<Dfp> r = new FieldRotation<Dfp>(createVector(unit[0],
unit[1], unit[2]),
-                                          createAngle(random.nextDouble()));
+                                                          createAngle(random.nextDouble()),
+                                                          RotationConvention.VECTOR_OPERATOR);
 
             for (double x = -0.9; x < 0.9; x += 0.4) {
                 for (double y = -0.9; y < 0.9; y += 0.4) {
@@ -520,7 +677,7 @@ public class FieldRotationDfpTest {
         for (int i = 0; i < 10; ++i) {
             double[] unit1 = g.nextVector();
             Rotation r1 = new Rotation(new Vector3D(unit1[0], unit1[1], unit1[2]),
-                                      random.nextDouble());
+                                      random.nextDouble(), RotationConvention.VECTOR_OPERATOR);
             FieldRotation<Dfp> r1Prime = new FieldRotation<Dfp>(field.newDfp(r1.getQ0()),
                                                                 field.newDfp(r1.getQ1()),
                                                                 field.newDfp(r1.getQ2()),
@@ -528,7 +685,8 @@ public class FieldRotationDfpTest {
                                                                 false);
             double[] unit2 = g.nextVector();
             FieldRotation<Dfp> r2 = new FieldRotation<Dfp>(createVector(unit2[0],
unit2[1], unit2[2]),
-                                           createAngle(random.nextDouble()));
+                                                           createAngle(random.nextDouble()),
+                                                           RotationConvention.VECTOR_OPERATOR);
 
             FieldRotation<Dfp> rA = FieldRotation.applyTo(r1, r2);
             FieldRotation<Dfp> rB = r1Prime.applyTo(r2);
@@ -557,7 +715,9 @@ public class FieldRotationDfpTest {
     @Test
     public void testArray() throws MathIllegalArgumentException {
 
-        FieldRotation<Dfp> r = new FieldRotation<Dfp>(createAxis(2, -3, 5), createAngle(1.7));
+        FieldRotation<Dfp> r = new FieldRotation<Dfp>(createAxis(2, -3, 5),
+                                                      createAngle(1.7),
+                                                      RotationConvention.VECTOR_OPERATOR);
 
         for (double x = -0.9; x < 0.9; x += 0.2) {
             for (double y = -0.9; y < 0.9; y += 0.2) {
@@ -585,7 +745,9 @@ public class FieldRotationDfpTest {
         Dfp[] in      = new Dfp[3];
         Dfp[] out     = new Dfp[3];
         Dfp[] rebuilt = new Dfp[3];
-        FieldRotation<Dfp> r = new FieldRotation<Dfp>(createVector(2, -3, 5),
createAngle(1.7));
+        FieldRotation<Dfp> r = new FieldRotation<Dfp>(createVector(2, -3, 5),
+                                                      createAngle(1.7),
+                                                      RotationConvention.VECTOR_OPERATOR);
         for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
             for (double phi = -1.55; phi < 1.55; phi += 0.2) {
                 FieldVector3D<Dfp> u = createVector(FastMath.cos(lambda) * FastMath.cos(phi),
@@ -616,7 +778,7 @@ public class FieldRotationDfpTest {
             }
         }
 
-        r = new FieldRotation<Dfp>(createVector(0, 0, 1), createAngle(FastMath.PI));
+        r = new FieldRotation<Dfp>(createVector(0, 0, 1), createAngle(FastMath.PI),
RotationConvention.VECTOR_OPERATOR);
         for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
             for (double phi = -1.55; phi < 1.55; phi += 0.2) {
                 FieldVector3D<Dfp> u = createVector(FastMath.cos(lambda) * FastMath.cos(phi),

http://git-wip-us.apache.org/repos/asf/commons-math/blob/971a7786/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PlaneTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PlaneTest.java
b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PlaneTest.java
index 081ccb6..6409365 100644
--- a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PlaneTest.java
+++ b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PlaneTest.java
@@ -74,17 +74,17 @@ public class PlaneTest {
         Plane    p  = new Plane(p1, p2, p3, 1.0e-10);
         Vector3D oldNormal = p.getNormal();
 
-        p = p.rotate(p2, new Rotation(p2.subtract(p1), 1.7));
+        p = p.rotate(p2, new Rotation(p2.subtract(p1), 1.7, RotationConvention.VECTOR_OPERATOR));
         Assert.assertTrue(p.contains(p1));
         Assert.assertTrue(p.contains(p2));
         Assert.assertTrue(! p.contains(p3));
 
-        p = p.rotate(p2, new Rotation(oldNormal, 0.1));
+        p = p.rotate(p2, new Rotation(oldNormal, 0.1, RotationConvention.VECTOR_OPERATOR));
         Assert.assertTrue(! p.contains(p1));
         Assert.assertTrue(p.contains(p2));
         Assert.assertTrue(! p.contains(p3));
 
-        p = p.rotate(p1, new Rotation(oldNormal, 0.1));
+        p = p.rotate(p1, new Rotation(oldNormal, 0.1, RotationConvention.VECTOR_OPERATOR));
         Assert.assertTrue(! p.contains(p1));
         Assert.assertTrue(! p.contains(p2));
         Assert.assertTrue(! p.contains(p3));

http://git-wip-us.apache.org/repos/asf/commons-math/blob/971a7786/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java
b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java
index c6fdcfb..10561f5 100644
--- a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java
+++ b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSetTest.java
@@ -142,7 +142,7 @@ public class PolyhedronsSetTest {
         Vector3D barycenter = (Vector3D) tree.getBarycenter();
         Vector3D s = new Vector3D(10.2, 4.3, -6.7);
         Vector3D c = new Vector3D(-0.2, 2.1, -3.2);
-        Rotation r = new Rotation(new Vector3D(6.2, -4.4, 2.1), 0.12);
+        Rotation r = new Rotation(new Vector3D(6.2, -4.4, 2.1), 0.12, RotationConvention.VECTOR_OPERATOR);
 
         tree = tree.rotate(c, r).translate(s);
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/971a7786/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationTest.java
b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationTest.java
index ce38a40..532201a 100644
--- a/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationTest.java
+++ b/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/RotationTest.java
@@ -51,7 +51,8 @@ public class RotationTest {
   }
 
   @Test
-  public void testAxisAngle() throws MathIllegalArgumentException {
+  @Deprecated
+  public void testAxisAngleDeprecated() throws MathIllegalArgumentException {
 
     Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * FastMath.PI / 3);
     checkVector(r.applyTo(Vector3D.PLUS_I), Vector3D.PLUS_J);
@@ -80,13 +81,82 @@ public class RotationTest {
   }
 
   @Test
+  public void testAxisAngleVectorOperator() throws MathIllegalArgumentException {
+
+    Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * FastMath.PI / 3, RotationConvention.VECTOR_OPERATOR);
+    checkVector(r.applyTo(Vector3D.PLUS_I), Vector3D.PLUS_J);
+    checkVector(r.applyTo(Vector3D.PLUS_J), Vector3D.PLUS_K);
+    checkVector(r.applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I);
+    double s = 1 / FastMath.sqrt(3);
+    checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Vector3D( s,  s,  s));
+    checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Vector3D(-s, -s, -s));
+    checkAngle(r.getAngle(), 2 * FastMath.PI / 3);
+
+    try {
+      new Rotation(new Vector3D(0, 0, 0), 2 * FastMath.PI / 3, RotationConvention.VECTOR_OPERATOR);
+      Assert.fail("an exception should have been thrown");
+    } catch (MathIllegalArgumentException e) {
+    }
+
+    r = new Rotation(Vector3D.PLUS_K, 1.5 * FastMath.PI, RotationConvention.VECTOR_OPERATOR);
+    checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Vector3D(0, 0, -1));
+    checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Vector3D(0, 0, +1));
+    checkAngle(r.getAngle(), 0.5 * FastMath.PI);
+
+    r = new Rotation(Vector3D.PLUS_J, FastMath.PI, RotationConvention.VECTOR_OPERATOR);
+    checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Vector3D.PLUS_J);
+    checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Vector3D.MINUS_J);
+    checkAngle(r.getAngle(), FastMath.PI);
+
+    checkVector(Rotation.IDENTITY.getAxis(RotationConvention.VECTOR_OPERATOR), Vector3D.PLUS_I);
+    checkVector(Rotation.IDENTITY.getAxis(RotationConvention.FRAME_TRANSFORM), Vector3D.MINUS_I);
+
+  }
+
+  @Test
+  public void testAxisAngleFrameTransform() throws MathIllegalArgumentException {
+
+    Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * FastMath.PI / 3, RotationConvention.FRAME_TRANSFORM);
+    checkVector(r.applyTo(Vector3D.PLUS_I), Vector3D.PLUS_K);
+    checkVector(r.applyTo(Vector3D.PLUS_J), Vector3D.PLUS_I);
+    checkVector(r.applyTo(Vector3D.PLUS_K), Vector3D.PLUS_J);
+    double s = 1 / FastMath.sqrt(3);
+    checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Vector3D( s,  s,  s));
+    checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Vector3D(-s, -s, -s));
+    checkAngle(r.getAngle(), 2 * FastMath.PI / 3);
+
+    try {
+      new Rotation(new Vector3D(0, 0, 0), 2 * FastMath.PI / 3, RotationConvention.FRAME_TRANSFORM);
+      Assert.fail("an exception should have been thrown");
+    } catch (MathIllegalArgumentException e) {
+    }
+
+    r = new Rotation(Vector3D.PLUS_K, 1.5 * FastMath.PI, RotationConvention.FRAME_TRANSFORM);
+    checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Vector3D(0, 0, -1));
+    checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Vector3D(0, 0, +1));
+    checkAngle(r.getAngle(), 0.5 * FastMath.PI);
+
+    r = new Rotation(Vector3D.PLUS_J, FastMath.PI, RotationConvention.FRAME_TRANSFORM);
+    checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Vector3D.PLUS_J);
+    checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Vector3D.MINUS_J);
+    checkAngle(r.getAngle(), FastMath.PI);
+
+    checkVector(Rotation.IDENTITY.getAxis(RotationConvention.FRAME_TRANSFORM), Vector3D.MINUS_I);
+    checkVector(Rotation.IDENTITY.getAxis(RotationConvention.VECTOR_OPERATOR), Vector3D.PLUS_I);
+
+  }
+
+  @Test
   public void testRevert() {
     Rotation r = new Rotation(0.001, 0.36, 0.48, 0.8, true);
     Rotation reverted = r.revert();
     checkRotation(r.applyTo(reverted), 1, 0, 0, 0);
     checkRotation(reverted.applyTo(r), 1, 0, 0, 0);
     Assert.assertEquals(r.getAngle(), reverted.getAngle(), 1.0e-12);
-    Assert.assertEquals(-1, Vector3D.dotProduct(r.getAxis(), reverted.getAxis()), 1.0e-12);
+    Assert.assertEquals(-1,
+                        Vector3D.dotProduct(r.getAxis(RotationConvention.VECTOR_OPERATOR),
+                                           reverted.getAxis(RotationConvention.VECTOR_OPERATOR)),
+                        1.0e-12);
   }
 
   @Test
@@ -120,7 +190,7 @@ public class RotationTest {
     checkVector(r.applyTo(Vector3D.PLUS_J), Vector3D.MINUS_I);
 
     r = new Rotation(u1, u2, u1.negate(), u2.negate());
-    Vector3D axis = r.getAxis();
+    Vector3D axis = r.getAxis(RotationConvention.VECTOR_OPERATOR);
     if (Vector3D.dotProduct(axis, Vector3D.PLUS_K) > 0) {
       checkVector(axis, Vector3D.PLUS_K);
     } else {
@@ -295,7 +365,8 @@ public class RotationTest {
   }
 
   @Test
-  public void testAngles()
+  @Deprecated
+  public void testAnglesDeprecated()
     throws CardanEulerSingularityException {
 
     RotationOrder[] CardanOrders = {
@@ -320,7 +391,7 @@ public class RotationTest {
     RotationOrder[] EulerOrders = {
             RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
             RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
-          };
+    };
 
     for (int i = 0; i < EulerOrders.length; ++i) {
       for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 0.3) {
@@ -340,43 +411,92 @@ public class RotationTest {
   }
 
   @Test
-  public void testSingularities() {
+  public void testAngles()
+      throws CardanEulerSingularityException {
 
-    RotationOrder[] CardanOrders = {
-      RotationOrder.XYZ, RotationOrder.XZY, RotationOrder.YXZ,
-      RotationOrder.YZX, RotationOrder.ZXY, RotationOrder.ZYX
-    };
+      for (RotationConvention convention : RotationConvention.values()) {
+          RotationOrder[] CardanOrders = {
+              RotationOrder.XYZ, RotationOrder.XZY, RotationOrder.YXZ,
+              RotationOrder.YZX, RotationOrder.ZXY, RotationOrder.ZYX
+          };
 
-    double[] singularCardanAngle = { FastMath.PI / 2, -FastMath.PI / 2 };
-    for (int i = 0; i < CardanOrders.length; ++i) {
-      for (int j = 0; j < singularCardanAngle.length; ++j) {
-        Rotation r = new Rotation(CardanOrders[i], 0.1, singularCardanAngle[j], 0.3);
-        try {
-          r.getAngles(CardanOrders[i]);
-          Assert.fail("an exception should have been caught");
-        } catch (CardanEulerSingularityException cese) {
-          // expected behavior
-        }
+          for (int i = 0; i < CardanOrders.length; ++i) {
+              for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 0.3) {
+                  for (double alpha2 = -1.55; alpha2 < 1.55; alpha2 += 0.3) {
+                      for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) {
+                          Rotation r = new Rotation(CardanOrders[i], convention, alpha1,
alpha2, alpha3);
+                          double[] angles = r.getAngles(CardanOrders[i], convention);
+                          checkAngle(angles[0], alpha1);
+                          checkAngle(angles[1], alpha2);
+                          checkAngle(angles[2], alpha3);
+                      }
+                  }
+              }
+          }
+
+          RotationOrder[] EulerOrders = {
+              RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
+              RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
+          };
+
+          for (int i = 0; i < EulerOrders.length; ++i) {
+              for (double alpha1 = 0.1; alpha1 < 6.2; alpha1 += 0.3) {
+                  for (double alpha2 = 0.05; alpha2 < 3.1; alpha2 += 0.3) {
+                      for (double alpha3 = 0.1; alpha3 < 6.2; alpha3 += 0.3) {
+                          Rotation r = new Rotation(EulerOrders[i], convention,
+                                                    alpha1, alpha2, alpha3);
+                          double[] angles = r.getAngles(EulerOrders[i], convention);
+                          checkAngle(angles[0], alpha1);
+                          checkAngle(angles[1], alpha2);
+                          checkAngle(angles[2], alpha3);
+                      }
+                  }
+              }
+          }
       }
-    }
 
-    RotationOrder[] EulerOrders = {
-            RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
-            RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
+  }
+
+  @Test
+  public void testSingularities() {
+
+      for (RotationConvention convention : RotationConvention.values()) {
+          RotationOrder[] CardanOrders = {
+              RotationOrder.XYZ, RotationOrder.XZY, RotationOrder.YXZ,
+              RotationOrder.YZX, RotationOrder.ZXY, RotationOrder.ZYX
           };
 
-    double[] singularEulerAngle = { 0, FastMath.PI };
-    for (int i = 0; i < EulerOrders.length; ++i) {
-      for (int j = 0; j < singularEulerAngle.length; ++j) {
-        Rotation r = new Rotation(EulerOrders[i], 0.1, singularEulerAngle[j], 0.3);
-        try {
-          r.getAngles(EulerOrders[i]);
-          Assert.fail("an exception should have been caught");
-        } catch (CardanEulerSingularityException cese) {
-          // expected behavior
-        }
+          double[] singularCardanAngle = { FastMath.PI / 2, -FastMath.PI / 2 };
+          for (int i = 0; i < CardanOrders.length; ++i) {
+              for (int j = 0; j < singularCardanAngle.length; ++j) {
+                  Rotation r = new Rotation(CardanOrders[i], convention, 0.1, singularCardanAngle[j],
0.3);
+                  try {
+                      r.getAngles(CardanOrders[i], convention);
+                      Assert.fail("an exception should have been caught");
+                  } catch (CardanEulerSingularityException cese) {
+                      // expected behavior
+                  }
+              }
+          }
+
+          RotationOrder[] EulerOrders = {
+              RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
+              RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
+          };
+
+          double[] singularEulerAngle = { 0, FastMath.PI };
+          for (int i = 0; i < EulerOrders.length; ++i) {
+              for (int j = 0; j < singularEulerAngle.length; ++j) {
+                  Rotation r = new Rotation(EulerOrders[i], convention, 0.1, singularEulerAngle[j],
0.3);
+                  try {
+                      r.getAngles(EulerOrders[i], convention);
+                      Assert.fail("an exception should have been caught");
+                  } catch (CardanEulerSingularityException cese) {
+                      // expected behavior
+                  }
+              }
+          }
       }
-    }
 
 
   }
@@ -384,7 +504,7 @@ public class RotationTest {
   @Test
   public void testQuaternion() throws MathIllegalArgumentException {
 
-    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
+    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
     double n = 23.5;
     Rotation r2 = new Rotation(n * r1.getQ0(), n * r1.getQ1(),
                                n * r1.getQ2(), n * r1.getQ3(),
@@ -406,8 +526,8 @@ public class RotationTest {
   @Test
   public void testCompose() throws MathIllegalArgumentException {
 
-    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
-    Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3);
+    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+    Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
     Rotation r3 = r2.applyTo(r1);
 
     for (double x = -0.9; x < 0.9; x += 0.2) {
@@ -424,8 +544,8 @@ public class RotationTest {
   @Test
   public void testComposeInverse() throws MathIllegalArgumentException {
 
-    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
-    Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3);
+    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+    Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
     Rotation r3 = r2.applyInverseTo(r1);
 
     for (double x = -0.9; x < 0.9; x += 0.2) {
@@ -442,7 +562,7 @@ public class RotationTest {
   @Test
   public void testArray() throws MathIllegalArgumentException {
 
-      Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7);
+      Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
 
       for (double x = -0.9; x < 0.9; x += 0.2) {
           for (double y = -0.9; y < 0.9; y += 0.2) {
@@ -467,7 +587,7 @@ public class RotationTest {
   @Test
   public void testApplyInverseTo() throws MathIllegalArgumentException {
 
-    Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7);
+    Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
     for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
       for (double phi = -1.55; phi < 1.55; phi += 0.2) {
           Vector3D u = new Vector3D(FastMath.cos(lambda) * FastMath.cos(phi),
@@ -490,7 +610,7 @@ public class RotationTest {
       }
     }
 
-    r = new Rotation(Vector3D.PLUS_K, FastMath.PI);
+    r = new Rotation(Vector3D.PLUS_K, FastMath.PI, RotationConvention.VECTOR_OPERATOR);
     for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
       for (double phi = -1.55; phi < 1.55; phi += 0.2) {
           Vector3D u = new Vector3D(FastMath.cos(lambda) * FastMath.cos(phi),
@@ -537,6 +657,48 @@ public class RotationTest {
 
   }
 
+  @Test
+  public void testGithubPullRequest22A() {
+      final RotationOrder order = RotationOrder.ZYX;
+      final double xRotation = FastMath.toDegrees(30);
+      final double yRotation = FastMath.toDegrees(20);
+      final double zRotation = FastMath.toDegrees(10);
+      final Vector3D startingVector = Vector3D.PLUS_I;
+      Vector3D appliedIndividually = startingVector;
+      appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, zRotation,
0, 0).applyTo(appliedIndividually);
+      appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, 0, yRotation,
0).applyTo(appliedIndividually);
+      appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, 0, 0,
xRotation).applyTo(appliedIndividually);
+
+      final Vector3D bad = new Rotation(order, RotationConvention.FRAME_TRANSFORM, zRotation,
yRotation, xRotation).applyTo(startingVector);
+
+      Assert.assertEquals(bad.getX(), appliedIndividually.getX(), 1e-12);
+      Assert.assertEquals(bad.getY(), appliedIndividually.getY(), 1e-12);
+      Assert.assertEquals(bad.getZ(), appliedIndividually.getZ(), 1e-12);
+  }
+
+  @Test
+  public void testGithubPullRequest22B() {
+      final RotationOrder order = RotationOrder.ZYX;
+      final double xRotation = FastMath.toDegrees(30);
+      final double yRotation = FastMath.toDegrees(20);
+      final double zRotation = FastMath.toDegrees(10);
+      final Vector3D startingVector = Vector3D.PLUS_I;
+      Vector3D appliedIndividually = startingVector;
+      appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, zRotation,
0, 0).applyTo(appliedIndividually);
+      appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, 0, yRotation,
0).applyTo(appliedIndividually);
+      appliedIndividually = new Rotation(order, RotationConvention.FRAME_TRANSFORM, 0, 0,
xRotation).applyTo(appliedIndividually);
+
+      final Rotation r1 = new Rotation(order.getA1(), zRotation, RotationConvention.FRAME_TRANSFORM);
+      final Rotation r2 = new Rotation(order.getA2(), yRotation, RotationConvention.FRAME_TRANSFORM);
+      final Rotation r3 = new Rotation(order.getA3(), xRotation, RotationConvention.FRAME_TRANSFORM);
+      final Rotation composite = r3.applyTo(r2.applyTo(r1));
+      final Vector3D good = composite.applyTo(startingVector);
+
+      Assert.assertEquals(good.getX(), appliedIndividually.getX(), 1e-12);
+      Assert.assertEquals(good.getY(), appliedIndividually.getY(), 1e-12);
+      Assert.assertEquals(good.getZ(), appliedIndividually.getZ(), 1e-12);
+  }
+
   private void checkVector(Vector3D v1, Vector3D v2) {
     Assert.assertTrue(v1.subtract(v2).getNorm() < 1.0e-10);
   }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/971a7786/src/test/java/org/apache/commons/math3/geometry/spherical/twod/CircleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/geometry/spherical/twod/CircleTest.java
b/src/test/java/org/apache/commons/math3/geometry/spherical/twod/CircleTest.java
index 4258399..713a905 100644
--- a/src/test/java/org/apache/commons/math3/geometry/spherical/twod/CircleTest.java
+++ b/src/test/java/org/apache/commons/math3/geometry/spherical/twod/CircleTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.math3.geometry.spherical.twod;
 
 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.geometry.partitioning.Transform;
 import org.apache.commons.math3.geometry.spherical.oned.Arc;
@@ -159,7 +160,8 @@ public class CircleTest {
         for (int i = 0; i < 100; ++i) {
 
             Rotation r = new Rotation(new Vector3D(sphRandom.nextVector()),
-                                      FastMath.PI * random.nextDouble());
+                                      FastMath.PI * random.nextDouble(),
+                                      RotationConvention.VECTOR_OPERATOR);
             Transform<Sphere2D, Sphere1D> t = Circle.getTransform(r);
 
             S2Point  p = new S2Point(new Vector3D(sphRandom.nextVector()));


Mime
View raw message