# point inside 6 planes

Hi guys

I have a problem…
Imagine a cube, defined by 6 planes!
Ok, now, is there a way to find if a point is inside that cube, with the point coordinates(x,y,z) and the 6 planes equations ?
The point is not in any planes, he is just surrounded by the six planes.
Thanks

Bruno

do the on-left test for each plane, and if it returns true for all of them then the point is inside the object (works for any convex hull)

How is the on-left test done ?

thanks,

Bruno

For any point r, and any plane P(N,d),

let s=Nr-d

if s<0 then the point is behind the plane
if s=0 then the point lies on the plane
if s>0 then the point is in front of the plane

Note: The meanings of “behind” and “in front” are dependent upon your convention, but otherwise do not change anything.

[This message has been edited by DFrey (edited 02-03-2001).]

here is the Frustum Culling in OpenGL . It contain all you need I mean it !!

Frustum culling?

Michael Steinberg :
Frustum culling?

Well, you should go and see by yourlself

[This message has been edited by holocaust (edited 02-04-2001).]

Hey, I might be a bit silly, but I still know what frustum culling is. I just meant that the creator of this discussion intended to do collision detection (which includes some tests of frustum culling…). My bit.

i asked a similar question previously and i got great help from the contributors…see their advice here:
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/001894.html

I’d just like to know what was wrong with the answer I gave above? Are people not able to read it because of a problem with the font? My answer above succinctly says what that whole thread says.

Michael Steinberg
I just meant that the creator of this discussion intended to do collision detection

Well, you’re right. But, as you saw it ;), all the techs explained are usable for plane-based collision detection.

DFrey : you’re right man, i was just giving some where-to-start link

Well, I stated I know that one uses all the collision stuff in culling too (at least in unoptimized culling). It’s just that beginners like to have an answer to their question, not to another related question (and I know that sine I ask often… )

DFrey, I think we can be happy when we agree that you said all.
However what do you mean with P(N,d)? I never saw such a representation of a plane. Is that actually the thin for both the normal representation and the coordinate representation (then I would basically understood what you talked about)

aren’t you basically saying (p-q)*n? Enlighten me!!! Thanks!

I first came across the P(N,d) nomenclature for a plane in an Analytic Geometry class.
It is just a convienient way of saying plane P’s normal is N and displacement is d.

aren’t you basically saying (p-q)*n?

Not exactly, but then again, I’m not certain what your p and q are.

Well, basically, p is a point on the plane and q is the point to test for. n is the identity normal. I may have flipped q and p.

Here’s how you’ll get that.

P is the point to test for and q is the point that lies somewhere on the plane. n is the normal, n0 the identity normal.

p-q is the vector that projects q to p. The cosine of the angle between that vector and the normal is:

cos a = (p-q)n / ((|p|-|q|)|n|)

Now, there’s also:

cos a = ankathete / hypotenuse

Where the hypotenuse is p-q and ankathete the distance vector (well the length of it).

So you’ll get:

d/(|p|-|q|) = (p-q)n / ((|p|-|q|)|n|)

Which is

d = (p-q)*n / |n|. Now a vector divided by itself is the normalized vector:

d = (p-q)*n0

Where the product is defined as:
ab = a0b0+a1b1+…+anbn for two n-component vectors.

[This message has been edited by Michael Steinberg (edited 02-06-2001).]

If instead of using planes’ equation, you use 3 unit vectors & 3 dot products, you’ll just have to use 3 comparaizon :

Cube p1…p6
v1 = p4 - p1
v2 = p3 - p1
v3 = p2 - p1
where p2…4 are the nearest point of the cube to P1

v1 = unit_vector(v1)
v2 = unit_vector(v2)
v3 = unit_vector(v3)

d1= v1.(pt - p1)
d2= v2.(pt - p1)
d3= v3.(pt - p1)

in_cube =
(unsigned)d1<=sizeof(p2-p1)
&& (unsigned)d2<=sizeof(p2-p1)
&& (unsigned)d3<=sizeof(p2-p1);

> Cube p1…p6
Of course you should read “Cube p1…p8” =)
But that doesn’t change anything else

But you wouldn’t get the time and the point of the intersection with the plane, which you need to reflect the vector the ball is moving along.
DFrey, are my mathematical understandings understandable to you?

Where you write (|p|-|q|), did you intend to write (|p-q|)? Because otherwise, I can’t see what relationship was used to arrive at that point. I’m also a little unclear by your value for n, is it the shortest vector from the origin to plane, or the shortest vector from the plane to the test point? Geometry is very difficult in text I wish they would enable the img tags or html on this board, for at least the advanced forum anyway.

Yes, you’re right, I meant |p-q|

Where q is the place vector a point on the plane. p is the point to test the distance. n is the normal, n0 the normalized (unit?) normal.

Basically the first term I mention is the angle beween the normal starting in q and the vector from q to the test-point p. Now, if you imagine the normal going through the test point, you’ll see exactly the same angle again. Where the cosine is cos alpha = Ankathete(don’t know what this is in english)/Hypothenuse(see above…). Okay, the Ankathete is the distance! So you can bascialle set the both terms equal (=) and solve to d, the distance. What comes out is:

d = (p-q)*n

I also replaced n/|n| with n0, means it’s normalized (length of 1). I wonder if this attempt is similar to yours! Cheers!

Are we talking the same, DFrey?