Calculate Volume?

Started by Alexei_B, December 12, 2007, 03:08:57 PM

Previous topic - Next topic

Alexei_B

I suspect this simple question may be difficult to answer, but how do I calculate the volume of a closed 3-d shape?   Obviously simple geometric primitives like cubes, rectangles, spheres, cones etc. all have known formulae.

Even shapes bounded by known equations describing planes can have volumes found via 3d integration methods.

But what if I need the volume of a more complex mesh/object representing a simple house for example?

My only thought is that 2d areas can be calculated by iterative methods - literally filling a space with tiny units and counting them - something like how the fill or paint bucket tools work in drawing programmes.  Perhaps this could be extended to a 3d solution?

Any comments most appreciated.

EgonOlsen

I have no idea...sounds like a very complicated problem. Your approach may work but sounds time consuming.  ???

Hrolf

If time isn't a problem you could use the method they use in stone carving;

Pseudocode;
    modelVolume=BBoxVolume;
    For each face of the bounding box (ie +X by YZ, -X by YZ, +Z by XY, &c)
        scan the BBox face in smallUnits (use 2 nested for loops)
        use dist=calcMinDistance to get distance from the point on the BBox face to the model
        modelVolume-=small unit * smallUnit * dist

The smaller smallUnit is, the slower it is but the closer the result is to the actual volume...

This method only really works properly on convex models!