pointInTriangle function

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

Implementation

bool pointInTriangle(double ax, double ay, double bx, double by, double cx, double cy, double px, double 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;
}