@Test public void testBoxSphereCollision() { BoundingBox box1 = new BoundingBox(Vector3f.ZERO, 1, 1, 1); BoundingSphere sphere2 = new BoundingSphere(1, Vector3f.ZERO); checkCollision(box1, sphere2, 1); // Put it at the very edge - for sphere vs. box, it will not intersect sphere2.setCenter(new Vector3f(2f, 0f, 0f)); checkCollision(box1, sphere2, 0); // Put it a wee bit closer - should intersect. sphere2.setCenter(new Vector3f(2f - FastMath.ZERO_TOLERANCE, 0, 0)); checkCollision(box1, sphere2, 1); // Test if the algorithm converts the sphere // to a box before testing the collision (incorrect) float sqrt3 = FastMath.sqrt(3); sphere2.setCenter(Vector3f.UNIT_XYZ.mult(2)); sphere2.setRadius(sqrt3); checkCollision(box1, sphere2, 0); // Make it a wee bit larger. sphere2.setRadius(sqrt3 + FastMath.ZERO_TOLERANCE); checkCollision(box1, sphere2, 1); }