用直线划分两组点 [英] Dividing two sets of points using a straight line
问题描述
假设我在2D空间中有两组点A和B.我想知道是否存在一条直线,该直线在一侧将具有A的所有点,而在另一侧将具有B的所有点,并且如果可能的话,找到一条这样的线.我发现这个问题,但它更像是最适合行"问题.
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.
推荐答案
您可以找到每组点的凸包,然后按照此问题中的步骤确定它们是否相交(如果它们相交,则返回一条分界线不要):
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):
这篇关于用直线划分两组点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!