POV-Ray : Newsgroups : povray.advanced-users : volume calculations Server Time
8 Jul 2024 19:58:19 EDT (-0400)
  volume calculations (Message 1 to 10 of 27)  
Goto Latest 10 Messages Next 10 Messages >>>
From: OJCIT
Subject: volume calculations
Date: 9 Jan 2007 14:10:00
Message: <web.45a3e7c858741c4db43007370@news.povray.org>
Is there a way to calculate and/or export the internal volumes of the finite
CSG objects in a POV-Ray scene?

If not, are there any CAD/CAM translators that can take a .pov file as
input?

I realize this isn't what the program was designed for, but figued it
couldn't hurt to ask.  It seems like the kind of thing somebody might have
thought of before me.

Thanks,

Jay


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: volume calculations
Date: 9 Jan 2007 15:26:44
Message: <45a3fa84@news.povray.org>
OJCIT wrote:
> Is there a way to calculate and/or export the internal volumes of the finite
> CSG objects in a POV-Ray scene?

<http://tag.povray.org/povQandT/languageQandT.html#wireframes>


Post a reply to this message

From: OJCIT
Subject: Re: volume calculations
Date: 9 Jan 2007 16:45:01
Message: <web.45a40bb2174c9403b43007370@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> OJCIT wrote:
> > Is there a way to calculate and/or export the internal volumes of the finite
> > CSG objects in a POV-Ray scene?
>
> <http://tag.povray.org/povQandT/languageQandT.html#wireframes>

Thanks for the quick response, but that's not quite what I meant.  I don't
need to export the surfaces, but I was wondering if there were a way to get
the numerical volume of each solid entity in my scene (i.e., if I filled
them with water, how much would they hold?).  For this purpose I'm only
talking about discrete primitives and objects created by union and
difference operations among them.

For example, I might have a model with a cylinder with a box subtracted from
it, and want to know the resulting volume.  Since the SDL allows much more
complexity than what I use it for, and since there is seamless integration
of infinite primitives, I wouldn't think that's a number that gets computed
in the normal course of things.

My limited understanding seems to be that ray tracers are more interested in
surfaces than interior volumes, and that there's not a concept of internal
mass or material, except for the purposes of diffraction, translucence,
etc.  If photons don't need to know it, I'm guessing it doesn't get
computed.


Post a reply to this message

From: Alain
Subject: Re: volume calculations
Date: 9 Jan 2007 19:34:55
Message: <45a434af$1@news.povray.org>
OJCIT nous apporta ses lumieres en ce 09-01-2007 16:40:
> Thorsten Froehlich <tho### [at] trfde> wrote:
>> OJCIT wrote:
>>> Is there a way to calculate and/or export the internal volumes of the finite
>>> CSG objects in a POV-Ray scene?
>> <http://tag.povray.org/povQandT/languageQandT.html#wireframes>

> Thanks for the quick response, but that's not quite what I meant.  I don't
> need to export the surfaces, but I was wondering if there were a way to get
> the numerical volume of each solid entity in my scene (i.e., if I filled
> them with water, how much would they hold?).  For this purpose I'm only
> talking about discrete primitives and objects created by union and
> difference operations among them.

> For example, I might have a model with a cylinder with a box subtracted from
> it, and want to know the resulting volume.  Since the SDL allows much more
> complexity than what I use it for, and since there is seamless integration
> of infinite primitives, I wouldn't think that's a number that gets computed
> in the normal course of things.

> My limited understanding seems to be that ray tracers are more interested in
> surfaces than interior volumes, and that there's not a concept of internal
> mass or material, except for the purposes of diffraction, translucence,
> etc.  If photons don't need to know it, I'm guessing it doesn't get
> computed.


You can't get the volume of an object directly. You can calculate it for a 
primitive, using the trigonometric formulaes.
Obvious for a box, a cylinder, a torus or a sphere, easy for most simple solids.
It would be a real headache for a blob with more than 1 components...
You can only gues it for SCG objects in non-trivial cases, you can hardly know 
what percentage of any object actualy add or substract from the total volume.

-- 
Alain
-------------------------------------------------
If you pick up a starving dog and make him prosperous, he will not bite you; 
that is the principal difference between a dog and a man.

Mark Twain


Post a reply to this message

From: Tim Attwood
Subject: Re: volume calculations
Date: 10 Jan 2007 05:44:15
Message: <45a4c37f$1@news.povray.org>
> Is there a way to calculate and/or export the internal volumes of the 
> finite
> CSG objects in a POV-Ray scene?

Using extents of an object you can calculate the
volume of the bounding box, then use a large number of
random point samples within the bounding box to determine
the percent of samples that are inside the object, then
the volume can be estimated to be that percent of the
bounding volume. This is sort of like filling a real object
with water then measuring the water.

#include "rand.inc"
#macro volume(Obj)
   #local mn = min_extent(Obj);
   #local mx = max_extent(Obj);
   #local rs = seed(1);
   #local in = 0;
   #local lp = -1;
   #local p = -2;
   #local n = 0;
   #while ( abs(p-lp) > 0.0001)
      #local lp = p;
      #local c = 0;
      #while (c < 5000)
         #local r = VRand_In_Box(mn, mx, rs);
         #local in = in + inside(Obj,r);
         #local c=c+1;
         #local n=n+1;
      #end
      #local p = in/n;
   #end
   #local result = p*(mx.x-mn.x)*(mx.y-mn.y)*(mx.z-mn.z);
   (result)
#end


Post a reply to this message

From: Warp
Subject: Re: volume calculations
Date: 10 Jan 2007 09:42:19
Message: <45a4fb4b@news.povray.org>
Tim Attwood <tim### [at] comcastnet> wrote:
> Using extents of an object you can calculate the
> volume of the bounding box, then use a large number of
> random point samples within the bounding box to determine
> the percent of samples that are inside the object, then
> the volume can be estimated to be that percent of the
> bounding volume.

  If you want any accuracy at all, it would take a very LONG time.

  I would estimate that getting one additional decimal of accuracy
(or whichever base is used) requires O(n^3) more points to be sampled.
You can figure out that that number grows quite fast.

-- 
                                                          - Warp


Post a reply to this message

From: Grassblade
Subject: Re: volume calculations
Date: 10 Jan 2007 12:10:01
Message: <web.45a51d3d174c9403e40c4e130@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Tim Attwood <tim### [at] comcastnet> wrote:
> > Using extents of an object you can calculate the
> > volume of the bounding box, then use a large number of
> > random point samples within the bounding box to determine
> > the percent of samples that are inside the object, then
> > the volume can be estimated to be that percent of the
> > bounding volume.
>
>   If you want any accuracy at all, it would take a very LONG time.
>
>   I would estimate that getting one additional decimal of accuracy
> (or whichever base is used) requires O(n^3) more points to be sampled.
> You can figure out that that number grows quite fast.
>
> --
>                                                           - Warp
If you take an average of m such tests, the standard deviation of errors
will be multiplied by 1/m^2, so that overall accuracy will rise rather
quickly. ;-)


Post a reply to this message

From: Rune
Subject: Re: volume calculations
Date: 10 Jan 2007 12:22:01
Message: <45a520b9$1@news.povray.org>
Warp wrote:
> Tim Attwood <tim### [at] comcastnet> wrote:
>> Using extents of an object you can calculate the
>> volume of the bounding box, then use a large number of
>> random point samples within the bounding box to determine
>> the percent of samples that are inside the object, then
>> the volume can be estimated to be that percent of the
>> bounding volume.
>
>  If you want any accuracy at all, it would take a very LONG time.
>
>  I would estimate that getting one additional decimal of accuracy
> (or whichever base is used) requires O(n^3) more points to be sampled.
> You can figure out that that number grows quite fast.

For objects that fill a reasonably high percentage of the bounding box (such 
as a sphere) it wouldn't be a big problem unless you really care about high 
accuracy. For other objects though, such as, say, a cylinder from <-1,-1,-1> 
to <1,1,1> with radius 0.01, testing all points (with some proximity) within 
the bounding box is extremely inefficient. However, pre-testing with trace 
lines within the bounding box parallel with one or more axes could be used 
to weed out by far the most points beforehand, and this would only be 
O(n^2).

Rune
-- 
http://runevision.com


Post a reply to this message

From: Rune
Subject: Re: volume calculations
Date: 10 Jan 2007 12:33:24
Message: <45a52364$1@news.povray.org>
Rune wrote:
> For objects that fill a reasonably high percentage of the bounding
> box (such as a sphere) it wouldn't be a big problem unless you really
> care about high accuracy. For other objects though, such as, say, a
> cylinder from <-1,-1,-1> to <1,1,1> with radius 0.01, testing all
> points (with some proximity) within the bounding box is extremely
> inefficient. However, pre-testing with trace lines within the
> bounding box parallel with one or more axes could be used to weed out
> by far the most points beforehand, and this would only be O(n^2).

...in most common cases that is. It won't work for, say, a sphere with a 
slightly smaller sphere carved out of it.

Come to think of it, the tracing could be used iteratively to do the volume 
calculation in the first place. This would work in all cases and would only 
be O(n^2*m) where m represents the complexity of the object.

Rune
-- 
http://runevision.com


Post a reply to this message

From: Daniel Nilsson
Subject: Re: volume calculations
Date: 10 Jan 2007 13:20:51
Message: <45a52e83$1@news.povray.org>
Tim Attwood wrote:
>> Is there a way to calculate and/or export the internal volumes of the 
>> finite
>> CSG objects in a POV-Ray scene?
> 
> Using extents of an object you can calculate the
> volume of the bounding box, then use a large number of
> random point samples within the bounding box to determine
> the percent of samples that are inside the object, then
> the volume can be estimated to be that percent of the
> bounding volume. This is sort of like filling a real object
> with water then measuring the water.


A better way to sample the volume (although requiring external 
processing) may be to render a series of slices of the object and then 
sum the number of covered pixels in those images. This can be done using 
an object pattern mapped to a plane and animating the translation of the 
pattern along the axis perpendicular to the plane, much like a CAT-scan 
really.

-- 
Daniel Nilsson
going back to lurking mode...


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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