Vector3D implements Serializable, Vector<Euclidean3D> { public double distance(Vector<Euclidean3D> v) { return distance((Point<Euclidean3D>) v); } Vector3D(double x, double y, double z);  Vector3D(double[] v);  Vector3D(double alpha, double delta);  Vector3D(double a, Vector3D u);  Vector3D(double a1, Vector3D u1, double a2, Vector3D u2);  Vector3D(double a1, Vector3D u1, double a2, Vector3D u2,
                    double a3, Vector3D u3);  Vector3D(double a1, Vector3D u1, double a2, Vector3D u2,
                    double a3, Vector3D u3, double a4, Vector3D u4); double getX(); double getY(); double getZ(); double[] toArray(); Space getSpace(); Vector3D getZero(); double getNorm1(); double getNorm(); double getNormSq(); double getNormInf(); double getAlpha(); double getDelta(); Vector3D add(final Vector<Euclidean3D> v); Vector3D add(double factor, final Vector<Euclidean3D> v); Vector3D subtract(final Vector<Euclidean3D> v); Vector3D subtract(final double factor, final Vector<Euclidean3D> v); Vector3D normalize(); Vector3D orthogonal(); static double angle(Vector3D v1, Vector3D v2); Vector3D negate(); Vector3D scalarMultiply(double a); boolean isNaN(); boolean isInfinite(); @Override boolean equals(Object other); @Override int hashCode(); double dotProduct(final Vector<Euclidean3D> v); Vector3D crossProduct(final Vector<Euclidean3D> v); double distance1(Vector<Euclidean3D> v); double distance(Vector<Euclidean3D> v); double distance(Point<Euclidean3D> v); double distanceInf(Vector<Euclidean3D> v); double distanceSq(Vector<Euclidean3D> v); static double dotProduct(Vector3D v1, Vector3D v2); static Vector3D crossProduct(final Vector3D v1, final Vector3D v2); static double distance1(Vector3D v1, Vector3D v2); static double distance(Vector3D v1, Vector3D v2); static double distanceInf(Vector3D v1, Vector3D v2); static double distanceSq(Vector3D v1, Vector3D v2); @Override String toString(); String toString(final NumberFormat format); static final Vector3D ZERO; static final Vector3D PLUS_I; static final Vector3D MINUS_I; static final Vector3D PLUS_J; static final Vector3D MINUS_J; static final Vector3D PLUS_K; static final Vector3D MINUS_K; static final Vector3D NaN; static final Vector3D POSITIVE_INFINITY; static final Vector3D NEGATIVE_INFINITY; }
@Test public void testDistance() { Vector3D v1 = new Vector3D(1, -2, 3); Vector3D v2 = new Vector3D(-4, 2, 0); Assert.assertEquals(0.0, Vector3D.distance(Vector3D.MINUS_I, Vector3D.MINUS_I), 0); Assert.assertEquals(FastMath.sqrt(50), Vector3D.distance(v1, v2), 1.0e-12); Assert.assertEquals(v1.subtract(v2).getNorm(), Vector3D.distance(v1, v2), 1.0e-12); }