
Hi Kilbert,
As long as all of your plane normals point outwards, then if the point is on the negative side of all of the planes, then it is inside. So if the plane equation is Ax+By+Cz+D=0, and p.n + D < 0 for every plane, then it is inside. (where p is the point (x,y,z), and n is the plane normal (A,B,C))
For 2d, it is pretty much the same. Find a 'normal' for each line, and treat it in the same way as for 3d. The 'normal' is either (y0y1, x1x0) or (y1y0, x0x1), depending on whether the polygon is clockwise or not. Then calculate D using D=p.n OR You can test using the dot product between the normal and a vector from the surface to the point. This is what I have used:
Here is some code from an Edge class. The Edge class has members 'p' and 'q' for the start and end of the Edge.
bool Edge::vertexInside(Vertex *v){ // vertexInside() returns true if the vertex is on the "inside" / anticlockwise // side of the edge. // ( nx, ny ) is a vector perpendicular to PQ (anticlockwise) Coord nx= (q>getY()  p>getY()); Coord ny= (q>getX()  p>getX()); // ( dx, dy ) is a vector from a point on the line (P) to the vertex Coord dx= (v>getX()  p>getX()); Coord dy= (v>getY()  p>getY()); // The sign of the dot product indicates which side the vertex is on return (dx*nx + dy*ny) > 0; }
I hope this is of some use to you, See ya, Bry
