简体   繁体   English

Python - 三角学,三点之间等角的中点

[英]Python - trigonometry, mid point for equal angles between three points

I'm kinda stuck with some basic trigonometry.我有点坚持一些基本的三角学。

I have three points A, B and C defined by some height value and distance between A and C.我有三个点 A、B 和 C,由 A 和 C 之间的一些高度值和距离定义。 I usually take B as mid-point distance between A and C.我通常将 B 作为 A 和 C 之间的中点距离。 The case is like this:情况是这样的:

图片

As C goes lower, the angle at C gets narrower if B stays in place.随着 C 变低,如果 B 保持在原位,C 处的角度会变窄。 How to calculate B such that angles at A and C are always the same.如何计算 B 使得 A 和 C 处的角度始终相同。 B always lies on the line 90 degrees to parallel lines where A and C are. B 始终位于与 A 和 C 所在的平行线成 90 度的线上。

I think what you're asking is this:我想你要问的是:

With point A fixed, find point C such that the angles shown are equal.固定 A 点,找到 C 点,使所示角度相等。

Let the horizontal line C sits on be the line y = 0. Let the vertical lines that points A and B sit on be x = a and x = b, respectively.设水平线 C 位于线 y = 0 上。设点 A 和 B 所在的垂直线分别为 x = a 和 x = b。 So, given By, we must find Cx such that atan((Cx - a) / Ay) = atan((b - Cx) / By).因此,给定 By,我们必须找到满足 atan((Cx - a) / Ay) = atan((b - Cx) / By) 的 Cx。 Because numerators and denominators have been chosen to be positive and we know the angles are acute we can know that the arctangent is a bijection and the arctangents are equal only if the arguments are equal:因为分子和分母被选为正数,并且我们知道角度是锐角,所以我们可以知道反正切是双射,并且仅当 arguments 相等时,反正切才相等:

(Cx - a) / Ay = (b - Cx) / By
Cx/Ay - a/Ay = b/By - Cx/By
Cx/Ay + Cx/By = a/Ay + b/By
Cx(1/Ay + 1/By) = (a/Ay + b/By)
Cx = (a/Ay + b/By) / (1/Ay + 1/By)
   = (a/Ay + b/By) / [(Ay + By)/(AyBy)]
   = (AyBy)(a/Ay + b/By) / (Ay + By)
   = (aBy + bAy) / (Ay + By)

Let's check the result.让我们检查一下结果。 If Ay = By - that is, A and B are at the same height - we'd expect C to be right in the middle, by symmetry.如果 Ay = By - 即 A 和 B 处于相同高度 - 我们预计 C 正好在中间,对称。 Let Ay = By = h.令 Ay = By = h。 Then然后

Cx = (aBy + bAy) / (Ay + By)
   = (ah + bh) / (h + h)
   = (a + b) / 2

We get Cx = (a + b) / 2, as required.根据需要,我们得到 Cx = (a + b) / 2。 Now, imagine that By >> Ay;现在,想象一下 By >> Ay; that is, B is much farther away than A is from the horizontal line on which C lies.也就是说,B 比 A 离 C 所在的水平线远得多。 We'd expect Cx to approach a, the x-value of the vertical line on which point A lies.我们期望 Cx 接近 a,即 A 点所在的垂直线的 x 值。

Cx = (aBy + bAy) / (Ay + By)
   ~ aBy / By
   ~ a

Note that we dropped the low-order terms Ay and bAy since these were much less than the terms containing the large value By.请注意,我们删除了低阶项 Ay 和 bAy,因为它们远小于包含大值 By 的项。 This checks out.这检查出来。 Finally, imagine Ay >> By.最后,想象一下 Ay >> By。 Then we expect Cx to approach b:然后我们期望 Cx 接近 b:

Cx = (aBy + bAy) / (Ay + By)
   ~ bAy / Ay
   ~ b

Again, we find that our formula matches our intuition.同样,我们发现我们的公式符合我们的直觉。 Therefore, for points因此,对于点

A = (a, Ay)
B = (b, By)

We find that the point C must be我们发现点 C 一定是

C = ((aBy + bAy) / (Ay + By), 0)

In order that the angles be the same.为了使角度相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM