Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


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.

  • You cannot reply to this topic
1 reply to this topic

#1 23yrold3yrold   GDNet+   -  Reputation: 914

Like
Likes
Like

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

Sponsor:

#2 mossmoss   Members   -  Reputation: 326

Like
Likes
Like

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.

---- --- -- -
Blue programmer needs food badly. Blue programmer is about to die!





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.



PARTNERS