POV-Ray : Newsgroups : povray.programming : How find the volume of an object? : Re: How find the volume of an object? Server Time
1 Jun 2024 18:51:14 EDT (-0400)
  Re: How find the volume of an object?  
From: Warp
Date: 21 Sep 2005 15:30:03
Message: <4331b4ba@news.povray.org>
Chris Kinata <chr### [at] kinatacom> wrote:
> What is the best method in POV-Ray for finding the
> volume of a simple convex (that is, no hollows or cavities)
> object that is the intersection of two other objects?

  Do you want the exact volume or an approximation?

> One way might be to iteratively intersect this object
> with a series of long thin boxes incremented
> along (for example) the xy plane, and use the Extents macro
> in shapes.inc to get the length of the box.

  Nope, that doesn't work because that macro simply uses min_extent()
and max_extent() which just return the corners of the bounding box of
the given object. CSG intersection does not decrement the size of the
original bounding boxes of the involved objects.

  One possibility, which works with any object with a defined interior
(not just convex ones) is to sample points inside the bounding box of
the object and use inside() to see if the points are inside the object
or not (just a triply-nested loop which goes through all the points
at even distances inside the bounding box should do it). Just count the
number of points inside the object and divide by the total number of
points you sampled and you'll get a factor. When you multiply the volume
of the bounding box with this factor you'll get an approximation of the
volume of the object.
  The problem with this method is that if you want any accuracy you will
have to sample a lot of points and it will be SLOW.

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.