3
$\begingroup$

Is there a way to find the volume in cubic feet under a ListPlot3D mesh, in positive and negative regions? I have tried using the Volume command. I created a 3D plot from an excel file of x,y, and z values.

$\endgroup$
3
  • $\begingroup$ You could compute the volume by summing over "infinitesimal" volumes. Otherwise, 39161 and related questions might be helpful even if they do not provide a direct answer. $\endgroup$
    – anderstood
    Dec 24, 2017 at 0:55
  • 1
    $\begingroup$ What is your definition of volume for a set of points in 3D space? $\endgroup$
    – m_goldberg
    Dec 24, 2017 at 3:30
  • $\begingroup$ The volume would be enclosed by the x,y plane and the boundary of the points in space connected together to form a mesh. $\endgroup$
    – Codi
    Dec 27, 2017 at 11:11

1 Answer 1

5
$\begingroup$

I don't know what you mean by "in positive and negative regions," but here's a way if the function is nonnegative.

SeedRandom[0]; (* for reproducible results *)
data = Table[{x = RandomReal[{0, 1}], y = RandomReal[{0, 1}], 1 - x^2 + y^2}, {300}];
plot = ListPlot3D[data, BoxRatios -> Automatic, Filling -> 0]
reg = BoundaryDiscretizeGraphics@Show@DiscretizeGraphics@plot
Volume@reg

Mathematica graphics

(*  0.951312   <-- volume *)

Note: DiscretizeGraphics@plot produces a surface (dimension 2) that has no volume. Show converts the region to a Graphics3D object consisting of polygons that happen to form a polyhedron. BoundaryDiscretizeGraphics converts the graphics to the solid region contained by the polyhedron. Roundabout, but I didn't find a more direct way.

If "negative regions" means the function might be negative, then you have to chose a lower bound for what space is to be considered under the graph. For instance, the above problem translated down by 1:

SeedRandom[0];
data = Table[{x = RandomReal[{0, 1}], y = RandomReal[{0, 1}], -x^2 + y^2}, {300}];
plot = ListPlot3D[data, BoxRatios -> Automatic, Mesh -> None, 
   PlotRange -> {-1, 1}, Filling -> -1];
reg = BoundaryDiscretizeGraphics@Show@DiscretizeGraphics@plot;
Volume@reg
(*  0.951312  *)

It is important that the plot range contain the whole region (or parts will be lopped off and the internal meshing function that discretizes the graphics will complain).

$\endgroup$
2
  • $\begingroup$ But where does my x,y,z data get input? I am trying to attach a screenshot but can't figure out how right now... Thank you very much for the answer. $\endgroup$
    – Codi
    Dec 27, 2017 at 11:03
  • $\begingroup$ It worked perfectly, thanks again for the answer. $\endgroup$
    – Codi
    Dec 27, 2017 at 23:41

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.