3
$\begingroup$

I have a set of data from which I'm able to generate closed contours (surfaces) in with ListContourPlot3D. I would like to determine the (approximate) volume of these surfaces as well as their surface areas. Is this possible in some manner?

$\endgroup$
2
  • 2
    $\begingroup$ Where is the data? $\endgroup$
    – zhk
    Commented Feb 5, 2017 at 15:43
  • $\begingroup$ This is highly dependant on the surface. Oftentimes the output from ContourPlot3D includes many polygons with 4 points which aren't quite as planar as the region functions want. $\endgroup$
    – Jason B.
    Commented Feb 5, 2017 at 22:38

2 Answers 2

2
$\begingroup$

You can use DelaunayMesh, RegionBoundary, and RegionMeasure

Points on a unit sphere for example data (Taken from:how to get $n$ equidistributed points on the unit sphere):

points = With[{points = 5000, samples = 40000, iterations = 20}, 
   Nest[With[{randoms = Join[#, RandomPoint[Sphere[], samples]]}, 
      Normalize@Mean@randoms[[#]] & /@ 
       Values@PositionIndex@Nearest[#, randoms]] &, 
    RandomPoint[Sphere[], points], iterations]];

Calculating volume and surface area:

ListContourPlot3D[points, Contours -> {0}]
object = DelaunayMesh[points];
objectSurface = RegionBoundary[object];

RegionMeasure[object, 3]
RegionMeasure[objectSurface, 2]

4.18349

12.5579

$\endgroup$
2
$\begingroup$

You can use BoundaryDiscretizeGraphics to convert the contour plot to a BoundaryMeshRegion, then measure the volume and surface area of the region.

data = Table[x^4 + y^4 + z^4, {x, -1, 1, 0.2}, {y, -1, 1, 0.2}, {z, -1, 1, 0.2}];

g = ListContourPlot3D[data, Contours -> {0.8}, 
  DataRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, Mesh -> None]

enter image description here

b = BoundaryDiscretizeGraphics[g]

enter image description here

RegionMeasure /@ {b, RegionBoundary[b]}
(* {5.2023, 15.2752} *)
$\endgroup$
3
  • $\begingroup$ Should this work in V10.4? $\endgroup$
    – Young
    Commented Feb 5, 2017 at 17:30
  • $\begingroup$ @Young, I'm not sure - I'm using version 11. $\endgroup$ Commented Feb 5, 2017 at 17:43
  • $\begingroup$ It doesn't seem to work for me on 10.4.1 $\endgroup$
    – Young
    Commented Feb 5, 2017 at 17:52

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.