You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2013/02/26 10:29:25 UTC

svn commit: r1450096 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/geometry/euclidean/threed/ test/java/org/apache/commons/math3/geometry/euclidean/threed/

Author: luc
Date: Tue Feb 26 09:29:25 2013
New Revision: 1450096

URL: http://svn.apache.org/r1450096
Log:
Brought back some useful static methods.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDSTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3DTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java?rev=1450096&r1=1450095&r2=1450096&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotation.java Tue Feb 26 09:29:25 2013
@@ -219,14 +219,14 @@ public class FieldRotation<T extends Ext
 
         // build orthonormalized base from u1, u2
         // this fails when vectors are null or colinear, which is forbidden to define a rotation
-        final FieldVector3D<T> u3 = u1.crossProduct(u2).normalize();
-        u2 = u3.crossProduct(u1).normalize();
+        final FieldVector3D<T> u3 = FieldVector3D.crossProduct(u1, u2).normalize();
+        u2 = FieldVector3D.crossProduct(u3, u1).normalize();
         u1 = u1.normalize();
 
         // build an orthonormalized base from v1, v2
         // this fails when vectors are null or colinear, which is forbidden to define a rotation
-        final FieldVector3D<T> v3 = v1.crossProduct(v2).normalize();
-        v2 = v3.crossProduct(v1).normalize();
+        final FieldVector3D<T> v3 = FieldVector3D.crossProduct(v1, v2).normalize();
+        v2 = FieldVector3D.crossProduct(v3, v1).normalize();
         v1 = v1.normalize();
 
         // buid a matrix transforming the first base into the second one
@@ -269,7 +269,7 @@ public class FieldRotation<T extends Ext
             throw new MathArithmeticException(LocalizedFormats.ZERO_NORM_FOR_ROTATION_DEFINING_VECTOR);
         }
 
-        final T dot = u.dotProduct(v);
+        final T dot = FieldVector3D.dotProduct(u, v);
 
         if (dot.getReal() < ((2.0e-15 - 1.0) * normProduct.getReal())) {
             // special case u = -v: we select a PI angle rotation around
@@ -284,7 +284,7 @@ public class FieldRotation<T extends Ext
             // the shortest possible rotation: axis orthogonal to this plane
             q0 = dot.divide(normProduct).add(1.0).multiply(0.5).sqrt();
             final T coeff = q0.multiply(normProduct).multiply(2.0).reciprocal();
-            final FieldVector3D<T> q = v.crossProduct(u);
+            final FieldVector3D<T> q = FieldVector3D.crossProduct(v, u);
             q1 = coeff.multiply(q.getX());
             q2 = coeff.multiply(q.getY());
             q3 = coeff.multiply(q.getZ());
@@ -831,6 +831,7 @@ public class FieldRotation<T extends Ext
     /** Apply a rotation to a vector.
      * @param r rotation to apply
      * @param u vector to apply the rotation to
+     * @param <T> the type of the field elements
      * @return a new vector which is the image of u by the rotation
      */
     public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> applyTo(final Rotation r, final FieldVector3D<T> u) {
@@ -927,6 +928,7 @@ public class FieldRotation<T extends Ext
     /** Apply the inverse of a rotation to a vector.
      * @param r rotation to apply
      * @param u vector to apply the inverse of the rotation to
+     * @param <T> the type of the field elements
      * @return a new vector which such that u is its image by the rotation
      */
     public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> applyInverseTo(final Rotation r, final FieldVector3D<T> u) {
@@ -986,6 +988,7 @@ public class FieldRotation<T extends Ext
      * where comp = applyTo(rOuter, rInner).
      * @param r1 rotation to apply
      * @param rInner rotation to apply the rotation to
+     * @param <T> the type of the field elements
      * @return a new rotation which is the composition of r by the instance
      */
     public static <T extends ExtendedFieldElement<T>> FieldRotation<T> applyTo(final Rotation r1, final FieldRotation<T> rInner) {
@@ -1043,6 +1046,7 @@ public class FieldRotation<T extends Ext
      * comp = applyInverseTo(rOuter, rInner).
      * @param rOuter rotation to apply the rotation to
      * @param rInner rotation to apply the rotation to
+     * @param <T> the type of the field elements
      * @return a new rotation which is the composition of r by the inverse
      * of the instance
      */
@@ -1170,6 +1174,7 @@ public class FieldRotation<T extends Ext
      * their components are different (they are exact opposites).</p>
      * @param r1 first rotation
      * @param r2 second rotation
+     * @param <T> the type of the field elements
      * @return <i>distance</i> between r1 and r2
      */
     public static <T extends ExtendedFieldElement<T>> T distance(final FieldRotation<T> r1, final FieldRotation<T> r2) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java?rev=1450096&r1=1450095&r2=1450096&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3D.java Tue Feb 26 09:29:25 2013
@@ -563,28 +563,31 @@ public class FieldVector3D<T extends Ext
 
     }
 
-    /** Compute the angular separation between the instance and another vector.
+    /** Compute the angular separation between two vectors.
      * <p>This method computes the angular separation between two
      * vectors using the dot product for well separated vectors and the
      * cross product for almost aligned vectors. This allows to have a
      * good accuracy in all cases, even for vectors very close to each
      * other.</p>
-     * @param v second vector
-     * @return angular separation between the instance and v
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return angular separation between v1 and v2
      * @exception MathArithmeticException if either vector has a null norm
      */
-    public T angle(FieldVector3D<T> v) throws MathArithmeticException {
+    public static <T extends ExtendedFieldElement<T>> T angle(final FieldVector3D<T> v1, final FieldVector3D<T> v2)
+        throws MathArithmeticException {
 
-        final T normProduct = getNorm().multiply(v.getNorm());
+        final T normProduct = v1.getNorm().multiply(v2.getNorm());
         if (normProduct.getReal() == 0) {
             throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
         }
 
-        final T dot = dotProduct(v);
+        final T dot = dotProduct(v1, v2);
         final double threshold = normProduct.getReal() * 0.9999;
         if ((dot.getReal() < -threshold) || (dot.getReal() > threshold)) {
             // the vectors are almost aligned, compute using the sine
-            FieldVector3D<T> v3 = crossProduct(v);
+            FieldVector3D<T> v3 = crossProduct(v1, v2);
             if (dot.getReal() >= 0) {
                 return v3.getNorm().divide(normProduct).asin();
             }
@@ -596,6 +599,59 @@ public class FieldVector3D<T extends Ext
 
     }
 
+    /** Compute the angular separation between two vectors.
+     * <p>This method computes the angular separation between two
+     * vectors using the dot product for well separated vectors and the
+     * cross product for almost aligned vectors. This allows to have a
+     * good accuracy in all cases, even for vectors very close to each
+     * other.</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return angular separation between v1 and v2
+     * @exception MathArithmeticException if either vector has a null norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T angle(final FieldVector3D<T> v1, final Vector3D v2)
+        throws MathArithmeticException {
+
+        final T normProduct = v1.getNorm().multiply(v2.getNorm());
+        if (normProduct.getReal() == 0) {
+            throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
+        }
+
+        final T dot = dotProduct(v1, v2);
+        final double threshold = normProduct.getReal() * 0.9999;
+        if ((dot.getReal() < -threshold) || (dot.getReal() > threshold)) {
+            // the vectors are almost aligned, compute using the sine
+            FieldVector3D<T> v3 = crossProduct(v1, v2);
+            if (dot.getReal() >= 0) {
+                return v3.getNorm().divide(normProduct).asin();
+            }
+            return v3.getNorm().divide(normProduct).asin().subtract(FastMath.PI).negate();
+        }
+
+        // the vectors are sufficiently separated to use the cosine
+        return dot.divide(normProduct).acos();
+
+    }
+
+    /** Compute the angular separation between two vectors.
+     * <p>This method computes the angular separation between two
+     * vectors using the dot product for well separated vectors and the
+     * cross product for almost aligned vectors. This allows to have a
+     * good accuracy in all cases, even for vectors very close to each
+     * other.</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return angular separation between v1 and v2
+     * @exception MathArithmeticException if either vector has a null norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T angle(final Vector3D v1, final FieldVector3D<T> v2)
+        throws MathArithmeticException {
+        return angle(v2, v1);
+    }
+
     /** Get the opposite of the instance.
      * @return a new vector which is opposite to the instance
      */
@@ -875,6 +931,242 @@ public class FieldVector3D<T extends Ext
         return dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz));
     }
 
+    /** Compute the dot-product of two vectors.
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the dot product v1.v2
+     */
+    public static <T extends ExtendedFieldElement<T>> T dotProduct(final FieldVector3D<T> v1,
+                                                                   final FieldVector3D<T> v2) {
+        return v1.dotProduct(v2);
+    }
+
+    /** Compute the dot-product of two vectors.
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the dot product v1.v2
+     */
+    public static <T extends ExtendedFieldElement<T>> T dotProduct(final FieldVector3D<T> v1,
+                                                                   final Vector3D v2) {
+        return v1.dotProduct(v2);
+    }
+
+    /** Compute the dot-product of two vectors.
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the dot product v1.v2
+     */
+    public static <T extends ExtendedFieldElement<T>> T dotProduct(final Vector3D v1,
+                                                                   final FieldVector3D<T> v2) {
+        return v2.dotProduct(v1);
+    }
+
+    /** Compute the cross-product of two vectors.
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the cross product v1 ^ v2 as a new Vector
+     */
+    public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
+                                                                                    final FieldVector3D<T> v2) {
+        return v1.crossProduct(v2);
+    }
+
+    /** Compute the cross-product of two vectors.
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the cross product v1 ^ v2 as a new Vector
+     */
+    public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
+                                                                                    final Vector3D v2) {
+        return v1.crossProduct(v2);
+    }
+
+    /** Compute the cross-product of two vectors.
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the cross product v1 ^ v2 as a new Vector
+     */
+    public static <T extends ExtendedFieldElement<T>> FieldVector3D<T> crossProduct(final Vector3D v1,
+                                                                                    final FieldVector3D<T> v2) {
+        return new FieldVector3D<T>(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y),
+                                    v2.y.linearCombination(v1.getZ(), v2.x, -v1.getX(), v2.z),
+                                    v2.z.linearCombination(v1.getX(), v2.y, -v1.getY(), v2.x));
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>1</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNorm1()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>1</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distance1(final FieldVector3D<T> v1,
+                                                                  final FieldVector3D<T> v2) {
+        return v1.distance1(v2);
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>1</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNorm1()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>1</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distance1(final FieldVector3D<T> v1,
+                                                                  final Vector3D v2) {
+        return v1.distance1(v2);
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>1</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNorm1()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>1</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distance1(final Vector3D v1,
+                                                                  final FieldVector3D<T> v2) {
+        return v2.distance1(v1);
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>2</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNorm()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>2</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distance(final FieldVector3D<T> v1,
+                                                                 final FieldVector3D<T> v2) {
+        return v1.distance(v2);
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>2</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNorm()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>2</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distance(final FieldVector3D<T> v1,
+                                                                 final Vector3D v2) {
+        return v1.distance(v2);
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>2</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNorm()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>2</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distance(final Vector3D v1,
+                                                                 final FieldVector3D<T> v2) {
+        return v2.distance(v1);
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>&infin;</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNormInf()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>&infin;</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distanceInf(final FieldVector3D<T> v1,
+                                                                    final FieldVector3D<T> v2) {
+        return v1.distanceInf(v2);
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>&infin;</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNormInf()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>&infin;</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distanceInf(final FieldVector3D<T> v1,
+                                                                    final Vector3D v2) {
+        return v1.distanceInf(v2);
+    }
+
+    /** Compute the distance between two vectors according to the L<sub>&infin;</sub> norm.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNormInf()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the distance between v1 and v2 according to the L<sub>&infin;</sub> norm
+     */
+    public static <T extends ExtendedFieldElement<T>> T distanceInf(final Vector3D v1,
+                                                                    final FieldVector3D<T> v2) {
+        return v2.distanceInf(v1);
+    }
+
+    /** Compute the square of the distance between two vectors.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNormSq()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the square of the distance between v1 and v2
+     */
+    public static <T extends ExtendedFieldElement<T>> T distanceSq(final FieldVector3D<T> v1,
+                                                                   final FieldVector3D<T> v2) {
+        return v1.distanceSq(v2);
+    }
+
+    /** Compute the square of the distance between two vectors.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNormSq()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the square of the distance between v1 and v2
+     */
+    public static <T extends ExtendedFieldElement<T>> T distanceSq(final FieldVector3D<T> v1,
+                                                                   final Vector3D v2) {
+        return v1.distanceSq(v2);
+    }
+
+    /** Compute the square of the distance between two vectors.
+     * <p>Calling this method is equivalent to calling:
+     * <code>v1.subtract(v2).getNormSq()</code> except that no intermediate
+     * vector is built</p>
+     * @param v1 first vector
+     * @param v2 second vector
+     * @param <T> the type of the field elements
+     * @return the square of the distance between v1 and v2
+     */
+    public static <T extends ExtendedFieldElement<T>> T distanceSq(final Vector3D v1,
+                                                                   final FieldVector3D<T> v2) {
+        return v2.distanceSq(v1);
+    }
+
     /** Get a string representation of this vector.
      * @return a string representation of this vector
      */

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDSTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDSTest.java?rev=1450096&r1=1450095&r2=1450096&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDSTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDSTest.java Tue Feb 26 09:29:25 2013
@@ -150,7 +150,7 @@ public class FieldRotationDSTest {
         Assert.assertEquals(0, rTr.getQ3().getPartialDerivative(0, 0, 1, 0), 1.0e-15);
         Assert.assertEquals(0, rTr.getQ3().getPartialDerivative(0, 0, 0, 1), 1.0e-15);
         Assert.assertEquals(r.getAngle().getReal(), reverted.getAngle().getReal(), 1.0e-15);
-        Assert.assertEquals(-1, r.getAxis().dotProduct(reverted.getAxis()).getReal(), 1.0e-15);
+        Assert.assertEquals(-1, FieldVector3D.dotProduct(r.getAxis(), reverted.getAxis()).getReal(), 1.0e-15);
     }
 
     @Test
@@ -185,7 +185,7 @@ public class FieldRotationDSTest {
 
         r = new FieldRotation<DerivativeStructure>(u1, u2, u1.negate(), u2.negate());
         FieldVector3D<DerivativeStructure> axis = r.getAxis();
-        if (axis.dotProduct(createVector(0, 0, 1)).getReal() > 0) {
+        if (FieldVector3D.dotProduct(axis, createVector(0, 0, 1)).getReal() > 0) {
             checkVector(axis, createVector(0, 0, 1));
         } else {
             checkVector(axis, createVector(0, 0, -1));
@@ -198,7 +198,7 @@ public class FieldRotationDSTest {
                            createVector(0.5, 0.5, -sqrt));
         checkRotationDS(r, sqrt, 0.5, 0.5, 0);
 
-        r = new FieldRotation<DerivativeStructure>(u1, u2, u1, u1.crossProduct(u2));
+        r = new FieldRotation<DerivativeStructure>(u1, u2, u1, FieldVector3D.crossProduct(u1, u2));
         checkRotationDS(r, sqrt, -sqrt, 0, 0);
 
         checkRotationDS(new FieldRotation<DerivativeStructure>(u1, u2, u1, u2), 1, 0, 0, 0);
@@ -477,6 +477,10 @@ public class FieldRotationDSTest {
         checkRotationDS(r1,
                         -r1.getQ0().getReal(), -r1.getQ1().getReal(),
                         -r1.getQ2().getReal(), -r1.getQ3().getReal());
+        Assert.assertEquals(0.288, r1.toRotation().getQ0(), 1.0e-15);
+        Assert.assertEquals(0.384, r1.toRotation().getQ1(), 1.0e-15);
+        Assert.assertEquals(0.36,  r1.toRotation().getQ2(), 1.0e-15);
+        Assert.assertEquals(0.8,   r1.toRotation().getQ3(), 1.0e-15);
 
     }
 
@@ -781,8 +785,8 @@ public class FieldRotationDSTest {
                     quat.getQ2().getReal() * quat.getQ2().getReal() +
                     quat.getQ3().getReal() * quat.getQ3().getReal();
         Assert.assertEquals(1.0, q2, 1.0e-14);
-        Assert.assertEquals(0.0, v1.angle(quat.applyTo(u1)).getReal(), 1.0e-14);
-        Assert.assertEquals(0.0, v2.angle(quat.applyTo(u2)).getReal(), 1.0e-14);
+        Assert.assertEquals(0.0, FieldVector3D.angle(v1, quat.applyTo(u1)).getReal(), 1.0e-14);
+        Assert.assertEquals(0.0, FieldVector3D.angle(v2, quat.applyTo(u2)).getReal(), 1.0e-14);
 
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java?rev=1450096&r1=1450095&r2=1450096&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldRotationDfpTest.java Tue Feb 26 09:29:25 2013
@@ -96,7 +96,7 @@ 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, r.getAxis().dotProduct(reverted.getAxis()).getReal(), 1.0e-15);
+        Assert.assertEquals(-1, FieldVector3D.dotProduct(r.getAxis(), reverted.getAxis()).getReal(), 1.0e-15);
     }
 
     @Test
@@ -131,7 +131,7 @@ public class FieldRotationDfpTest {
 
         r = new FieldRotation<Dfp>(u1, u2, u1.negate(), u2.negate());
         FieldVector3D<Dfp> axis = r.getAxis();
-        if (axis.dotProduct(createVector(0, 0, 1)).getReal() > 0) {
+        if (FieldVector3D.dotProduct(axis, createVector(0, 0, 1)).getReal() > 0) {
             checkVector(axis, createVector(0, 0, 1));
         } else {
             checkVector(axis, createVector(0, 0, -1));
@@ -144,7 +144,7 @@ public class FieldRotationDfpTest {
                            createVector(0.5, 0.5, -sqrt));
         checkRotationDS(r, sqrt, 0.5, 0.5, 0);
 
-        r = new FieldRotation<Dfp>(u1, u2, u1, u1.crossProduct(u2));
+        r = new FieldRotation<Dfp>(u1, u2, u1, FieldVector3D.crossProduct(u1, u2));
         checkRotationDS(r, sqrt, -sqrt, 0, 0);
 
         checkRotationDS(new FieldRotation<Dfp>(u1, u2, u1, u2), 1, 0, 0, 0);
@@ -658,8 +658,8 @@ public class FieldRotationDfpTest {
                     quat.getQ2().getReal() * quat.getQ2().getReal() +
                     quat.getQ3().getReal() * quat.getQ3().getReal();
         Assert.assertEquals(1.0, q2, 1.0e-14);
-        Assert.assertEquals(0.0, v1.angle(quat.applyTo(u1)).getReal(), 1.0e-14);
-        Assert.assertEquals(0.0, v2.angle(quat.applyTo(u2)).getReal(), 1.0e-14);
+        Assert.assertEquals(0.0, FieldVector3D.angle(v1, quat.applyTo(u1)).getReal(), 1.0e-14);
+        Assert.assertEquals(0.0, FieldVector3D.angle(v2, quat.applyTo(u2)).getReal(), 1.0e-14);
 
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3DTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3DTest.java?rev=1450096&r1=1450095&r2=1450096&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3DTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/threed/FieldVector3DTest.java Tue Feb 26 09:29:25 2013
@@ -261,13 +261,18 @@ public class FieldVector3DTest {
     public void testDistance1() {
         FieldVector3D<DerivativeStructure> v1 = createVector(1, -2, 3, 3);
         FieldVector3D<DerivativeStructure> v2 = createVector(-4, 2, 0, 3);
-        Assert.assertEquals(0.0, createVector(-1, 0, 0, 3).distance1(createVector(-1, 0, 0, 3)).getReal(), 0);
-        DerivativeStructure distance = v1.distance1(v2);
+        Assert.assertEquals(0.0, FieldVector3D.distance1(createVector(-1, 0, 0, 3), createVector(-1, 0, 0, 3)).getReal(), 0);
+        DerivativeStructure distance = FieldVector3D.distance1(v1, v2);
         Assert.assertEquals(12.0, distance.getReal(), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
-        distance = v1.distance1(new Vector3D(-4, 2, 0));
+        distance = FieldVector3D.distance1(v1, new Vector3D(-4, 2, 0));
+        Assert.assertEquals(12.0, distance.getReal(), 1.0e-12);
+        Assert.assertEquals( 1, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
+        Assert.assertEquals(-1, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
+        Assert.assertEquals( 1, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
+        distance = FieldVector3D.distance1(new Vector3D(-4, 2, 0), v1);
         Assert.assertEquals(12.0, distance.getReal(), 1.0e-12);
         Assert.assertEquals( 1, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
         Assert.assertEquals(-1, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
@@ -278,13 +283,18 @@ public class FieldVector3DTest {
     public void testDistance() {
         FieldVector3D<DerivativeStructure> v1 = createVector(1, -2, 3, 3);
         FieldVector3D<DerivativeStructure> v2 = createVector(-4, 2, 0, 3);
-        Assert.assertEquals(0.0, createVector(-1, 0, 0, 3).distance(createVector(-1, 0, 0, 3)).getReal(), 0);
-        DerivativeStructure distance = v1.distance(v2);
+        Assert.assertEquals(0.0, FieldVector3D.distance(createVector(-1, 0, 0, 3), createVector(-1, 0, 0, 3)).getReal(), 0);
+        DerivativeStructure distance = FieldVector3D.distance(v1, v2);
         Assert.assertEquals(FastMath.sqrt(50), distance.getReal(), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
-        distance = v1.distance(new Vector3D(-4, 2, 0));
+        distance = FieldVector3D.distance(v1, new Vector3D(-4, 2, 0));
+        Assert.assertEquals(FastMath.sqrt(50), distance.getReal(), 1.0e-12);
+        Assert.assertEquals( 5 / FastMath.sqrt(50), distance.getPartialDerivative(1, 0, 0), 1.0e-12);
+        Assert.assertEquals(-4 / FastMath.sqrt(50), distance.getPartialDerivative(0, 1, 0), 1.0e-12);
+        Assert.assertEquals( 3 / FastMath.sqrt(50), distance.getPartialDerivative(0, 0, 1), 1.0e-12);
+        distance = FieldVector3D.distance(new Vector3D(-4, 2, 0), v1);
         Assert.assertEquals(FastMath.sqrt(50), distance.getReal(), 1.0e-12);
         Assert.assertEquals( 5 / FastMath.sqrt(50), distance.getPartialDerivative(1, 0, 0), 1.0e-12);
         Assert.assertEquals(-4 / FastMath.sqrt(50), distance.getPartialDerivative(0, 1, 0), 1.0e-12);
@@ -295,13 +305,18 @@ public class FieldVector3DTest {
     public void testDistanceSq() {
         FieldVector3D<DerivativeStructure> v1 = createVector(1, -2, 3, 3);
         FieldVector3D<DerivativeStructure> v2 = createVector(-4, 2, 0, 3);
-        Assert.assertEquals(0.0, createVector(-1, 0, 0, 3).distanceSq(createVector(-1, 0, 0, 3)).getReal(), 0);
-        DerivativeStructure distanceSq = v1.distanceSq(v2);
+        Assert.assertEquals(0.0, FieldVector3D.distanceSq(createVector(-1, 0, 0, 3), createVector(-1, 0, 0, 3)).getReal(), 0);
+        DerivativeStructure distanceSq = FieldVector3D.distanceSq(v1, v2);
         Assert.assertEquals(50.0, distanceSq.getReal(), 1.0e-12);
         Assert.assertEquals(0, distanceSq.getPartialDerivative(1, 0, 0), 1.0e-12);
         Assert.assertEquals(0, distanceSq.getPartialDerivative(0, 1, 0), 1.0e-12);
         Assert.assertEquals(0, distanceSq.getPartialDerivative(0, 0, 1), 1.0e-12);
-        distanceSq = v1.distanceSq(new Vector3D(-4, 2, 0));
+        distanceSq = FieldVector3D.distanceSq(v1, new Vector3D(-4, 2, 0));
+        Assert.assertEquals(50.0, distanceSq.getReal(), 1.0e-12);
+        Assert.assertEquals(10, distanceSq.getPartialDerivative(1, 0, 0), 1.0e-12);
+        Assert.assertEquals(-8, distanceSq.getPartialDerivative(0, 1, 0), 1.0e-12);
+        Assert.assertEquals( 6, distanceSq.getPartialDerivative(0, 0, 1), 1.0e-12);
+        distanceSq = FieldVector3D.distanceSq(new Vector3D(-4, 2, 0), v1);
         Assert.assertEquals(50.0, distanceSq.getReal(), 1.0e-12);
         Assert.assertEquals(10, distanceSq.getPartialDerivative(1, 0, 0), 1.0e-12);
         Assert.assertEquals(-8, distanceSq.getPartialDerivative(0, 1, 0), 1.0e-12);
@@ -312,55 +327,60 @@ public class FieldVector3DTest {
     public void testDistanceInf() {
         FieldVector3D<DerivativeStructure> v1 = createVector(1, -2, 3, 3);
         FieldVector3D<DerivativeStructure> v2 = createVector(-4, 2, 0, 3);
-        Assert.assertEquals(0.0, createVector(-1, 0, 0, 3).distanceInf(createVector(-1, 0, 0, 3)).getReal(), 0);
-        DerivativeStructure distance = v1.distanceInf(v2);
+        Assert.assertEquals(0.0, FieldVector3D.distanceInf(createVector(-1, 0, 0, 3), createVector(-1, 0, 0, 3)).getReal(), 0);
+        DerivativeStructure distance = FieldVector3D.distanceInf(v1, v2);
         Assert.assertEquals(5.0, distance.getReal(), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
-        distance = v1.distanceInf(new Vector3D(-4, 2, 0));
+        distance = FieldVector3D.distanceInf(v1, new Vector3D(-4, 2, 0));
         Assert.assertEquals(5.0, distance.getReal(), 1.0e-12);
         Assert.assertEquals(1, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
         Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
-        Assert.assertEquals(v1.subtract(v2).getNormInf().getReal(), v1.distanceInf(v2).getReal(), 1.0e-12);
+        distance = FieldVector3D.distanceInf(new Vector3D(-4, 2, 0), v1);
+        Assert.assertEquals(5.0, distance.getReal(), 1.0e-12);
+        Assert.assertEquals(1, distance.getPartialDerivative(1, 0, 0), 1.0e-12);
+        Assert.assertEquals(0, distance.getPartialDerivative(0, 1, 0), 1.0e-12);
+        Assert.assertEquals(0, distance.getPartialDerivative(0, 0, 1), 1.0e-12);
+        Assert.assertEquals(v1.subtract(v2).getNormInf().getReal(), FieldVector3D.distanceInf(v1, v2).getReal(), 1.0e-12);
 
         Assert.assertEquals(5.0,
-                            createVector( 1, -2, 3, 3).distanceInf(createVector(-4,  2, 0, 3)).getReal(),
+                            FieldVector3D.distanceInf(createVector( 1, -2, 3, 3), createVector(-4,  2, 0, 3)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector( 1, 3, -2, 3).distanceInf(createVector(-4, 0,  2, 3)).getReal(),
+                            FieldVector3D.distanceInf(createVector( 1, 3, -2, 3), createVector(-4, 0,  2, 3)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector(-2,  1, 3, 3).distanceInf(createVector( 2, -4, 0, 3)).getReal(),
+                            FieldVector3D.distanceInf(createVector(-2,  1, 3, 3), createVector( 2, -4, 0, 3)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector(-2, 3,  1, 3).distanceInf(createVector( 2, 0, -4, 3)).getReal(),
+                            FieldVector3D.distanceInf(createVector(-2, 3,  1, 3), createVector( 2, 0, -4, 3)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector(3, -2,  1, 3).distanceInf(createVector(0,  2, -4, 3)).getReal(),
+                            FieldVector3D.distanceInf(createVector(3, -2,  1, 3), createVector(0,  2, -4, 3)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector(3,  1, -2, 3).distanceInf(createVector(0, -4,  2, 3)).getReal(),
+                            FieldVector3D.distanceInf(createVector(3,  1, -2, 3), createVector(0, -4,  2, 3)).getReal(),
                             1.0e-12);
 
         Assert.assertEquals(5.0,
-                            createVector( 1, -2, 3, 3).distanceInf(new Vector3D(-4,  2, 0)).getReal(),
+                            FieldVector3D.distanceInf(createVector( 1, -2, 3, 3), new Vector3D(-4,  2, 0)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector( 1, 3, -2, 3).distanceInf(new Vector3D(-4, 0,  2)).getReal(),
+                            FieldVector3D.distanceInf(createVector( 1, 3, -2, 3), new Vector3D(-4, 0,  2)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector(-2,  1, 3, 3).distanceInf(new Vector3D( 2, -4, 0)).getReal(),
+                            FieldVector3D.distanceInf(createVector(-2,  1, 3, 3), new Vector3D( 2, -4, 0)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector(-2, 3,  1, 3).distanceInf(new Vector3D( 2, 0, -4)).getReal(),
+                            FieldVector3D.distanceInf(createVector(-2, 3,  1, 3), new Vector3D( 2, 0, -4)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector(3, -2,  1, 3).distanceInf(new Vector3D(0,  2, -4)).getReal(),
+                            FieldVector3D.distanceInf(createVector(3, -2,  1, 3), new Vector3D(0,  2, -4)).getReal(),
                             1.0e-12);
         Assert.assertEquals(5.0,
-                            createVector(3,  1, -2, 3).distanceInf(new Vector3D(0, -4,  2)).getReal(),
+                            FieldVector3D.distanceInf(createVector(3,  1, -2, 3), new Vector3D(0, -4,  2)).getReal(),
                             1.0e-12);
 
     }
@@ -425,25 +445,37 @@ public class FieldVector3DTest {
         FieldVector3D<DerivativeStructure> v1 = createVector(2, 1, -4, 3);
         FieldVector3D<DerivativeStructure> v2 = createVector(3, 1, -1, 3);
 
-        Assert.assertTrue(FastMath.abs(v1.dotProduct(v2).getReal() - 11) < 1.0e-12);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v1, v2).getReal() - 11) < 1.0e-12);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v1, v2.toVector3D()).getReal() - 11) < 1.0e-12);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v1.toVector3D(), v2).getReal() - 11) < 1.0e-12);
+
+        FieldVector3D<DerivativeStructure> v3 = FieldVector3D.crossProduct(v1, v2);
+        checkVector(v3, 3, -10, -1);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v1, v3).getReal()) < 1.0e-12);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v2, v3).getReal()) < 1.0e-12);
 
-        FieldVector3D<DerivativeStructure> v3 = v1.crossProduct(v2);
+        v3 = FieldVector3D.crossProduct(v1, v2.toVector3D());
         checkVector(v3, 3, -10, -1);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v1, v3).getReal()) < 1.0e-12);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v2, v3).getReal()) < 1.0e-12);
+
+        v3 = FieldVector3D.crossProduct(v1.toVector3D(), v2);
+        checkVector(v3, 3, -10, -1);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v1, v3).getReal()) < 1.0e-12);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.dotProduct(v2, v3).getReal()) < 1.0e-12);
 
-        Assert.assertTrue(FastMath.abs(v1.dotProduct(v3).getReal()) < 1.0e-12);
-        Assert.assertTrue(FastMath.abs(v2.dotProduct(v3).getReal()) < 1.0e-12);
     }
 
     @Test
     public void testCrossProductCancellation() {
         FieldVector3D<DerivativeStructure> v1 = createVector(9070467121.0, 4535233560.0, 1, 3);
         FieldVector3D<DerivativeStructure> v2 = createVector(9070467123.0, 4535233561.0, 1, 3);
-        checkVector(v1.crossProduct(v2), -1, 2, 1);
+        checkVector(FieldVector3D.crossProduct(v1, v2), -1, 2, 1);
 
         double scale    = FastMath.scalb(1.0, 100);
         FieldVector3D<DerivativeStructure> big1   = new FieldVector3D<DerivativeStructure>(scale, v1);
         FieldVector3D<DerivativeStructure> small2 = new FieldVector3D<DerivativeStructure>(1 / scale, v2);
-        checkVector(big1.crossProduct(small2), -1, 2, 1);
+        checkVector(FieldVector3D.crossProduct(big1, small2), -1, 2, 1);
 
     }
 
@@ -468,8 +500,20 @@ public class FieldVector3DTest {
         FieldVector3D<DerivativeStructure>  i = k.orthogonal();
         FieldVector3D<DerivativeStructure> v2 = k.scalarMultiply(FastMath.cos(1.2)).add(i.scalarMultiply(FastMath.sin(1.2)));
 
-        Assert.assertTrue(FastMath.abs(v1.angle(v2).getReal() - 1.2) < 1.0e-12);
-  }
+        Assert.assertTrue(FastMath.abs(FieldVector3D.angle(v1, v2).getReal() - 1.2) < 1.0e-12);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.angle(v1, v2.toVector3D()).getReal() - 1.2) < 1.0e-12);
+        Assert.assertTrue(FastMath.abs(FieldVector3D.angle(v1.toVector3D(), v2).getReal() - 1.2) < 1.0e-12);
+
+        try {
+            FieldVector3D.angle(v1, Vector3D.ZERO);
+            Assert.fail("an exception should have been thrown");
+        } catch (MathArithmeticException mae) {
+            // expected
+        }
+        Assert.assertEquals(0.0, FieldVector3D.angle(v1, v1.toVector3D()).getReal(), 1.0e-15);
+        Assert.assertEquals(FastMath.PI, FieldVector3D.angle(v1, v1.negate().toVector3D()).getReal(), 1.0e-15);
+
+    }
 
     @Test
     public void testNormalize() throws MathArithmeticException {
@@ -491,13 +535,13 @@ public class FieldVector3DTest {
     @Test
     public void testOrthogonal() throws MathArithmeticException {
         FieldVector3D<DerivativeStructure> v1 = createVector(0.1, 2.5, 1.3, 3);
-        Assert.assertEquals(0.0, v1.dotProduct(v1.orthogonal()).getReal(), 1.0e-12);
+        Assert.assertEquals(0.0, FieldVector3D.dotProduct(v1, v1.orthogonal()).getReal(), 1.0e-12);
         FieldVector3D<DerivativeStructure> v2 = createVector(2.3, -0.003, 7.6, 3);
-        Assert.assertEquals(0.0, v2.dotProduct(v2.orthogonal()).getReal(), 1.0e-12);
+        Assert.assertEquals(0.0, FieldVector3D.dotProduct(v2, v2.orthogonal()).getReal(), 1.0e-12);
         FieldVector3D<DerivativeStructure> v3 = createVector(-1.7, 1.4, 0.2, 3);
-        Assert.assertEquals(0.0, v3.dotProduct(v3.orthogonal()).getReal(), 1.0e-12);
+        Assert.assertEquals(0.0, FieldVector3D.dotProduct(v3, v3.orthogonal()).getReal(), 1.0e-12);
         FieldVector3D<DerivativeStructure> v4 = createVector(4.2, 0.1, -1.8, 3);
-        Assert.assertEquals(0.0, v4.dotProduct(v4.orthogonal()).getReal(), 1.0e-12);
+        Assert.assertEquals(0.0, FieldVector3D.dotProduct(v4, v4.orthogonal()).getReal(), 1.0e-12);
         try {
             createVector(0, 0, 0, 3).orthogonal();
             Assert.fail("an exception should have been thrown");
@@ -509,16 +553,16 @@ public class FieldVector3DTest {
     @Test
     public void testAngle() throws MathArithmeticException {
         Assert.assertEquals(0.22572612855273393616,
-                            createVector(1, 2, 3, 3).angle(createVector(4, 5, 6, 3)).getReal(),
+                            FieldVector3D.angle(createVector(1, 2, 3, 3), createVector(4, 5, 6, 3)).getReal(),
                             1.0e-12);
         Assert.assertEquals(7.98595620686106654517199e-8,
-                            createVector(1, 2, 3, 3).angle(createVector(2, 4, 6.000001, 3)).getReal(),
+                            FieldVector3D.angle(createVector(1, 2, 3, 3), createVector(2, 4, 6.000001, 3)).getReal(),
                             1.0e-12);
         Assert.assertEquals(3.14159257373023116985197793156,
-                            createVector(1, 2, 3, 3).angle(createVector(-2, -4, -6.000001, 3)).getReal(),
+                            FieldVector3D.angle(createVector(1, 2, 3, 3), createVector(-2, -4, -6.000001, 3)).getReal(),
                             1.0e-12);
         try {
-            createVector(0, 0, 0, 3).angle(createVector(1, 0, 0, 3));
+            FieldVector3D.angle(createVector(0, 0, 0, 3), createVector(1, 0, 0, 3));
             Assert.fail("an exception should have been thrown");
         } catch (MathArithmeticException ae) {
             // expected behavior
@@ -537,7 +581,7 @@ public class FieldVector3DTest {
                                    -4550117129121957.0 /    2097152.0,
                                     8846951984510141.0 /     131072.0, 3);
         DerivativeStructure sNaive = u1.getX().multiply(u2.getX()).add(u1.getY().multiply(u2.getY())).add(u1.getZ().multiply(u2.getZ()));
-        DerivativeStructure sAccurate = u1.dotProduct(u2);
+        DerivativeStructure sAccurate = FieldVector3D.dotProduct(u1, u2);
         Assert.assertEquals(0.0, sNaive.getReal(), 1.0e-30);
         Assert.assertEquals(-2088690039198397.0 / 1125899906842624.0, sAccurate.getReal(), 1.0e-16);
     }
@@ -560,13 +604,13 @@ public class FieldVector3DTest {
             FieldVector3D<DerivativeStructure> vds = createVector(vx, vy, vz, 3);
             Vector3D v = new Vector3D(vx, vy, vz);
 
-            DerivativeStructure sAccurate = uds.dotProduct(vds);
+            DerivativeStructure sAccurate = FieldVector3D.dotProduct(uds, vds);
             Assert.assertEquals(sNaive, sAccurate.getReal(), 2.5e-16 * sNaive);
             Assert.assertEquals(ux + vx, sAccurate.getPartialDerivative(1, 0, 0), 2.5e-16 * sNaive);
             Assert.assertEquals(uy + vy, sAccurate.getPartialDerivative(0, 1, 0), 2.5e-16 * sNaive);
             Assert.assertEquals(uz + vz, sAccurate.getPartialDerivative(0, 0, 1), 2.5e-16 * sNaive);
 
-            sAccurate = uds.dotProduct(v);
+            sAccurate = FieldVector3D.dotProduct(uds, v);
             Assert.assertEquals(sNaive, sAccurate.getReal(), 2.5e-16 * sNaive);
             Assert.assertEquals(vx, sAccurate.getPartialDerivative(1, 0, 0), 2.5e-16 * sNaive);
             Assert.assertEquals(vy, sAccurate.getPartialDerivative(0, 1, 0), 2.5e-16 * sNaive);
@@ -594,9 +638,9 @@ public class FieldVector3DTest {
         FieldVector3D<DerivativeStructure> cNaive = new FieldVector3D<DerivativeStructure>(u1.getY().multiply(u2.getZ()).subtract(u1.getZ().multiply(u2.getY())),
                                        u1.getZ().multiply(u2.getX()).subtract(u1.getX().multiply(u2.getZ())),
                                        u1.getX().multiply(u2.getY()).subtract(u1.getY().multiply(u2.getX())));
-        FieldVector3D<DerivativeStructure> cAccurate = u1.crossProduct(u2);
-        Assert.assertTrue(u3.distance(cNaive).getReal() > 2.9 * u3.getNorm().getReal());
-        Assert.assertEquals(0.0, u3.distance(cAccurate).getReal(), 1.0e-30 * cAccurate.getNorm().getReal());
+        FieldVector3D<DerivativeStructure> cAccurate = FieldVector3D.crossProduct(u1, u2);
+        Assert.assertTrue(FieldVector3D.distance(u3, cNaive).getReal() > 2.9 * u3.getNorm().getReal());
+        Assert.assertEquals(0.0, FieldVector3D.distance(u3, cAccurate).getReal(), 1.0e-30 * cAccurate.getNorm().getReal());
     }
 
     @Test
@@ -617,13 +661,13 @@ public class FieldVector3DTest {
             FieldVector3D<DerivativeStructure> vds = createVector(vx, vy, vz, 3);
             Vector3D v = new Vector3D(vx, vy, vz);
 
-            checkVector(uds.crossProduct(vds),
+            checkVector(FieldVector3D.crossProduct(uds, vds),
                         cNaive.getX(), cNaive.getY(), cNaive.getZ(),
                         0, vz - uz, uy - vy,
                         uz - vz, 0, vx - ux,
                         vy - uy, ux - vx, 0);
 
-            checkVector(uds.crossProduct(v),
+            checkVector(FieldVector3D.crossProduct(uds, v),
                         cNaive.getX(), cNaive.getY(), cNaive.getZ(),
                           0,  vz, -vy,
                         -vz,   0,  vx,