The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
collision with triangles
cndr.mike


Joined: 20 Apr 2010
Posts: 6
what technique do you use for triangle on triangle collision detection?
gameEater63


Joined: 26 Mar 2012
Posts: 3
Location: Iran
You can use some geometric support. A triangle can be represented
by a set three points vertices(vertices), and each point contains two elements x,y. Each two points
form a section, and each section implies a line. You need to solve
these linear problems:
1. Get two points and make a line. A line can be modeled by a vector and a point
2. Get two lines and check if they cross each other, or have a common point.
You should solve a linear system
3. Telling if a given point belongs to a given section, whose line
already has passed (owned) that point.

Now two sections collide if their lines cross, and the common point belongs to
both the sections. Two triangles collide if and only if any section of one, collide
with any section of the other.