POV-Ray : Newsgroups : povray.general : Testing whether a shape intersects with another Server Time
31 Jul 2024 08:29:02 EDT (-0400)
  Testing whether a shape intersects with another (Message 3 to 12 of 12)  
<<< Previous 2 Messages Goto Initial 10 Messages
From: PhilipIsPDR
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 10:40:01
Message: <web.472de695cc25c29c5a2aacfe0@news.povray.org>
"M_a_r_c" <jac### [at] wanadoofr> wrote:

> web.472dcf35dc25d7085a2aacfe0@news.povray.org...
> > Does anyone know a way of accomplishing this?  I've looked and looked, and
> > I
> > realise I might be missing something very obvious...
> >
> What is obvious is that you did not make a research about the word "inside"
> in the pov documentaion :-)
>
> Marc


Thank you for your answer Marc, although it would have been nicer not to have
been put down for my lack of knowledge.  The inside function is exactly what I
was looking for; thank you for pointing me in the right direction.


If anyone else is searching for this, the inside function would be called in
this way:

#if ( inside(Obj, Point) )


Post a reply to this message

From: Jan Dvorak
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 10:47:44
Message: <472de9a0@news.povray.org>
M_a_r_c napsal(a):

> web.472dcf35dc25d7085a2aacfe0@news.povray.org...
>> Does anyone know a way of accomplishing this?  I've looked and looked, and 
>> I
>> realise I might be missing something very obvious...
>>
> What is obvious is that you did not make a research about the word "inside" 
> in the pov documentaion :-)
> 
> Marc 
> 
> 
what is obvious is that you missed he doesn't test for a point. He tests 
for an object being inside another.

One idea is to choose a point where the inner surface is seen completely 
when unoccluded and then trace it together with the other object. If all 
of your rays hit the object you know it's not being intersected by the 
other object, hoping not to miss anything. Then use inside() to know 
whether it is completely inside or completely outside. There is no 
general algorithm to find out if two objects have non-null intersection.


Post a reply to this message

From: PhilipIsPDR
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 11:05:00
Message: <web.472decd3cc25c29c5a2aacfe0@news.povray.org>
Jan Dvorak <jan### [at] centrumcz> wrote:
> M_a_r_c napsal(a):

> > web.472dcf35dc25d7085a2aacfe0@news.povray.org...
> >> Does anyone know a way of accomplishing this?  I've looked and looked, and
> >> I
> >> realise I might be missing something very obvious...
> >>
> > What is obvious is that you did not make a research about the word "inside"
> > in the pov documentaion :-)
> >
> > Marc
> >
> >
> what is obvious is that you missed he doesn't test for a point. He tests
> for an object being inside another.
>
> One idea is to choose a point where the inner surface is seen completely
> when unoccluded and then trace it together with the other object. If all
> of your rays hit the object you know it's not being intersected by the
> other object, hoping not to miss anything. Then use inside() to know
> whether it is completely inside or completely outside. There is no
> general algorithm to find out if two objects have non-null intersection.


Jan, thank you very much for this suggestion, I think I'm going to go with
something very similar to this.

Philip


Post a reply to this message

From: Chris B
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 11:26:04
Message: <472df29c@news.povray.org>
"PhilipIsPDR" <nomail@nomail> wrote in message 
news:web.472de695cc25c29c5a2aacfe0@news.povray.org...
> "M_a_r_c" <jac### [at] wanadoofr> wrote:

>> web.472dcf35dc25d7085a2aacfe0@news.povray.org...
>> > Does anyone know a way of accomplishing this?  I've looked and looked, 
>> > and
>> > I
>> > realise I might be missing something very obvious...
>> >
>> What is obvious is that you did not make a research about the word 
>> "inside"
>> in the pov documentaion :-)
>>
>> Marc
>
>
> Thank you for your answer Marc, although it would have been nicer not to 
> have
> been put down for my lack of knowledge.  The inside function is exactly 
> what I
> was looking for; thank you for pointing me in the right direction......
>

Hi Guys,

I think Marc's smiley emoticon was a good indication that he intended to 
convey irony ie. "Ok obvious, but we all miss the obvious now and then" 
rather than as a "put-down". Remember, emoticons were invented to help avoid 
humour causing offense when you can't see the senders face or hear their 
voice. The alternative of avoiding all humour, just to be on the safe side, 
would make life a little dull (IMHO).

Regards,
Chris B.


Post a reply to this message

From: M a r c
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 12:12:03
Message: <472dfd63$1@news.povray.org>

web.472de695cc25c29c5a2aacfe0@news.povray.org...
> Thank you for your answer Marc, although it would have been nicer not to 
> have
> been put down for my lack of knowledge.  The inside function is exactly 
> what I
> was looking for; thank you for pointing me in the right direction.
>
I was just pulling your leg ;-)

Marc


Post a reply to this message

From: M a r c
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 12:14:17
Message: <472dfde9$1@news.povray.org>

472de9a0@news.povray.org...
>>
> what is obvious is that you missed he doesn't test for a point. He tests 
> for an object being inside another.
>
I never pretended I gave a whole solution but rather a direction to explore.
inside() is usefull isn't it?

Marc


Post a reply to this message

From: M a r c
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 12:16:38
Message: <472dfe76$1@news.povray.org>

472df29c@news.povray.org...
>
> Hi Guys,
>
> I think Marc's smiley emoticon was a good indication that he intended to 
> convey irony ie. "Ok obvious, but we all miss the obvious now and then" 
> rather than as a "put-down". Remember, emoticons were invented to help 
> avoid humour causing offense when you can't see the senders face or hear 
> their voice. The alternative of avoiding all humour, just to be on the 
> safe side, would make life a little dull (IMHO).
>
> Regards,
> Chris B.
>
Thank you for having got and put it right Chris :-)


Marc


Post a reply to this message

From: Alain
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 12:31:52
Message: <472e0208@news.povray.org>
Jan Dvorak nous apporta ses lumieres en ce 2007/11/04 10:46:
> M_a_r_c napsal(a):
>> "PhilipIsPDR" <nomail@nomail> a écrit dans le message de news: 
>> web.472dcf35dc25d7085a2aacfe0@news.povray.org...
>>> Does anyone know a way of accomplishing this?  I've looked and 
>>> looked, and I
>>> realise I might be missing something very obvious...
>>>
>> What is obvious is that you did not make a research about the word 
>> "inside" in the pov documentaion :-)
>>
>> Marc
>>
> what is obvious is that you missed he doesn't test for a point. He tests 
> for an object being inside another.
> 
> One idea is to choose a point where the inner surface is seen completely 
> when unoccluded and then trace it together with the other object. If all 
> of your rays hit the object you know it's not being intersected by the 
> other object, hoping not to miss anything. Then use inside() to know 
> whether it is completely inside or completely outside. There is no 
> general algorithm to find out if two objects have non-null intersection.
The thing to do is to make two objects: one for the actual rendering, and 
another one, smaler, for the tests. If you want to fill your shape with spheres, 
like marbles in a jar, the smaller object have dimentions that are that of the 
containing object minus the radius of the spheres.

-- 
Alain
-------------------------------------------------
War is an instrument entirely inefficient toward redressing wrong; and
multiplies, instead of indemnifying losses.
Thomas Jefferson


Post a reply to this message

From: Tim Attwood
Subject: Re: Testing whether a shape intersects with another
Date: 5 Nov 2007 22:38:13
Message: <472fe1a5$1@news.povray.org>
>> what is obvious is that you missed he doesn't test for a point. He tests 
>> for an object being inside another.

This macro tests if two objects are touching with some accuracy.
You could check if an object is inside another completely by
testing against an inverse container object.

#macro collision(A B rez)
   #local result = false;
   #if (((min_extent(A).x > max_extent(B).x ) |
         (min_extent(B).x > max_extent(A).x ) |
         (min_extent(A).y > max_extent(B).y ) |
         (min_extent(B).y > max_extent(A).y ) |
         (min_extent(A).z > max_extent(B).z ) |
         (min_extent(B).z > max_extent(A).z ))=false)
      #local AB = intersection{object{A} object{B}};
      #local Mn = min_extent(AB);
      #local Mx = max_extent(AB);
      #local S1 = seed(1);
      #local Pt = VRand_In_Box(Mn, Mx, S1);
      #local cnt = 0;
      #while ((result = false) & (cnt < rez))
         #local Pt = VRand_In_Box(Mn, Mx, S1);
         #if (inside(AB, Pt))
            #local result = true;
         #end
         #local cnt = cnt + 1;
      #end
   #end
   result
#end

#declare sample1 = union {
   box {<0,0,0>,<1,1,1>}
   sphere{<0,1,0>,0.1}
   pigment{Red}
};

#declare sample2 = union {
   box {<0,0,0>,<1,1,1>}
   sphere{<1,0,0>,0.1}
   sphere{<0,0,0>,0.1}
   pigment{Blue}
   translate <-1.05,0.25,0>
};

#local result = collision(sample1 sample2 1000);


Post a reply to this message

From: Bryan Valencia
Subject: Re: Testing whether a shape intersects with another
Date: 6 Nov 2007 20:41:47
Message: <473117db$1@news.povray.org>
// Persistence of Vision Ray Tracer Scene Description File
// File: SphereIntersections.pov
// Vers: 3.6
// Desc: Placing Spheres without intersecting
// Date: 11/6/07
// Auth: Bryan Valencia



#declare Count=400;

#declare SphereCenters = array[Count];
#declare Radius = array[Count];

#include "math.inc"
#declare T=texture{
   pigment{color rgb 1}
}

camera{location <0,0,-40> look_at<0,0,0>}
light_source{<-1,1,-1>*1000 color rgb 1}

#declare R=seed(0);

#declare thisSphere=0;
#while (thisSphere<Count)

   #debug str(thisSphere,5,0)

   #declare SphereCenters[thisSphere]=<0,0,0>;
   #declare ok=false;
   #while (ok = false)
     //create a center
     #declare ThisCenter = 
(<rand(R),rand(R),rand(R)>-<rand(R),rand(R),rand(R)>)*30;
     #declare ThisRadius = rand(R)*4+1;

     //test against each previous center
     #declare ok=true;
     #declare A=0;
     #while (A<thisSphere)  //iterate over previous centers
       #declare D = VDist(ThisCenter, SphereCenters[A]);
       #if ( D< (ThisRadius+Radius[A]) )
         #declare ok=false;  //of they are closer than 2 then they 
intersect, things are not ok.
         #declare A=Count; //short-circuit the rest of the testing
       #end
       #declare A=A+1; //next sphere in list to test against
     #end
     //at this point if any are too close we will generate a new center.
     #debug "."  //print one dot per new random point generated.
   #end

   #debug "\n" //when the new center is accepted, new line.
   #declare SphereCenters[thisSphere]=ThisCenter; //add it to the list.
   #declare Radius[thisSphere] = ThisRadius;

   #declare thisSphere=thisSphere+1;
#end

//now lets make spheres out of the list.
#declare A=0;
#while (A<Count)
   #declare C = SphereCenters[A];
   sphere{ C,1 texture{T}}
   #declare A=A+1;
#end






-- 
Bryan Valencia

"I'd rather live with false hope than with false despair."


Post a reply to this message

<<< Previous 2 Messages Goto Initial 10 Messages

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