Bug introduced in 10.0 and fixed in 10.4
Given that two polygons regions as below:
ellipsePoints[mat_, {x_, y_}] :=
mat.{Sin[#], Cos[#], 1} & /@ Range[x, y, 0.02 Pi]
ellipsePoints[mat_, {{a_, b_}, {c_, d_}}] :=
mat.{Sin[#], Cos[#], 1} & /@
Join[Range[a, b, 0.02 Pi], Range[c, d, 0.02 Pi]]
mat1 =
{{{0., -5., 0}, {-5.2203, 0., 1.7945}},
{{-0.8583, -4.9384, 0.6792}, {-5.4189, 0.7822, 1.8663}},
{{-1.8203, -4.7553, 1.0855}, {-5.6022, 1.5451, 1.9672}},
{{-2.3568, -4.6194, 1.1959}, {-5.6897, 1.9134, 2.047}},
{{-2.9427, -4.455, 1.2502}, {-5.7755, 2.27, 2.1556}},
{{-4.3197, -4.0451, 1.2087}, {-5.9456, 2.9389, 2.4846}},
{{-6.1237, -3.5355, 1.}, {-6.1237, 3.5355, 3.}}};
domain1 =
{{{5.0026, 2 Pi}, {0, 1.4113}}, {1.2264, 5.2684},
{0.6788, 5.5682}, {{0.2931, 2.3402}, {2.9578, 5.7662}},
{{3.2396, 2 Pi}, {0, 2.1486}}, {{3.4794, 2 Pi}, {0, 2.0429}},
{{3.5801, 2 Pi}, {0, 2.0223}}};
pts1 = Flatten[
MapThread[ellipsePoints, {mat1[[1 ;; 3]], domain1[[1 ;; 3]]}], 1];
pts2 = Flatten[
MapThread[ellipsePoints, {mat1[[1 ;; 5]], domain1[[1 ;; 5]]}], 1];
Show[ConvexHullMesh[pts2], ConvexHullMesh[pts1]]
Obviously, mesh1
and mesh2
own difference of area.
RegionDifference[ConvexHullMesh[pts2], ConvexHullMesh[pts1]]
However, the above code cannot return the difference of area normally.
An alternative method is using RegionIntersection[]
,
intersec =
RegionIntersection[ConvexHullMesh[pts3], ConvexHullMesh[pts2]]
then using the bigest area minus insters
. This time it also failed.
RegionDifference[ConvexHullMesh[pts2], intersec]
Normal case
pts3 = Flatten[MapThread[ellipsePoints, {mat1, domain1}], 1];
RegionDifference[ConvexHullMesh[pts3], ConvexHullMesh[pts1]]
Test on version V10.3
Bug fixed in V10.4
bug
tag. $\endgroup$