0
$\begingroup$

I have a volume enclosing a certain region. The region is non-convex, and I calculate its convex hull with the built-in Mathematica function. I want to know the difference between the region and its convex hull. The inbuilt RegionDifference function throws the following error:

BoundaryMeshRegion::bsuncl: The boundary surface is not closed because the edges Line[{... ,<<2390>>}] only come from a single face.

Any help would be appreciated.

(* some preliminaries *)
fn[x_, y_] = 
 x^2 + y^2 + 
  2/x^2 (-20 x + 0.4 x^2 + y^2)^2 (1/2 + (
     Sqrt[
      2] (Cos[(x^2)^(1/4)/Sqrt[2]] - 
        Cosh[(x^2)^(1/4)/Sqrt[2]]))/((x^2)^(
      1/4) (Sin[(x^2)^(1/4)/Sqrt[2]] + Sinh[(x^2)^(1/4)/Sqrt[2]])))
fnLimit[x_, y_] = Limit[fn[x, y], x -> 0]
fnPiecewise[x_, y_] = 
 Piecewise[{{fn[x, y], x < 0}, {fnLimit[x, y], x == 0}, {fn[x, y], 
    x > 0}}]

(* the region of interest *)
volToPlot = 
  ImplicitRegion[
   fnPiecewise[x, y] - 100 z < 
    00, {{x, -300, 300}, {y, -300, 300}, {z, 0, 800}}];
vol = BoundaryDiscretizeRegion[
  volToPlot, {{-300, 300}, {-300, 300}, {0, 800}}, 
  MaxCellMeasure -> 1000]

(* Convex hull of the region *)
convexHullVol = ConvexHullMesh[vol]

RegionDifference[convexHullVol, vol]
$\endgroup$
2
  • 1
    $\begingroup$ "RegionDifference is throwing an error" - what error? $\endgroup$
    – MarcoB
    Jun 1, 2022 at 12:26
  • $\begingroup$ Thanks, @MarcoB. I edited the question. $\endgroup$
    – akr
    Jun 1, 2022 at 12:28

0

Your Answer

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