Plane { public boolean intersectsSegment(Vec3 endPoint1, Vec3 endPoint2) { if (endPoint1 == null || endPoint2 == null) { throw new IllegalArgumentException(Logger.logMessage(Logger.ERROR, "Plane", "intersectsSegment", "missingPoint")); } double distance1 = this.dot(endPoint1); double distance2 = this.dot(endPoint2); return distance1 * distance2 <= 0; } Plane();  Plane(double x, double y, double z, double distance);  Plane(Plane plane); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); double distanceToPoint(Vec3 point); Plane set(double x, double y, double z, double distance); Plane set(Plane plane); Plane transformByMatrix(Matrix4 matrix); double dot(Vec3 vector); boolean intersectsSegment(Vec3 endPoint1, Vec3 endPoint2); int onSameSide(Vec3 pointA, Vec3 pointB); Vec3[] clip(Vec3 pointA, Vec3 pointB);  }
@Test public void testIntersectsSegment() throws Exception { Plane p = new Plane(0, 0, -1, 0); boolean result; result = p.intersectsSegment(new Vec3(), new Vec3(0, 0, -1)); assertTrue("Perpendicular, 0 at origin, should produce intersection at origin", result); result = p.intersectsSegment(new Vec3(1, 0, 0), new Vec3(1, 0, 0)); assertTrue("Line segment is in fact a point, located on the plane, should produce intersection at (1, 0, 0)", result); result = p.intersectsSegment(new Vec3(0, 0, -1), new Vec3(0, 0, -1)); assertFalse("Line segment is in fact a point not on the plane, should produce no intersection", result); result = p.intersectsSegment(new Vec3(0, 0, 1), new Vec3(0, 0, -1)); assertTrue("Perpendicular, integer end points off origin, should produce intersection at origin", result); result = p.intersectsSegment(new Vec3(0, 0, 0.5), new Vec3(0, 0, -0.5)); assertTrue("Perpendicular, non-integer end points off origin, should produce intersection at origin", result); result = p.intersectsSegment(new Vec3(0.5, 0.5, 0.5), new Vec3(-0.5, -0.5, -0.5)); assertTrue("Not perpendicular, non-integer end points off origin, should produce intersection at origin", result); result = p.intersectsSegment(new Vec3(1, 0, 0), new Vec3(2, 0, 0)); assertTrue("Parallel, in plane, should produce intersection at origin", result); result = p.intersectsSegment(new Vec3(1, 0, 1), new Vec3(2, 0, 1)); assertFalse("Parallel, integer end points off origin, should produce no intersection", result); }