3

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.

user21
  • 39,710
  • 8
  • 110
  • 167
Codi
  • 39
  • 1
  • 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. – anderstood Dec 24 '17 at 00:55
  • 1
    What is your definition of volume for a set of points in 3D space? – m_goldberg Dec 24 '17 at 03:30
  • The volume would be enclosed by the x,y plane and the boundary of the points in space connected together to form a mesh. – Codi Dec 27 '17 at 11:11

1 Answers1

5

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).

Michael E2
  • 235,386
  • 17
  • 334
  • 747
  • 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. – Codi Dec 27 '17 at 11:03
  • It worked perfectly, thanks again for the answer. – Codi Dec 27 '17 at 23:41