Determine if point is within bounding box

后端 未结 7 1922
没有蜡笔的小新
没有蜡笔的小新 2020-12-08 11:02

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

My point is 48.847172 , 2.386597.

Boundingbox:

    \"48.7998602295\",
           


        
相关标签:
7条回答
  • 2020-12-08 11:59

    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.

    0 讨论(0)
提交回复
热议问题