Skip to main content
GameDev.net gamedev.net
🔒 Locked

Triangle vs Triangle 2D

Started by Jnz86 Aug 4, 2005 at 4:04 PM 3 replies 1k views
Original Post
Jnz86
Jnz86
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: Free Image Hosting at www.ImageShack.us (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...
Zakwayda
Zakwayda
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.
Structure
Structure
and a nice easy to follow web page here
[happy coding]
Jnz86
Jnz86
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?
oliii
oliii
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.
Everything is better with Metal.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.