pointInTriangle function

dynamic pointInTriangle(
  1. dynamic ax,
  2. dynamic ay,
  3. dynamic bx,
  4. dynamic by,
  5. dynamic cx,
  6. dynamic cy,
  7. dynamic px,
  8. dynamic py,
)

Implementation

pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
  return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
      (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
      (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
}