POV-Ray : Newsgroups : povray.off-topic : Math question (inside box) : Re: Math question (inside box) Server Time
28 Jul 2024 22:24:31 EDT (-0400)
  Re: Math question (inside box)  
From: Patrick Elliott
Date: 8 Aug 2013 02:55:57
Message: <520340fd$1@news.povray.org>
On 8/7/2013 2:11 AM, scott wrote:
>> Mind, such a test could handle even non-box results, like trapezoids,
>> but requires.. Ah, I know.. I need to just add in a rotation for the
>> axis I want to test my other "sides" against, which are at:
>
> Indeed, the multiple-planes approach can handle any convex object. If
> you want a concave object (eg an "L" shape) you need to split it up in
> to multiple boxes and test each one separately.
>
>> Hmm. Wait, that gives me planes, but.. how does the test happen?
>> Actually, I think you may have really lost me, or I missed something, or
>> you assumed I had a clue about something I didn't, or.. something.. lol
>
> Once you've got the equations for your planes (ie Ax+By+Cz+D=0) then you
> plug in your point position for xyz and evaluate the result.
>
> If the result is 0 then the point is exactly on the plane, if it's >0
> it's on one side, <0 the other side.
>
> So for example suppose your "right" plane is at a distance 5 along the X
> axis, your plane equation would be 1*x + 0*y + 0*z - 5
>
> Now you can take some points and plug it into that equation:
>
> P=(0,1,2) gives 1*0 + 0*1 + 0*2 -5 = -5 (negative, so on left of plane)
>
> P=(10,5,4) gives 1*10 + 0*5 + 0*4 -5 = 5 (positive, so on right of plane)
>
> You just need to check that your point is on the "inside" of each of the
> 6 planes that make up your box, then you know for sure it is inside the
> box.
>
> Your other plane equations for the box might be:
>
> -1*x + 0*y + 0*z - 3 (left plane)
>   0*x + 1*y + 0*z - 2 (top plane)
>   0*x - 1*y + 0*z - 0 (bottom plane)
>   0*x + 0*y + 1*z - 4 (front plane)
>   0*x + 0*y - 1*z - 1 (back plane)
>
> Slightly off-topic I know, but those are the same numbers you can use in
> the POV "plane" object :-)
>
Ah. OK. That make perfect sense. Definitely need, one of these days, to 
take more math. lol Though, honestly, I have always had much the same 
problem with "equations" as with function calls. Remembering what I want 
to do (or, say.. the function name) is the easy part, its all the fiddly 
bits, which make it work, like.. the actual written equation, or the 
parameters for the call, which screwed me up. lol

Hmm. I do, in this case, since there are "at origin", need to also do:

AVPos = llDetectedPos(0) - llGetPos();

I think, so that the "location" I am testing against is actually based 
on where the box is, not some other place. Otherwise, I would have to 
"add" that position, to all the values. After all, its not at the 
origin, but the equations "assume" that it is.


Post a reply to this message

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