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