# Collision detection between triangle and polygon

I have some difficulties to understand how to be sure if there is a collision between a space ship (black) and an asteroid (in blue). A space ship is placed on a case and an asteroid comes from the right, like on the image.

Also Y1 != Y2, there are not exactly on the same line. What is the best way, in that case, to detect if there is a collision ? Is AABB collision the correct algorith I need ?

• Hi Asm, are you using the shapes of the objects as the colliders? If you are then you can split your hexagon into 2 triangles and a square to simplify your collision algorithm, or are you just checking for a point to point collision? Commented Dec 19, 2014 at 0:12
• Hi Matthew, thank you for your comment. I confirm that I'm using the shapes of the objects. If an asteroid touch the point (X2, Y2) of the triangle, the space ship will be erased. I have got severeal lines and columns and many objects on my grid.
– Asm
Commented Dec 19, 2014 at 0:18
• possible duplicate of Triangle-triangle continuous collision detection Commented Dec 19, 2014 at 0:30
• You probably want the separation algorithm, but are you aware that most games use simple hitboxes rather than complex polygon collision detection? Commented Dec 19, 2014 at 2:32

To complete @user55564 I give some more information about line segments intersection.