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);
}