|
![](/i/fill.gif) |
"SharkD" <nomail@nomail> wrote in message
news:web.4916415194a473741f7585b80@news.povray.org...
> Is there a function that returns true if two objects intersect? Thanks!
>
> -Mike
>
I don't think there's any universally reliable way to do that.
In some circumstances you may be able to construct an approach using the
min_extent and max_extent functions with the object you get by using an
intersection of the two objects you're interested in to help determine this,
but these functions use the bounding box of the resulting object and, as the
help says: "this is not perfect, in some cases (such as CSG intersections
and differences or isosurfaces) the bounding box does not represent the
actual dimensions of the object".
Given this, you could (with a considerable degree of caution) construct a
macro that may be able to serve your particular needs by combining the
min_extent and max_extent functions and the trace function. If the extent
values returned are very large (10000000000), then the objects don't
intersect. If any of the dimensions is zero, then they don't intersect.
Otherwise you'd need to fire a grid of lines through the space using the
trace function to see if any hit the object. If any hit the intersection
object, then it exists. If none hit the object it's still possible that the
original objects intersected, but that your rays were'nt close enough
together to hit it.
I've pasted in a bit of SDL below that may help if you wish to explore this
approach.
Hope that helps.
Regards,
Chris B.
camera {location <0,0,-6> look_at 0}
light_source { <0,100,-10>, 1 }
#declare MyObject = intersection {
sphere {y,1}
sphere {-x,0.01}
pigment {rgb 1}
}
#declare MyObject_Min = min_extent(MyObject);
#declare MyObject_Max = max_extent(MyObject);
#declare MyObject_Dim = MyObject_Max - MyObject_Min;
#debug concat(" Min extents: ",vstr(3,MyObject_Min,","3,3),"\n")
#debug concat(" Max extents: ",vstr(3,MyObject_Max,","3,3),"\n")
#debug concat(" Dimensions: ",vstr(3,MyObject_Dim,","3,3),"\n")
#if (MyObject_Max.x>1000000)
#debug "Clear Miss\n"
#end
#if (MyObject_Dim.x=0 | MyObject_Dim.y=0 | MyObject_Dim.z=0)
#debug "Miss\n"
#end
// Otherwise use trace to test the object.
object {MyObject}
Post a reply to this message
|
![](/i/fill.gif) |