FieldVector3D implements Serializable { public static <T extends RealFieldElement<T>> T angle(final FieldVector3D<T> v1, final FieldVector3D<T> 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)) { 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(); } return dot.divide(normProduct).acos(); } FieldVector3D(final T x, final T y, final T z);  FieldVector3D(final T[] v);  FieldVector3D(final T alpha, final T delta);  FieldVector3D(final T a, final FieldVector3D<T>u);  FieldVector3D(final T a, final Vector3D u);  FieldVector3D(final double a, final FieldVector3D<T> u);  FieldVector3D(final T a1, final FieldVector3D<T> u1,
                         final T a2, final FieldVector3D<T> u2);  FieldVector3D(final T a1, final Vector3D u1,
                         final T a2, final Vector3D u2);  FieldVector3D(final double a1, final FieldVector3D<T> u1,
                         final double a2, final FieldVector3D<T> u2);  FieldVector3D(final T a1, final FieldVector3D<T> u1,
                         final T a2, final FieldVector3D<T> u2,
                         final T a3, final FieldVector3D<T> u3);  FieldVector3D(final T a1, final Vector3D u1,
                         final T a2, final Vector3D u2,
                         final T a3, final Vector3D u3);  FieldVector3D(final double a1, final FieldVector3D<T> u1,
                         final double a2, final FieldVector3D<T> u2,
                         final double a3, final FieldVector3D<T> u3);  FieldVector3D(final T a1, final FieldVector3D<T> u1,
                         final T a2, final FieldVector3D<T> u2,
                         final T a3, final FieldVector3D<T> u3,
                         final T a4, final FieldVector3D<T> u4);  FieldVector3D(final T a1, final Vector3D u1,
                         final T a2, final Vector3D u2,
                         final T a3, final Vector3D u3,
                         final T a4, final Vector3D u4);  FieldVector3D(final double a1, final FieldVector3D<T> u1,
                         final double a2, final FieldVector3D<T> u2,
                         final double a3, final FieldVector3D<T> u3,
                         final double a4, final FieldVector3D<T> u4); T getX(); T getY(); T getZ(); T[] toArray(); Vector3D toVector3D(); T getNorm1(); T getNorm(); T getNormSq(); T getNormInf(); T getAlpha(); T getDelta(); FieldVector3D<T> add(final FieldVector3D<T> v); FieldVector3D<T> add(final Vector3D v); FieldVector3D<T> add(final T factor, final FieldVector3D<T> v); FieldVector3D<T> add(final T factor, final Vector3D v); FieldVector3D<T> add(final double factor, final FieldVector3D<T> v); FieldVector3D<T> add(final double factor, final Vector3D v); FieldVector3D<T> subtract(final FieldVector3D<T> v); FieldVector3D<T> subtract(final Vector3D v); FieldVector3D<T> subtract(final T factor, final FieldVector3D<T> v); FieldVector3D<T> subtract(final T factor, final Vector3D v); FieldVector3D<T> subtract(final double factor, final FieldVector3D<T> v); FieldVector3D<T> subtract(final double factor, final Vector3D v); FieldVector3D<T> normalize(); FieldVector3D<T> orthogonal(); static T angle(final FieldVector3D<T> v1, final FieldVector3D<T> v2); static T angle(final FieldVector3D<T> v1, final Vector3D v2); static T angle(final Vector3D v1, final FieldVector3D<T> v2); FieldVector3D<T> negate(); FieldVector3D<T> scalarMultiply(final T a); FieldVector3D<T> scalarMultiply(final double a); boolean isNaN(); boolean isInfinite(); @Override boolean equals(Object other); @Override int hashCode(); T dotProduct(final FieldVector3D<T> v); T dotProduct(final Vector3D v); FieldVector3D<T> crossProduct(final FieldVector3D<T> v); FieldVector3D<T> crossProduct(final Vector3D v); T distance1(final FieldVector3D<T> v); T distance1(final Vector3D v); T distance(final FieldVector3D<T> v); T distance(final Vector3D v); T distanceInf(final FieldVector3D<T> v); T distanceInf(final Vector3D v); T distanceSq(final FieldVector3D<T> v); T distanceSq(final Vector3D v); static T dotProduct(final FieldVector3D<T> v1,
                                                                   final FieldVector3D<T> v2); static T dotProduct(final FieldVector3D<T> v1,
                                                                   final Vector3D v2); static T dotProduct(final Vector3D v1,
                                                                   final FieldVector3D<T> v2); static FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
                                                                                    final FieldVector3D<T> v2); static FieldVector3D<T> crossProduct(final FieldVector3D<T> v1,
                                                                                    final Vector3D v2); static FieldVector3D<T> crossProduct(final Vector3D v1,
                                                                                    final FieldVector3D<T> v2); static T distance1(final FieldVector3D<T> v1,
                                                                  final FieldVector3D<T> v2); static T distance1(final FieldVector3D<T> v1,
                                                                  final Vector3D v2); static T distance1(final Vector3D v1,
                                                                  final FieldVector3D<T> v2); static T distance(final FieldVector3D<T> v1,
                                                                 final FieldVector3D<T> v2); static T distance(final FieldVector3D<T> v1,
                                                                 final Vector3D v2); static T distance(final Vector3D v1,
                                                                 final FieldVector3D<T> v2); static T distanceInf(final FieldVector3D<T> v1,
                                                                    final FieldVector3D<T> v2); static T distanceInf(final FieldVector3D<T> v1,
                                                                    final Vector3D v2); static T distanceInf(final Vector3D v1,
                                                                    final FieldVector3D<T> v2); static T distanceSq(final FieldVector3D<T> v1,
                                                                   final FieldVector3D<T> v2); static T distanceSq(final FieldVector3D<T> v1,
                                                                   final Vector3D v2); static T distanceSq(final Vector3D v1,
                                                                   final FieldVector3D<T> v2); @Override String toString(); String toString(final NumberFormat format);  }
@Test public void testAngle() throws MathArithmeticException { Assert.assertEquals(0.22572612855273393616, FieldVector3D.angle(createVector(1, 2, 3, 3), createVector(4, 5, 6, 3)).getReal(), 1.0e-12); Assert.assertEquals(7.98595620686106654517199e-8, FieldVector3D.angle(createVector(1, 2, 3, 3), createVector(2, 4, 6.000001, 3)).getReal(), 1.0e-12); Assert.assertEquals(3.14159257373023116985197793156, FieldVector3D.angle(createVector(1, 2, 3, 3), createVector(-2, -4, -6.000001, 3)).getReal(), 1.0e-12); try { FieldVector3D.angle(createVector(0, 0, 0, 3), createVector(1, 0, 0, 3)); Assert.fail("an exception should have been thrown"); } catch (MathArithmeticException ae) { } }