Tri Tri Intersection ?

Blitz3D Forums/Blitz3D Programming/Tri Tri Intersection ?

jfk EO-11110(Posted 2007) [#1]
Is there some sourcecode for a (2D) Triangle to Triangle intersection test?

Or what is in your opinion the best way to align 2 triangles onscreen with minimal space requirement?


jfk EO-11110(Posted 2007) [#2]
haha, probably I will simply create two masked images and use ImagesCollide <:o)


b32(Posted 2007) [#3]
I don't know any tri tri intersection code, but do you mean side-by-side alignment ? I wrote a routine a while back that could do something like that. If you give it the coords for two points, and the length of the three splines, it calculates where the 3rd point should be. There are two possibilities, so I used a forth point as a reference:



jfk EO-11110(Posted 2007) [#4]
Thanks, IŽll check this out.


Beaker(Posted 2007) [#5]
Can't you just do 3 ray-to-triangle2 tests (one ray for each triangle1 edge)? Move triangle1 away from triangle2 by the amount of intersection?


jfk EO-11110(Posted 2007) [#6]
Maybe yes, but I guess this wouldn't recognize an enclosed triangle?


Beaker(Posted 2007) [#7]
Or maybe test if each corner is inside the triangle (both ways).


Rob Farley(Posted 2007) [#8]
I think Beaker's solution sounds pretty straight forward... especially if you had a function to detect if a point was inside a triangle...

Hmm... if only


jfk EO-11110(Posted 2007) [#9]
Hmmmmmmmmmmm...

wait a minute - what if they are intersecting, but there's no vertex inside the other tri? Like when two lines are crossing two lines of the 2nd tri.

Well, Beakers first suggestion with 3* ray vs tri sounds good. Then I still have to ckeck if a tri is enclosed (all 3 vertices within Tri 1), by using Robs code. Wrapped in a neat function this may be pretty good.