简体   繁体   中英

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. I usually take B as mid-point distance between A and C. The case is like this:

图片

As C goes lower, the angle at C gets narrower if B stays in place. How to calculate B such that angles at A and C are always the same. B always lies on the line 90 degrees to parallel lines where A and C are.

I think what you're asking is this:

With point A fixed, find point C such that the angles shown are equal.

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. So, given By, we must find Cx such that atan((Cx - a) / Ay) = atan((b - Cx) / By). 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:

(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. Let Ay = By = h. Then

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

We get Cx = (a + b) / 2, as required. Now, imagine that By >> Ay; that is, B is much farther away than A is from the horizontal line on which C lies. We'd expect Cx to approach a, the x-value of the vertical line on which point A lies.

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. This checks out. Finally, imagine Ay >> By. Then we expect Cx to approach 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 = ((aBy + bAy) / (Ay + By), 0)

In order that the angles be the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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