POV-Ray : Newsgroups : povray.general : Testing for intersection of two objects : Re: Testing for intersection of two objects Server Time
1 Aug 2024 04:15:23 EDT (-0400)
  Re: Testing for intersection of two objects  
From: Mike the Elder
Date: 25 Jul 2006 15:50:00
Message: <web.44c674ddc08fcd85aaf01cad0@news.povray.org>
Testing the min_extent (or max_extent) of the intesetion of the two objects
seems to work pretty well.

In the example below, "TheBox" will intersect "TheSphere" iff "SphereRadius"
has a magnitude of 1 or more.

===============================================
#declare SphereRadius = 1;      //Just big enough
#declare TheBox = box{<1,1,1>,<-1,-1,-1>}
#declare TheSphere = sphere{<2,0,0>,SphereRadius}
#declare TestThing = intersection{object{TheBox} object{TheSphere}}

#if (min_extent(TestThing).x > -1000000)
        #warning "Yes, they intersect."
#else
        #warning "No, they do not intersect."
#end
===============================================
produces: "Parse Warning: Yes, they intersect."

AND

===============================================
#declare SphereRadius = .999999;       //Just too small
#declare TheBox = box{<1,1,1>,<-1,-1,-1>}
#declare TheSphere = sphere{<2,0,0>,SphereRadius}
#declare TestThing = intersection{object{TheBox} object{TheSphere}}

#if (min_extent(TestThing).x > -1000000)
        #warning "Yes, they intersect."
#else
        #warning "No, they do not intersect."
#end
===============================================
produces: "Parse Warning: No, they do not intersect."


In a further experiment, where one of the test objects was a slightly more
complex object (a union of several spheres) the results remained
consistent.  This method seems quite sufficient for my purpose.  (Which, by
the way, is filling a box with "packing peanuts" turned every which way so
that no two "peanuts" will occupy the same space.)

Thanks again to all who contributed.

-Mike C.


Post a reply to this message

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