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