Dividing two sets of points using a straight line

ⅰ亾dé卋堺 提交于 2021-02-08 03:04:56

问题


Suppose I have two sets of points, A and B, in 2D space. I want to know if there exists a single straight line that will have all points of A on one side and all points of B on the other, and if possible, find one such line. I found this question while searching but it is more of a "line of best fit" problem.

Intuitively, I feel like it is a question regarding cross-products but I can't figure out how it can be done.


回答1:


You could find the convex hull for each set of points, and then follow the procedure in this question to determine if they intersect (and return a dividing line if they don't):

How do I determine if two convex polygons intersect?




回答2:


In machine learning, the classical solution to this is the Support Vector Machine (SVM). It will generalize to N dimensions, find a best approximation in case there's no solution, and if there are multiple solutions it will optimize the margins left and right of the divider. Possibly overkill for you then, but there are multiple implementations already available. (E.g. OpenCV)



来源:https://stackoverflow.com/questions/25836565/dividing-two-sets-of-points-using-a-straight-line

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