Repository: commons-math
Updated Branches:
  refs/heads/master afa120227 -> a7294ccd7


http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7294ccd/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
index c63cf6d..8f6738c 100644
--- 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
+++ 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotationDfpTest.java
@@ -62,7 +62,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));
@@ -91,6 +92,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;
@@ -103,7 +186,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
@@ -137,7 +223,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 {
@@ -312,7 +398,8 @@ public class FieldRotationDfpTest {
     }
 
     @Test
-    public void testAngles()
+    @Deprecated
+    public void testAnglesDeprecated()
             throws CardanEulerSingularityException {
 
         DfpField field = new DfpField(15);
@@ -364,62 +451,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) {
@@ -439,8 +587,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(),
@@ -463,8 +615,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(),
@@ -492,7 +648,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) {
@@ -527,7 +684,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()),
@@ -535,7 +692,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);
@@ -564,7 +722,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) {
@@ -592,7 +752,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),
@@ -623,7 +785,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/a7294ccd/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java
 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java
index 0f424e5..3991a10 100644
--- 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PlaneTest.java
+++ 
b/src/test/java/org/apache/commons/math4/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/a7294ccd/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
index 5630f34..b1b902a 100644
--- 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
+++ 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java
@@ -146,7 +146,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/a7294ccd/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
index 6739625..c7894fd 100644
--- 
a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
+++ 
b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/RotationTest.java
@@ -56,7 +56,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);
@@ -85,13 +86,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
@@ -125,7 +195,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 {
@@ -300,7 +370,8 @@ public class RotationTest {
   }
 
   @Test
-  public void testAngles()
+  @Deprecated
+  public void testAnglesDeprecated()
     throws CardanEulerSingularityException {
 
     RotationOrder[] CardanOrders = {
@@ -325,7 +396,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) {
@@ -345,43 +416,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
+                  }
+              }
+          }
       }
-    }
 
 
   }
@@ -389,7 +509,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(),
@@ -411,8 +531,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) {
@@ -429,8 +549,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) {
@@ -447,7 +567,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) {
@@ -472,7 +592,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),
@@ -495,7 +615,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),
@@ -542,6 +662,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/a7294ccd/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
 
b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
index e6934b1..352bdd9 100644
--- 
a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
+++ 
b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.math4.geometry.spherical.twod;
 
 import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
+import org.apache.commons.math4.geometry.euclidean.threed.RotationConvention;
 import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
 import org.apache.commons.math4.geometry.partitioning.Transform;
 import org.apache.commons.math4.geometry.spherical.oned.Arc;
@@ -162,7 +163,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()));

Reply via email to