function IsPointInTriangle takes real x1, real y1, real x2, real y2, real x3, real y3, real x, real y returns boolean
local boolean b = (x2 - x) * (y3 - y2) - (x3 - x2) * (y2 - y) >= .0
return ((x1 - x) * (y2 - y1) - (x2 - x1) * (y1 - y) >= .0) == b and b == ((x3 - x) * (y1 - y3) - (x1 - x3) * (y3 - y) >= .0)
endfunction