Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Euclidean2D> { public Vector3D intersection(final Line line) { final Vector3D direction = line.getDirection(); final double dot = w.dotProduct(direction); if (FastMath.abs(dot) < 1.0e-10) { return null; } final Vector3D point = line.toSpace((Point<Euclidean1D>) Vector1D.ZERO); final double k = -(originOffset + w.dotProduct(point)) / dot; return new Vector3D(1.0, point, k, direction); } Plane(final Vector3D normal, final double tolerance);  Plane(final Vector3D p, final Vector3D normal, final double tolerance);  Plane(final Vector3D p1, final Vector3D p2, final Vector3D p3, final double tolerance); @Deprecated  Plane(final Vector3D normal); @Deprecated  Plane(final Vector3D p, final Vector3D normal); @Deprecated  Plane(final Vector3D p1, final Vector3D p2, final Vector3D p3);  Plane(final Plane plane); Plane copySelf(); void reset(final Vector3D p, final Vector3D normal); void reset(final Plane original); Vector3D getOrigin(); Vector3D getNormal(); Vector3D getU(); Vector3D getV(); Point<Euclidean3D> project(Point<Euclidean3D> point); double getTolerance(); void revertSelf(); Vector2D toSubSpace(Vector<Euclidean3D> vector); Vector3D toSpace(Vector<Euclidean2D> vector); Vector2D toSubSpace(final Point<Euclidean3D> point); Vector3D toSpace(final Point<Euclidean2D> point); Vector3D getPointAt(final Vector2D inPlane, final double offset); boolean isSimilarTo(final Plane plane); Plane rotate(final Vector3D center, final Rotation rotation); Plane translate(final Vector3D translation); Vector3D intersection(final Line line); Line intersection(final Plane other); static Vector3D intersection(final Plane plane1, final Plane plane2, final Plane plane3); SubPlane wholeHyperplane(); PolyhedronsSet wholeSpace(); boolean contains(final Vector3D p); double getOffset(final Plane plane); double getOffset(Vector<Euclidean3D> vector); double getOffset(final Point<Euclidean3D> point); boolean sameOrientationAs(final Hyperplane<Euclidean3D> other);  }
@Test public void testIntersection() throws MathArithmeticException, MathIllegalArgumentException { Plane p = new Plane(new Vector3D(1, 2, 3), new Vector3D(-4, 1, -5), 1.0e-10); Line l = new Line(new Vector3D(0.2, -3.5, 0.7), new Vector3D(1.2, -2.5, -0.3), 1.0e-10); Vector3D point = p.intersection(l); Assert.assertTrue(p.contains(point)); Assert.assertTrue(l.contains(point)); Assert.assertNull(p.intersection(new Line(new Vector3D(10, 10, 10), new Vector3D(10, 10, 10).add(p.getNormal().orthogonal()), 1.0e-10))); }
@Test public void testIntersection3() throws MathArithmeticException { Vector3D reference = new Vector3D (1.2, 3.4, -5.8); Plane p1 = new Plane(reference, new Vector3D(1, 3, 3), 1.0e-10); Plane p2 = new Plane(reference, new Vector3D(-2, 4, 0), 1.0e-10); Plane p3 = new Plane(reference, new Vector3D(7, 0, -4), 1.0e-10); Vector3D p = Plane.intersection(p1, p2, p3); Assert.assertEquals(reference.getX(), p.getX(), 1.0e-10); Assert.assertEquals(reference.getY(), p.getY(), 1.0e-10); Assert.assertEquals(reference.getZ(), p.getZ(), 1.0e-10); }