Hi, Geometry Team
I'm learning this interesting project and facing some difficulties when i did a
little experiment.
I created two ConvexPolygon3D instances (2 white rectangles in below image) on
the same plane, and try to get the overlaping area(blue part) by
RegionBSPTree3D intersection operation.
But i got null when getting the centroid of the intersection. It looks that
this test of intersection failed.
Could you tell me how can i fix this?
Thanks for your contribution to this project!
//---------my test codes----------
public class TestIntersection
{
public static void main(String args[])
{
Precision.DoubleEquivalence precision =
Precision.doubleEquivalenceOfEpsilon(1e-6);
List<Vector3D> pts1 = new ArrayList<>();
pts1.add(Vector3D.of(0, 10, 0));
pts1.add(Vector3D.of(30, 10, 0));
pts1.add(Vector3D.of(30, 20, 0));
pts1.add(Vector3D.of(0, 20, 0));
ConvexPolygon3D face1=Planes.convexPolygonFromVertices(pts1, precision);
List<Vector3D> pts2 = new ArrayList<>();
pts2.add(Vector3D.of(10, 0, 0));
pts2.add(Vector3D.of(20, 0, 0));
pts2.add(Vector3D.of(20, 30, 0));
pts2.add(Vector3D.of(10, 30, 0));
ConvexPolygon3D face2 = Planes.convexPolygonFromVertices(pts2,
precision);
List<ConvexPolygon3D> list1 = new ArrayList<>();
list1.add(face1);
RegionBSPTree3D bsp1 = RegionBSPTree3D.from(list1);
List<ConvexPolygon3D> list2 = new ArrayList<>();
list2.add(face2);
RegionBSPTree3D bsp2 = RegionBSPTree3D.from(list2);
RegionBSPTree3D result = RegionBSPTree3D.empty();
result.intersection(bsp1, bsp2);
System.out.println("Hello, Geometry! Centroid: "+result.getCentroid());
//expect (15,15,0), but got null actually
}
}