This question is in continuation with the previous post Convert ConvexHull to Inequality

There are two problems that I faced. Suppose we have two or more convex hull defined using an array R[i], like


Now to find the region inequality at once for all convex hull in the array I use a do loop as

    Do[regFunc[i][{x, y, z}] := FullSimplify @ RegionMember[Rationalize @ MeshPrimitives[DiscretizeRegion[R[i],  MaxCellMeasure -> \[Infinity]], 3][[1]]] @ {x, y, z},{i,1,2}];

But this gives error and so I have to manually write the whole code for each convex hull. Secondly, I want the region as a open region. This means that I want > or < not >= or <= . This is because later I will calculate region intersection using ImplicitRegion, where due to >= or <= the regions seem to intersect at the boundaries, which I don't want. Any possible way to do it in Mathematica?


1 Answer 1


The easy part of the question: (1) Use regFunc[i][{x_, y_, z_}] (not regFunc[i][{x, y, z}]) when you define regFunc, (2) Use With[{i = i}, ...] to inject the value of i on the right-hand-side expression:

Do[With[{i = i}, 
   regFunc[i][{x_, y_, z_}] := FullSimplify@
          DiscretizeRegion[R[i], MaxCellMeasure -> ∞], 3][[1]]]@{x, y, z}],
   {i, 1, 2}];

Column @ {regFunc[1]@{x, y, z}, regFunc[2]@{x, y, z}}

enter image description here

Not sure about the second part, but maybe you can do this:

{regFunc[1]@{x, y, z}, regFunc[2]@{x, y, z}} /. 
     {LessEqual -> Less, GreaterEqual -> Greater} // Column

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.