Frustum { public boolean intersectsSegment(Vec3 pointA, Vec3 pointB) { if (pointA == null || pointB == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Frustum", "containsPoint", "missingPoint")); } if (this.containsPoint(pointA) || this.containsPoint(pointB)) return true; if (pointA.equals(pointB)) return false; for (Plane plane : this.planes) { if (plane.onSameSide(pointA, pointB) < 0) return false; if (plane.clip(pointA, pointB) != null) return true; } return false; } Frustum();  Frustum(Plane left, Plane right, Plane bottom, Plane top, Plane near, Plane far, Viewport viewport); Frustum setToUnitFrustum(); Frustum setToModelviewProjection(Matrix4 projection, Matrix4 modelview, Viewport viewport); Frustum setToModelviewProjection(Matrix4 projection, Matrix4 modelview, Viewport viewport, Viewport subViewport); boolean containsPoint(Vec3 point); boolean intersectsSegment(Vec3 pointA, Vec3 pointB); boolean intersectsViewport(Viewport viewport);  }
@Test public void testIntersectsSegment() throws Exception { Frustum frustum = new Frustum(); Vec3 origin = new Vec3(0, 0, 0); assertTrue("origin", frustum.intersectsSegment(origin, new Vec3(0, 0, 0))); assertTrue("inside near", frustum.intersectsSegment(origin, new Vec3(0, 0, -0.999999))); assertTrue("inside far", frustum.intersectsSegment(origin, new Vec3(0, 0, 0.999999))); assertTrue("inside left", frustum.intersectsSegment(origin, new Vec3(0.9999999, 0, 0))); assertTrue("inside right", frustum.intersectsSegment(origin, new Vec3(-0.9999999, 0, 0))); assertTrue("inside bottom", frustum.intersectsSegment(origin, new Vec3(0, -0.9999999, 0))); assertTrue("inside top", frustum.intersectsSegment(origin, new Vec3(0, 0.9999999, 0))); assertTrue("intersect left", frustum.intersectsSegment(origin, new Vec3(1.0000001, 0, 0))); assertTrue("intersect right", frustum.intersectsSegment(origin, new Vec3(-1.0000001, 0, 0))); assertTrue("intersect bottom", frustum.intersectsSegment(origin, new Vec3(0, -1.0000001, 0))); assertTrue("intersect top", frustum.intersectsSegment(origin, new Vec3(0, 1.0000001, 0))); assertTrue("intersect near", frustum.intersectsSegment(origin, new Vec3(0, 0, -1.0000001))); assertTrue("intersect far", frustum.intersectsSegment(origin, new Vec3(0, 0, 1.0000001))); assertTrue("touch left", frustum.intersectsSegment(new Vec3(1, 0, 0), new Vec3(1.0000001, 0, 0))); assertTrue("touch right", frustum.intersectsSegment(new Vec3(-1, 0, 0), new Vec3(-1.0000001, 0, 0))); assertTrue("touch bottom", frustum.intersectsSegment(new Vec3(0, -1, 0), new Vec3(0, -1.0000001, 0))); assertTrue("touch top", frustum.intersectsSegment(new Vec3(0, 1, 0), new Vec3(0, 1.0000001, 0))); assertTrue("touch near", frustum.intersectsSegment(new Vec3(0, 0, -1), new Vec3(0, 0, -1.0000001))); assertTrue("touch far", frustum.intersectsSegment(new Vec3(0, 0, 1), new Vec3(0, 0, 1.0000001))); assertFalse("outside left", frustum.intersectsSegment(new Vec3(2, 0, 0), new Vec3(1.0000001, 0, 0))); assertFalse("outside right", frustum.intersectsSegment(new Vec3(-2, 0, 0), new Vec3(-1.0000001, 0, 0))); assertFalse("outside bottom", frustum.intersectsSegment(new Vec3(0, -2, 0), new Vec3(0, -1.0000001, 0))); assertFalse("outside top", frustum.intersectsSegment(new Vec3(0, 2, 0), new Vec3(0, 1.0000001, 0))); assertFalse("outside near", frustum.intersectsSegment(new Vec3(0, 0, -2), new Vec3(0, 0, -1.0000001))); assertFalse("outside far", frustum.intersectsSegment(new Vec3(0, 0, 2), new Vec3(0, 0, 1.0000001))); }