Find the Closest intersection point in plan

前端 未结 3 1677
遥遥无期
遥遥无期 2021-02-09 09:50

I was asked following question in interview recently:

Let suppose you have, following grid on Cartesian coordinate system ( Quadrant I).

o - x - x - x          


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-02-09 10:21

    This will probably give you more of an approximate than the correct answer. But maybe you can try some sort of clustering (see medical image processing)

    What if you project all points onto the Y axis:

     3*
     4*
     3*
    

    Then project onto the X axis:

    2* 2* 2* 2* 2*
    

    Legend: 3* means 3 people at this coordinate on the axis

    Now find the median also using the weights (weight @location = how many people at that location on axis)

    If you find the median for both axis then you could take the meeting points as (medianX, medianY).

    You could get the correct closest point if when you calculate median on one axis, you also make sure to minimize distance by calculating the median of the other axis. This latter case is harder.

提交回复
热议问题