POV-Ray : Newsgroups : povray.general : Testing whether a shape intersects with another Server Time
31 Jul 2024 06:24:16 EDT (-0400)
  Testing whether a shape intersects with another (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: PhilipIsPDR
Subject: Testing whether a shape intersects with another
Date: 4 Nov 2007 09:00:00
Message: <web.472dcf35dc25d7085a2aacfe0@news.povray.org>
Does anyone know of a simple way to test whether one shape is inside another?

I'm looking to fill a random volume - say a radius 10 sphere, with other objects
randomly spaced about - say radius 1 spheres.  That's easily accomplished with
RAND and a loop with a test #if
(random1*random1)+(random2*random2)+(random3*random3) < 1 ...  then sphere is
inside and can be drawn.

Then I can make a hemisphere out of this object by amending the test to add an
#if random1 > 0, for example.


But what I'm really looking for is a way to make a transparent complex CSG
object, and then fill it with spheres or other objects using a test, "#if
inside_CSG_object".


Does anyone know a way of accomplishing this?  I've looked and looked, and I
realise I might be missing something very obvious...


Post a reply to this message

From: M a r c
Subject: Re: Testing whether a shape intersects with another
Date: 4 Nov 2007 09:38:35
Message: <472dd96b@news.povray.org>

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


Post a reply to this message

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

Goto Latest 10 Messages Next 2 Messages >>>

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