[dirGames-L] point in triangle
Wouter Visser
wouter at nuvorm.nl
Tue Dec 16 14:03:52 EST 2003
Hi peolpe,
had a simple handler for testing point in triangle wich i wanted to share
with you.
I don't know if it fits the needs as i didn't follow the discussion much.
I hope this contributes.
Kind regards,
Wouter
nuvorm.nl
on point_in_triangle me, x0, y0,x1,y1,x2,y2,x3,y3
--x0,y0 = point to be tested
--x1,y1 en x2,y2 en x3,y3 = points of triangle
--if b0 = 0 dan all points are on one line, call a quit
b0 = ((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1))
b1 = (((x2 - x0) * (y3 - y0) - (x3 - x0) * (y2 - y0)) / (b0*1.0))
b2 = (((x3 - x0) * (y1 - y0) - (x1 - x0) * (y3 - y0)) / (b0*1.0))
b3 = 1 - b1 - b2
If b1 > 0 And b2 > 0 And b3 > 0 Then
return "inside"
Else
return "outside"
End If
end
More information about the dirGames-L
mailing list