Line implements Embedding<Euclidean3D, Euclidean1D> { public Vector3D intersection(final Line line) { final Vector3D closest = closestPoint(line); return line.contains(closest) ? closest : null; } Line(final Vector3D p1, final Vector3D p2, final double tolerance);  Line(final Line line); @Deprecated  Line(final Vector3D p1, final Vector3D p2); void reset(final Vector3D p1, final Vector3D p2); double getTolerance(); Line revert(); Vector3D getDirection(); Vector3D getOrigin(); double getAbscissa(final Vector3D point); Vector3D pointAt(final double abscissa); Vector1D toSubSpace(Vector<Euclidean3D> vector); Vector3D toSpace(Vector<Euclidean1D> vector); Vector1D toSubSpace(final Point<Euclidean3D> point); Vector3D toSpace(final Point<Euclidean1D> point); boolean isSimilarTo(final Line line); boolean contains(final Vector3D p); double distance(final Vector3D p); double distance(final Line line); Vector3D closestPoint(final Line line); Vector3D intersection(final Line line); SubLine wholeLine();  }
@Test public void testIntersection() throws MathIllegalArgumentException { Line l = new Line(new Vector3D(0, 1, 1), new Vector3D(0, 2, 2), 1.0e-10); Assert.assertNull(l.intersection(new Line(new Vector3D(1, 0, 1), new Vector3D(1, 0, 2), 1.0e-10))); Assert.assertNull(l.intersection(new Line(new Vector3D(-0.5, 0, 0), new Vector3D(-0.5, -1, -1), 1.0e-10))); Assert.assertEquals(0.0, l.intersection(l).distance(new Vector3D(0, 0, 0)), 1.0e-10); Assert.assertEquals(0.0, l.intersection(new Line(new Vector3D(0, -4, -4), new Vector3D(0, -5, -5), 1.0e-10)).distance(new Vector3D(0, 0, 0)), 1.0e-10); Assert.assertEquals(0.0, l.intersection(new Line(new Vector3D(0, -4, -4), new Vector3D(0, -3, -4), 1.0e-10)).distance(new Vector3D(0, -4, -4)), 1.0e-10); Assert.assertEquals(0.0, l.intersection(new Line(new Vector3D(0, -4, -4), new Vector3D(1, -4, -4), 1.0e-10)).distance(new Vector3D(0, -4, -4)), 1.0e-10); Assert.assertNull(l.intersection(new Line(new Vector3D(0, -4, 0), new Vector3D(1, -4, 0), 1.0e-10))); }