如何检查一个点是否在由另外两个点定义的直线上?



我正在用python写一个程序,需要确定一个点是否在由另外两个点组成的无限线上。我发现了许多其他关于线段的问题,但我需要一条无限的线。

您可以尝试这样做:

# positive when P is on the left of oriented line AB, 
# neutral when P lies on AB,
# negative when P is on the right of oriented line AB
def half_space(pX, pY, aX, aY, bX, bY):
return (bX - aX)*(pY - aY) - (bY - aY)*(pX - aX)

相关内容

最新更新