Damn trig ... or linear algebra ... or whatever ...,
GDNet+ - Reputation: 941
Posted 09 August 2001 - 03:55 PM
Members - Reputation: 326
Posted 09 August 2001 - 04:07 PM
Assuming you already know your point is on the plane of the poly (ie, distance of point to plane equals zero), you can take directed edge (counter-clockwise is the usual) as a vector, and cross-product it with the normal of the poly''s plane.
The result is the normal of a new plane passing through the edge and perpendicular to the poly. Now perform a distance test of your point with that plane. Repeat for all edges.
Assuming you''re using right-handed coordinate system, if all distances are negative, then your point lies in the poly. If any distance is positve, you''re outside the poly.
I expect this only works for convex polys, though.
---- --- -- -
Blue programmer needs food badly. Blue programmer is about to die!