POV-Ray : Newsgroups : povray.off-topic : Math question (inside box) : Re: Math question (inside box) Server Time
28 Jul 2024 22:21:42 EDT (-0400)
  Re: Math question (inside box)  
From: Patrick Elliott
Date: 6 Aug 2013 22:07:01
Message: <5201abc5$1@news.povray.org>
On 8/5/2013 11:16 PM, Le_Forgeron wrote:
> Le 06/08/2013 06:20, Patrick Elliott a écrit :
>> On 8/5/2013 4:43 AM, Le_Forgeron wrote:
>>>
>>> The test against 6 planes would work, and is easy if it is axis aligned.
>>> ...
>>> What I said was that extending the "smart" 2D triangle-based-tests to 3D
>>> are to be a nightmare.
>>>
>> Still not seeing why two planes wouldn't, see my "is it in the aquarium"
>> explanation from my reply to scott.
>
> the "Aquarium" is using projections (2) and has hidden implication (the
> projections are at 90° angle).
>
> you could as well use only 1 projections and an additional "distance
> from point to its projection".
> Your main issue so far is projecting on arbitrary rotated plane/square.
> and it won't be easy.
>
>>
>> But, in any case, I think there may be a simpler solution,
>
> Simpler than evaluating the sign of 6 first-degree equations ?
> P(x,y,z) the point to test,
>   Vn(An,Bn,Cn,Dn) [n:1 to 6], the 4D vector representing the planes of
> the box (oriented so that inside is >0)
>   are all signs of x.An+y.Bn+z.Cn+Dn positive ?
>
> the plane XY at height z=10 is <0,0,1,-10> (or in the opposite direction
> <0,0,-1,10> ), where is the difficulty ?
>
Ah, I see. Your looking at 'ax + by + cz - d = 0' It should be - for the 
last term, right, to be correct, or is it + because of what you are 
trying to do with it? The dots, instead of * threw me there, for a second.

Hmm.. I need to work out "where" the planes are, to test them, and that 
means the vector normal for it, which is dependent on the object 
rotation, right? So.. Which, if I am right, means I don't need to even 
know where the corners are (which was a "big") problem, when the thing 
was rotated.

norm = llVecNorm(<1,0,0> * llGetRot() * dist);

would give me "one" plane, and I can get another from that too, with a 
farther/shorter distance, where the results are <norm.x, norm.y, norm.z, 
dist> and <norm.x2, norm.y2, norm.z2, dist2>, but the I need to find the 
vector normals for the other four sides.

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:

llVecNorm(<1,0,0> * llGetRot() * <90,0,0> * dist3);
llVecNorm(<1,0,0> * llGetRot() * <90,90,0> * dist4);
llVecNorm(<1,0,0> * llGetRot() * <90, 180,0> * dist5);
llVecNorm(<1,0,0> * llGetRot() * <90,270,0> * dist6);

(or the quaternion equivalent, since Euler will go batshit if I try to 
rotate two axis at once, using their conversion functions...)

Realizing that,
dist1 = from the door/object.
dist2 = length of bounding box.
dist3 = left distance, from center of bounding box.
dist4 = up distance, from center of bounding box.
dist5 = right distance, from center of bounding box.
dist6 = down distance, from center of bounding box.

Or.. which ever directions those are.. ;) It doesn't matter though, 
since its still going to be right, I think. Unless I got the 90 degree 
angle I need to also twist around wrong, somehow). Yeah, that is doable, 
I think.

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


Post a reply to this message

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