SubCircle extends AbstractSubHyperplane<Sphere2D, Sphere1D> { @Override public SplitSubHyperplane<Sphere2D> split(final Hyperplane<Sphere2D> hyperplane) { final Circle thisCircle = (Circle) getHyperplane(); final Circle otherCircle = (Circle) hyperplane; final double angle = Vector3D.angle(thisCircle.getPole(), otherCircle.getPole()); if (angle < thisCircle.getTolerance()) { return new SplitSubHyperplane<Sphere2D>(null, this); } else if (angle > FastMath.PI - thisCircle.getTolerance()) { return new SplitSubHyperplane<Sphere2D>(this, null); } else { final Arc arc = thisCircle.getInsideArc(otherCircle); final ArcsSet.Split split = ((ArcsSet) getRemainingRegion()).split(arc); final ArcsSet plus = split.getPlus(); final ArcsSet minus = split.getMinus(); return new SplitSubHyperplane<Sphere2D>(plus == null ? null : new SubCircle(thisCircle.copySelf(), plus), minus == null ? null : new SubCircle(thisCircle.copySelf(), minus)); } } SubCircle(final Hyperplane<Sphere2D> hyperplane,
                     final Region<Sphere1D> remainingRegion); @Override Side side(final Hyperplane<Sphere2D> hyperplane); @Override SplitSubHyperplane<Sphere2D> split(final Hyperplane<Sphere2D> hyperplane);  }
@Test public void testSPlit() { Circle xzPlane = new Circle(Vector3D.PLUS_J, 1.0e-10); SubCircle sc1 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split1 = sc1.split(xzPlane); ArcsSet plus1 = (ArcsSet) ((SubCircle) split1.getPlus()).getRemainingRegion(); ArcsSet minus1 = (ArcsSet) ((SubCircle) split1.getMinus()).getRemainingRegion(); Assert.assertEquals(1, plus1.asList().size()); Assert.assertEquals(5.0, plus1.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(6.0, plus1.asList().get(0).getSup(), 1.0e-10); Assert.assertEquals(1, minus1.asList().size()); Assert.assertEquals(1.0, minus1.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(3.0, minus1.asList().get(0).getSup(), 1.0e-10); SubCircle sc2 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0); SplitSubHyperplane<Sphere2D> split2 = sc2.split(xzPlane); Assert.assertNull(split2.getPlus()); ArcsSet minus2 = (ArcsSet) ((SubCircle) split2.getMinus()).getRemainingRegion(); Assert.assertEquals(1, minus2.asList().size()); Assert.assertEquals(1.0, minus2.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(3.0, minus2.asList().get(0).getSup(), 1.0e-10); SubCircle sc3 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split3 = sc3.split(xzPlane); ArcsSet plus3 = (ArcsSet) ((SubCircle) split3.getPlus()).getRemainingRegion(); Assert.assertEquals(1, plus3.asList().size()); Assert.assertEquals(5.0, plus3.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(6.0, plus3.asList().get(0).getSup(), 1.0e-10); Assert.assertNull(split3.getMinus()); SubCircle sc4 = create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split4 = sc4.split(xzPlane); Assert.assertEquals(Side.HYPER, sc4.side(xzPlane)); Assert.assertNull(split4.getPlus()); Assert.assertTrue(split4.getMinus() == sc4); SubCircle sc5 = create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split5 = sc5.split(xzPlane); Assert.assertTrue(split5.getPlus() == sc5); Assert.assertNull(split5.getMinus()); }