Damn trig ... or linear algebra ... or whatever ...

Started by
0 comments, last by 23yrold3yrold 22 years, 8 months ago
Quick question. I''m looking to figure out if a point lies in a poly (3D style collision detection). How do I calculate the angles? Each "polygon" is 4 points, and I need to figure out the angle between two of them and the point I''m testing 4 times, given only their coordinates. The idea being if the angles add up to 360, we have contact. Any help? Chris Barry

Jesus saves ... the rest of you take 2d4 fire damage.

Advertisement
I''m not sure exactly what you''re trying to do, but maybe I can provide another idea...

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!

This topic is closed to new replies.

Advertisement