Function isPointWithinBounds

Returns whether q lies inside the segment/rectangle defined by p and r. This is an approximation to "does q lie on a segment pr" check.