How to find an arbitrarily oriented minimum bounding box in c++

后端 未结 5 723
不知归路
不知归路 2021-02-06 23:58

So let\'s say I have a list of N pairs of positive long coordinates (points).
How do I find the smallest rectangle containing all of them?
The rectangle can also have fl

5条回答
  •  死守一世寂寞
    2021-02-07 00:29

    Maybe this works for you:

    • find the center point of all your points (sum of all x / number of x's, same for y)
    • take the farthest point from the center as a corner point
    • project line through the 2nd farthest point in a 90° angle of the corner point
    • iterate over the points of the other side of the center point and find minimum

提交回复
热议问题