Description
In BSP trees, there are two related methods dealing with the relative position of a sub-hyperplane and an hyperplane: side and split.
sub.side(hyperplane) returns an enumerate (PLUS, MINUS, BOTH, HYPER) telling the relative position of the syb-hyperplane with respect to the hyperplane.
sub.split(hyperplane) splits the sub-hyperplane in two parts, one on the plus side of the hyperplane and one on the minus side of the hyperplane.
These methods should be consistent, i.e. when side returns BOTH, then split should return two non-null parts. This fails in the following case:
@Test public void testSideSplitConsistency() { double tolerance = 1.0e-6; Circle hyperplane = new Circle(new Vector3D(9.738804529764676E-5, -0.6772824575010357, -0.7357230887208355), tolerance); SubCircle sub = new SubCircle(new Circle(new Vector3D(2.1793884139073498E-4, 0.9790647032675541, -0.20354915700704285), tolerance), new ArcsSet(4.7121441684170700, 4.7125386635004760, tolerance)); SplitSubHyperplane<Sphere2D> split = sub.split(hyperplane); Assert.assertNotNull(split.getMinus()); Assert.assertNull(split.getPlus()); Assert.assertEquals(Side.MINUS, sub.side(hyperplane)); }
Here, side returns BOTH but the plus part is null. This is due to the plus
side being smaller than the tolerance (1.0e-6 here) and filtered out in the split methods whereas it is not filtered out in the side method, which has a slightly different algorithm. So instead of returning BOTH, side should return MINUS as it should filter out the too small plus part.
In fact, it is only one particular case, the same could occur in other spaces (Euclidean or Spherical, and on various dimensions).