math - 在直线上找一个点

标签 math opengl linear-algebra

我知道线段上的起点和终点。对于此示例,假设线段的距离为 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/

相关文章:

algorithm - log(n^c) 是否等于 O(log(n))

java - 是地球表面上多边形内部或外部的点

python - 舍入系统 RAM 和 HDD 字节,向上到最接近的千兆字节。 Python

c - 在 opengl 中纹理映射一个圆锥体

python - numPy 中的意外特征向量

algorithm - 如何将一条线反射到另一条线上

math - 平面上的 3d 正交投影

c++ - 'make' 的输出是共享对象,而不是可执行文件

opengl - glGetUniform 有多大用处?

python - 在一组固定的元素上生成特定秩的 "random"矩阵