我知道线段上的起点和终点。对于此示例,假设线段的距离为 5。现在我想知道与终点的距离为 3 的点。知道如何用数学来做到这一点吗?
起点 (0,0)
终点 (0,5)
我想找到的点 (0,2)
最佳答案
如果您的积分是 (x1, y1)
和 (x2, y2)
,并且您想找到点 (x3, y3)
即 n
距离点 2 的单位:
d = sqrt((x2-x1)^2 + (y2 - y1)^2) #distance
r = n / d #segment ratio
x3 = r * x2 + (1 - r) * x1 #find point that divides the segment
y3 = r * y2 + (1 - r) * y1 #into the ratio (1-r):r
关于math - 在直线上找一个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1934210/