POV-Ray : Newsgroups : povray.newusers : Povray Documentation Error? : Re: Povray Documentation Error? I'll say yes. Server Time
31 Jul 2024 04:23:02 EDT (-0400)
  Re: Povray Documentation Error? I'll say yes.  
From: Christopher James Huff
Date: 4 Aug 2003 17:17:27
Message: <cjameshuff-DA51FB.16154604082003@netplex.aussie.org>
In article <3f278c72$1@news.povray.org>,
 "Tom Melly" <tom### [at] tomandlucouk> wrote:

> My assumption (which afaik is/was wrong) was that the bounding box had a
> similiar function to the container for an iso-surface (where I may also have
> missed the point), i.e. that you only evaluate the shape for points inside 
> the container, thus saving calculations on points outside the bounding box.

I'm wondering if you're actually confused about the nature of the 
intersection calculations. Most objects do not solve for intersections 
by stepping along the ray and sampling a function, the isosurface is a 
bit of a special case. Most object intersections are found by following 
a simple algorithm with the ray and object parameters. For example, a 
sphere intersection is basically: (translated more or less directly from 
the C source into POV, and untested)

#declare EPSILON = 1.0e-10;
#macro Intersect_Sphere(RayOrigin, RayDirection, Center, Radius2, 
Depth1, Depth2)
    //distance from origin of ray to center of sphere
    #local Origin_To_Center = Center - RayOrigin;
    
    //square of the length of oc
    #local OCSquared = Sqr(Origin_To_Center);

    //dot product of oc and ray direction. This is the distance
    //along the ray where it is closest to the center of the sphere.
    #local t_Closest_Approach = vdot(Origin_To_Center, RayDirection);
    
    //If we are outside the sphere and closest approach is behind the
    //start of the ray, stop now. An intersection is not possible.
    #if((OCSquared >= Radius2) && (t_Closest_Approach < EPSILON))
        (false) //no intersection
    #else
        //Half of the length of the chord formed by the ray
        //passing through the sphere.
        #local t_Half_Chord_Squared = Radius2 - OCSquared + 
Sqr(t_Closest_Approach);

        #if(t_Half_Chord_Squared > EPSILON)
            //Finish computing the half-chord length.
            #declare Half_Chord = sqrt(t_Half_Chord_Squared);

            //set d1 and d2 to the distances of the intersections
            #declare Depth1 = t_Closest_Approach - Half_Chord;
            #declare Depth2 = t_Closest_Approach + Half_Chord;

            (true)//intersection found
        #else
            (false)//no intersection
        #end
    #end
#end


> In other words, you wouldn't bother to evaluate whether the ray had hit, for
> example, a sphere for any point outside the sphere's bounding box.

POV checks the ray against the bounding box. If the bounding box is not 
hit, the object inside is ignored. If the bounding box *is* hit, the 
object inside is tested against the ray. A bounding box intersection is 
quick to solve, and most of the time will be missed, so a great deal of 
calculations can be avoided this way. It has nothing to do with 
insideness, only with hit/no hit.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

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