View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #123yrold3yrold  GDNet+

Posted 09 August 2001 - 03:55 PM

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

### #2mossmoss  Members

Posted 09 August 2001 - 04:07 PM

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.

---- --- -- -