简体   繁体   English

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

[英]How can I check if a point is on a line defined by two other points?

I'm writing a program in python that needs to determine if a point is on an infinite line formed by two other points.我正在 python 中编写一个程序,该程序需要确定一个点是否在由另外两个点形成的无限线上。 I found many other questions asking about line segments, but I need an infinite line.我发现了许多其他关于线段的问题,但我需要一条无限线。

You can try something like this:你可以尝试这样的事情:

# 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您如何确定一个点位于线段上的其他两个点之间? - How can you determine a point is between two other points on a line segment? 如何检查一个点是否在一条线下方? - How can I check if a point is below a line or not ? 对于每个可能的线,由两个点到每个其他点形成的线之间的距离 - Distance between line formed by two points to every other point, for every possible line 如何从一个点画一条线到一个列表中的多个点 - How can I draw a line from one point to a list multiple points 给定一个包含 n 个点的列表,如何使用 numpy 生成一个包含从每个点到每个其他点的距离的矩阵? - Given a list of n points, how can I generate a matrix that contains the distance from every point to every other point using numpy? 点和线之间的距离(从两点开始) - Distance between point and a line (from two points) 如何在 Django 中检查两个模型是否相等? - How can I check if two models equal each other in Django? 如何检查两个给定点之间是否存在线段? - How to check if there is a line segment between two given points? 如何用两点画一条线,然后用opencv,python画线直到到达轮廓点? - How to draw a line from two points and then let the line complete drawing until reaching a contour point with opencv, python? 如何检查多边形是否包含一个点? - How can I check if a polygon contains a point?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM