Jump to content
  • Advertisement


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


more collision detection

This topic is 6542 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

-->question part<-- The part that I''m wondering about is how do you find the intersection of a vector and the triangle''s plane, given the triangle''s three points (or possibly the normal if you need that). Notice I said vector, and not ray. That should be an easy question, but it stumps me. I have the following worked out though: Thanks for any help. darrennix@msn.com -->solution part<-- A point is in a triangle if the point is contained by all three of the triangle''s angles. A point is contained if its angle from an edge is less than the angle. In other words, if(ptinangle(point, a, b, c) && ptinangle(point, b, c, a) && ptinangle(point, c, a, b)) // it''s in the triangle! bool ptinangle(CONST POINT &v, CONST POINT &v0, CONST POINT &v1, CONST POINT &v2) { double fTheta = acos(((v.x-v0.x)*(v2.x-v0.x)+(v.y-v0.y)*(v2.y-v0.y))/(mag(v-v0)*mag(v2-v0))), fAngle = acos(((v1.x-v0.x)*(v2.x-v0.x)+(v1.y-v0.y)*(v2.y-v0.y))/(mag(v1-v0)*mag(v2-v0))); if(fTheta < fAngle) return true; return false; } That''s in 2D because I wrote a simple test app that fills all points with a color depending on whether they''re in the triangle. Email me if you want to see it.

Share this post

Link to post
Share on other sites
it looks like u already know the rayintersection test...
if that test resolves in a collision, see if the begin point and the end point of the vertex are on the same side of the plane through the triangle...if so, there''s no collision...
if not so, there''s a collision...

(u can do that easily with the plane equitation)

does that make sense?
hope that helped,



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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!