POV-Ray : Newsgroups : povray.general : How find the volume of an object? : Re: How find the volume of an object? Server Time
1 Aug 2024 12:22:38 EDT (-0400)
  Re: How find the volume of an object?  
From: Mike Williams
Date: 24 Sep 2005 14:27:29
Message: <n+GKwIASkZNDFwJH@econym.demon.co.uk>
Wasn't it gregjohn who wrote:
>Mike, I'm wondering how this works for anything other than a sphere of 0,1 ,

It works for any convex object that fits inside the unit sphere.
For objects that don't fit into the unit sphere you could use min_extent
and max_extent of the object.

>and I'm trying to figure out how the trace function doesn't flake out when
>you "miss" the object completely.

When it misses, trace() returns P1 = <0,0,0>and P2 = <0,0,0>, so 
(P1.z - P2.z)*Area is zero, and that line adds nothing to the volume.

I could have got trace() to return a normal and checked that in the
documented manner to determine if trace() had missed, but it's probably
more efficient to just add the zero.

(It might possibly be more efficient to check to see if the trace() in
one direction hits, and only perform the second trace() if the first one
succeeds, but I was writing it in the middle of the night and couldn't
be bothered with such fine points.)

>Consider:
>http://news.povray.org/povray.text.scene-files/thread/%3C39bc2947%40news.povray.
>org%3E/?ttop=203039&toff=300

I guess that approach might work for concave objects too.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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