Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


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

This topic is 6188 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!