Line3 extends Line3Base implements ReadOnlyLine3, Poolable { @Override public double distanceSquared(final ReadOnlyVector3 point, final Vector3 store) { final Vector3 vectorA = Vector3.fetchTempInstance(); vectorA.set(point).subtractLocal(_origin); final double t0 = _direction.dot(vectorA); vectorA.set(_direction).multiplyLocal(t0); vectorA.addLocal(_origin); if (store != null) { store.set(vectorA); } point.subtract(vectorA, vectorA); final double lSQ = vectorA.lengthSquared(); Vector3.releaseTempInstance(vectorA); return lSQ; } Line3();  Line3(final ReadOnlyVector3 origin, final ReadOnlyVector3 direction);  Line3(final ReadOnlyLine3 source); Line3 set(final ReadOnlyLine3 source); @Override double distanceSquared(final ReadOnlyVector3 point, final Vector3 store); static boolean isValid(final ReadOnlyLine3 line); @Override String toString(); @Override boolean equals(final Object o); @Override Line3 clone(); final static Line3 fetchTempInstance(); final static void releaseTempInstance(final Line3 line);  }
@Test public void testDistance() { final Line3 line1 = new Line3(Vector3.ZERO, Vector3.UNIT_Z); final Vector3 store = new Vector3(); assertTrue(0.0 == line1.distanceSquared(new Vector3(0, 0, 5), store)); assertTrue(16.0 == line1.distanceSquared(new Vector3(0, 4, 1), store)); assertEquals(Vector3.UNIT_Z, store); assertTrue(9.0 == line1.distanceSquared(new Vector3(0, -3, -1), store)); assertEquals(Vector3.NEG_UNIT_Z, store); assertTrue(1.0 == line1.distanceSquared(Vector3.NEG_UNIT_X, null)); }