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

  return false;
}
// point q lies on line segment 'pr' 
point q lies on line segment 'pr'
point q lies on line segment ' pr '
function onSegment(p, q, r)
{
  if (q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) &&
    q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y))
    return true;
  return false;
}
function onSegment ( p , q , r ) { if ( q . x <= Math . max ( p . x , r . x ) && q . x >= Math . min ( p . x , r . x ) && q . y <= Math . max ( p . y , r . y ) && q . y >= Math . min ( p . y , r . y ) ) return true ; return false ; }
point q lies on line segment 'pr'
point q lies on line segment ' pr '