POV-Ray : Newsgroups : povray.general : Testing for intersection of two objects : Re: Testing for intersection of two objects Server Time
31 Jul 2024 22:14:49 EDT (-0400)
  Re: Testing for intersection of two objects  
From: Trevor G Quayle
Date: 24 Jul 2006 17:20:00
Message: <web.44c53894c08fcd85c150d4c10@news.povray.org>
"Mike the Elder" <zer### [at] wyanorg> wrote:
> Is there a reasonably simple way in POV-Ray to produce a Boolean value
> representing whether or no two objects intersect?  As in...
>
> #if ("object{Thing1} intersects object{Thing2}")
>       // STUFF TO DO IF THEY INTERSECT
> #else
>       // STUFF TO DO IF THEY DON'T INTERSECT
> #end
>
> I would very much appreciate if some kind soul could point out the section
> of the documentation and/or available resources that deal with this issue.
>
> Thanks in advance.
>
> Mike C.

Perhaps you can use CSG "intersect{}" and then chack min_extents,
max_extents.
Haver a look at this and see if you can get something to work out of it:

//START
global_settings {
  max_trace_level 15
  ambient_light 1
  adc_bailout 0.0001
}


camera {
  location  <0,3,-5>
  look_at   0
}


#declare LB=
sphere{0 50 hollow no_image
  texture{pigment{rgb 1} finish{ambient 20}}
}

light_source{0 rgb 1
  looks_like{LB}
  fade_power 2  fade_distance 300
  translate <0,100,-100>
}



#declare Obj1=sphere{<0,0,0> 1 pigment{rgb<1,0,0>}}
#declare Obj2=sphere{<-2.5,0,0> 1 pigment{rgb<0,1,0>}}
#declare Obj3=sphere{<1.5,0,0> 1 pigment{rgb<0,0,1>}}

object{Obj1}
object{Obj2}
object{Obj3}

#declare Int12=intersection{object{Obj1}object{Obj2}}
#declare Int13=intersection{object{Obj1}object{Obj3}}

#declare Siz12=vlength(min_extent(Int12)-max_extent(Int12));
#declare Siz13=vlength(min_extent(Int13)-max_extent(Int13));

text {ttf "arial.ttf",str(Siz12,0,3),0.1,0 scale 1/3 translate <-2.5,1.5,0>
pigment{rgb 1}}
text {ttf "arial.ttf",str(Siz13,0,3),0.1,0 scale 1/3 translate <1.5,1.5,0>
pigment{rgb 1}}
//END

-tgq


Post a reply to this message

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