Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if point is within bounding box

Tags:

How would you determine if a given point is within the bounding box?

My point is 48.847172 , 2.386597.

Boundingbox:

    "48.7998602295",     "48.8198640442",     "2.46138595581",     "2.48138619423" 
like image 235
viniciusmo Avatar asked Aug 18 '13 04:08

viniciusmo


People also ask

How do you find bounding box area?

Same way you compute the area of any other rectangle, by multiplying the width by the height.

How do you find the bounding box of a triangle?

To find the bounds of the box containing a triangle, you simply need to find the smallest and largest x and y coordinates from the three coordinates making up the triangle.

What are bounding coordinates?

the limits of coverage of a data set expressed by latitude and longitude values in the order western-most, eastern-most, northern-most, and southern-most.


1 Answers

Do just as usual:

if( bb.ix <= p.x && p.x <= bb.ax && bb.iy <= p.y && p.y <= bb.ay ) {     // Point is in bounding box } 

bb is the bounding box, (ix,iy) are its top-left coordinates, and (ax,ay) its bottom-right coordinates. p is the point and (x,y) its coordinates.

like image 96
Mario Rossi Avatar answered Sep 30 '22 21:09

Mario Rossi