point in triangle 2003-12-17 - By Wouter Visser
Back 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
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ dirGames-L mailing list - dirGames-L@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames-l
Earn $52 per hosting referral at Lunarpages.
|
|