Finding Top Left and Bottom Right Points (C++)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 05:18:24

问题


I'm looking for some help with a project I'm working on.

What I'm doing is a polygon approximation algorithm. I've got all of the points of my boundary, but in order to start the algorithm, I need to find the top left and bottom right points from the set of points. All of the points are stored in a structure array that has the x and y coordinates of each point. Any ideas on an easy way to loop through the array of points?

Any help would be greatly appreciated. If you need more information, just ask and I'll provide all I can.


回答1:


Based on your comment that bottom left is min(x+y) and top right is max(x+y)

Top left: min(x+max(y)-y)

Bottom right: max(max(x)-x+y)

Where the inner max is a constant.

Though this may not always give a result that agrees with your eyes.

Alternative metrics can be constructed based on the distance from the corners of the bounding box of your object, or the square of the distance, etc.

Another technique is to translate the polygon around the origin and then top left is the point furthest from the origin but in the top left quadrant... That gives a whole heap of choices as to where to put (0,0) could be average of all, could be weighted average based on some rule, etc. lot of variability in how you pick that, each may give results that differ for a very small number if polygons from what the eye would pick.

Finally you could always train a neural network to pick the answer.... That might result in something that is (insert confidence limits from training)% likely to give an answer you agree with... But you and I may disagree




回答2:


Top left: min(x+max(y)-y)

Bottom right: min(max(x)-x+y)

Where the inner max is a constant.



来源:https://stackoverflow.com/questions/13507550/finding-top-left-and-bottom-right-points-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!