Any three points in 3D space are guaranteed to be coplanar. But it's even easier than that. Since your walls are already flat then you know all points on the wall are coplanar.

Also we know that the dot product of two perpendicular vectors is always 0. Since this is true and since all your walls are planes themselves you can test whether or not any point is in the plane by a simple dot product. If the result is 0 then you know the point is on the plane. However, in 3D games this is RARELY EVER going to work out perfect since you will probably interpenetrate the plane or the wall.

The equation for a plane is A+B+C+D=0 or A+B+C=D.

It can be expressed in vector form as:

**N** dot **P**=0

Where N is the normal to the plane and P is a point on the plane.

The graph of a plane is:

N dot (P-P0)=0

Essentially if PO lies on the plane then the point P also lies on the plane if the vector formed from P-P0 is orthogonal to the plane's normal vector.

This results in the popular form: N dot P + d =0

d=-N dot P0

If the normal is of unit length then the above equation gives the shortest signed distance from the origin to the plane.

Ok now a,b,c form the component's of the plane's normal vector and d is the is the value we just derived from above.

From this proof we can see that:

if (n dot p)+d=0 then p is coplanar with the plane

if (n dot p)+d>0 then p is in front of the plane and in the plane's positive half space.

if (n dot p)+d<0 then p is in back of the plane and in the plane's negative half space.

The D3DX library provides functions to compute all of this but since you are not using Direct3D I will write the C function here.

Code:

typedef struct Plane
{
float a,b,c,d;
}
void VectorDotPlane(Plane P,Vector3 V)
{
return ((P.a*V.x)+(P.b*V.y)+(P.c*V.z)+(P.d))
}