# Triangle vs Triangle 2D

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

## Recommended Posts

Hi, i have this problem: I am trying to implement collision detection of triangle vs triangle (2D) by making 3 planes of 1 triangle and testing another triangles vertices against that planes. If i found one plane that has all of the vertices on the side of normal (outside of triangle) then i consider that triangles are not colliding. This works fine, except for this: (ignore the yellow line) the white lines are the planes as you can see the smaller's triangle's vertices are in back of all 3 planes, and triangles don't intersect... Well, maybe i didn't understood the algorithm or something, how can i fix this if possible, or do i need to pick another algorith(links would be great)? What are common ways to solve triangle vs triangle collision detection? I was thinking about doing segments out of triangles and testing their collisions, but after that i need to check for triangle inside triangle, but i think it's going to be slower than the algorithm above. Well, anyway, your thoughts how to solve this...

##### Share on other sites
You're almost there - you just need to check the vertices of each triangle against the planes of the other, instead of just one. This is basically the separating axis theorem - here is a paper on the subject.

##### Share on other sites
and a nice easy to follow web page here

##### Share on other sites
After writing this post i went to bed. In bed i thought:
"Sh*t! I need to check the other triangle too! :))))"

Quote:
 and a nice easy to follow web page here

I have seen that web already :) thnx anyway

Quote:
 You're almost there - you just need to check the vertices of each triangle against the planes of the other, instead of just one. This is basically the separating axis theorem - here is a paper on the subject.

I hate papers! Why? Because i don't understand equations written in them, because of strange(unknown to me) symbols in papers.(I am 19years old, I just finished Secondary School, in school they only teach Vectors, i had to learn matrices,planes,quaternions,ray's by myself, so i dont understand those often found in papers)

r++ for both of you :)

aaa, and 1 more question,
what are other common ways of solving triangle vs triangle collision detection?

##### Share on other sites
a couple ways to go about it. Test each edge of each triangles against the edge on the other triangles, or edges against triangles directly (which takes care of one triangle being inside another triangle, but the edges not actually intersectring), basic clipping routines (cohen-sutherland clipping, using one triangle as the clipping region), or the SAT algorithm.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634135
• Total Posts
3015752
×