Skip to main content
Added the full text of the error
Source Link
MarcoB
  • 68k
  • 19
  • 99
  • 207

I have a volume enclosing a certain region. The region is non-convex, and I calculate its convex hull with the inbuiltbuilt-in Mathematica function. I want to know the difference between the region and its convex hull. The inbuilt RegionDifferenceRegionDifference function throws the following error "The boundary surface is not closed because the edges.... ".:

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]

I have a volume enclosing a certain region. The region is non-convex, and I calculate its convex hull with the inbuilt Mathematica function. I want to know the difference between the region and its convex hull. The inbuilt RegionDifference function throws the error "The boundary surface is not closed because the edges.... ". 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]

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]
edited title
Link
akr
  • 177
  • 8

Difference ofbetween a region and its convex hull

edited title
Link
akr
  • 177
  • 8

Difference of a region and its convex hull?

edited title
Source Link
akr
  • 177
  • 8
Loading
added 91 characters in body
Source Link
akr
  • 177
  • 8
Loading
Source Link
akr
  • 177
  • 8
Loading