Saturday, June 3, 2017

Find if a point is inside of a rectangle

Test if point is within the  rectangle with corners b - c
Usage:
 


echo( InRect([1,1],[0,0],[2,3]));
echo( InRect([3,1],[0,0],[2,3]));

 function InRect(point, b, c)= 
   (point.x >= min(b.x, c.x) && point.x <= max(b.x, c.x)
   && point.y >= min(b.y, c.y) && point.y <= max(b.y, c.y)) ; 

No comments:

Post a Comment