找到垂直于给定线的点

发布于 2024-11-19 11:47:43 字数 1459 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羅雙樹 2024-11-26 11:47:43

让我将您的问题改写为我的想法,然后回答。

给定点 A = (x1, y1)B = (x2, y2)。您想要找到一个点 Z = (x3, y3),使得 AZ 垂直于 AB,并且 BZ > 长度为 h

AB的向量是v = (x2 - x1, y2 - y1)。一个易于计算的垂直向量是 w = (y2 - y1, x1 - x2) 。穿过 A 并垂直于 AB 的线表示为 F(s) = A + s*w = (x1 + s*(y2 - y1) ), y1 + s*(x1 - x2)) 因为 s 范围超过实数。因此,我们需要选择一个值 s,使得 F(s) 距离 Bh

根据毕达哥拉斯定理,从 F(s)B 的长度的平方始终是到 F(s)< 的距离的平方/code> 到 A,加上从 AB 距离的平方。从中我们得到了我们想要的混乱表达式:

h**2 = s**2 * ((y2 - y1)**2 + (x1-x2)**2) + ((x1 - x2)**2 + (y1 - y2)**2))
     = s**2 * ((x1 - x2)**2 + (y1 - y2)**2)) + ((x1 - x2)**2 + (y1 - y2)**2))
     = (s**2 + 1) * ((x1 - x2)**2 + (y1 - y2)**2))

(s**2 + 1) = h**2 / ((x1 - x2)**2 + (y1 - y2)**2))

s**2  = h**2 / ((x1 - x2)**2 + (y1 - y2)**2)) - 1

s = sqrt(h**2 / ((x1 - x2)**2 + (y1 - y2)**2)) - 1)

现在将 s 的表达式插回到 F(s) = (x1 + s*(y2 - y1), y1 + s*( x1 - x2)) 并且你得到了你的观点Z。另一个可能的答案是另一侧的距离相同。

Let me rephrase your question to be what I think it is, then answer it.

You're given points A = (x1, y1) and B = (x2, y2). You want to find a point Z = (x3, y3) such that AZ is perpendicular to AB, and BZ has length h.

The vector from A to B is v = (x2 - x1, y2 - y1). An easy to calculate perpendicular vector to that one is w = (y2 - y1, x1 - x2). The line crossing through A which is perpendicular to AB is represented by F(s) = A + s*w = (x1 + s*(y2 - y1), y1 + s*(x1 - x2)) as s ranges over the real numbers. So we need to pick a value s such that F(s) is h away from B.

From the Pythagorean theorem, the square of the length from F(s) to B is always going to be the square of the distance from F(s) to A, plus the square of the distance from A to B. From which we get the messy expression that we want:

h**2 = s**2 * ((y2 - y1)**2 + (x1-x2)**2) + ((x1 - x2)**2 + (y1 - y2)**2))
     = s**2 * ((x1 - x2)**2 + (y1 - y2)**2)) + ((x1 - x2)**2 + (y1 - y2)**2))
     = (s**2 + 1) * ((x1 - x2)**2 + (y1 - y2)**2))

(s**2 + 1) = h**2 / ((x1 - x2)**2 + (y1 - y2)**2))

s**2  = h**2 / ((x1 - x2)**2 + (y1 - y2)**2)) - 1

s = sqrt(h**2 / ((x1 - x2)**2 + (y1 - y2)**2)) - 1)

Now plug that expression for s back into F(s) = (x1 + s*(y2 - y1), y1 + s*(x1 - x2)) and you have your point Z. And the other possible answer is the same distance on the other side.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文