gpt4 book ai didi

math - 在直线上找一个点

转载 作者:行者123 更新时间:2023-12-04 02:41:32 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com