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:
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.
发布评论
评论(1)
让我将您的问题改写为我的想法,然后回答。
给定点
A = (x1, y1)
和B = (x2, y2)
。您想要找到一个点Z = (x3, y3)
,使得AZ
垂直于AB
,并且BZ
> 长度为h
。从
A
到B
的向量是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)
距离B
为h
。根据毕达哥拉斯定理,从
F(s)
到B
的长度的平方始终是到F(s)< 的距离的平方/code> 到
A
,加上从A
到B
距离的平方。从中我们得到了我们想要的混乱表达式:现在将
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)
andB = (x2, y2)
. You want to find a pointZ = (x3, y3)
such thatAZ
is perpendicular toAB
, andBZ
has lengthh
.The vector from
A
toB
isv = (x2 - x1, y2 - y1)
. An easy to calculate perpendicular vector to that one isw = (y2 - y1, x1 - x2)
. The line crossing throughA
which is perpendicular toAB
is represented byF(s) = A + s*w = (x1 + s*(y2 - y1), y1 + s*(x1 - x2))
ass
ranges over the real numbers. So we need to pick a values
such thatF(s)
ish
away fromB
.From the Pythagorean theorem, the square of the length from
F(s)
toB
is always going to be the square of the distance fromF(s)
toA
, plus the square of the distance fromA
toB
. From which we get the messy expression that we want:Now plug that expression for
s
back intoF(s) = (x1 + s*(y2 - y1), y1 + s*(x1 - x2))
and you have your pointZ
. And the other possible answer is the same distance on the other side.