onSegment function

dynamic onSegment(
  1. dynamic p,
  2. dynamic q,
  3. dynamic r
)

Implementation

onSegment(p, q, r) {
  return q.x <= Math.max<num>(p.x, r.x) &&
      q.x >= Math.min<num>(p.x, r.x) &&
      q.y <= Math.max<num>(p.y, r.y) &&
      q.y >= Math.min<num>(p.y, r.y);
}