当所有4条线长都已知时,如何推断梯形的最后两个坐标的可能值 [英] How to infer the possible values for the final two coordinates of a trapezoid when all 4 line lengths are known
问题描述
我有一个梯形,在那里我知道所有4条线的长度,而且我知道两个角的坐标.如何在JavaScript中找到其余两个角的坐标?
I have a trapezoid where I know the length of all 4 lines, and I know the coordinates of two of the corners. How do I find the coordinates of the remaining two corners in JavaScript?
注意:所有4条线的长度都不同,即这不是等腰梯形
NOTE: All 4 lines are of different length, ie this is not an isosceles trapezoid
这里有一个小图,以防万一:
Here's a little diagram in case it helps:
L3
D ____ C
/ \
L4 / \ L2
--------
A L1 B
我知道A和B的坐标,以及L1,L2,L3和L4的长度(都不同).我只需要获取D和C的所有可能的坐标集即可!
I know the coordinates of A and B, and the length of L1, L2, L3, and L4 (Which are all different). I just need to get all of the possible sets of coordinates for D and C!
推荐答案
将垂直线从点C和D拖放到AB线以找到它们在AB的E和F上的投影:
Drop vertical lines from points C and D to the line AB to find their projections on E and F on AB:
现在,AED和BFC是具有相同高度的直角三角形.我们将高度称为 h
.从毕达哥拉斯:
Now AED and BFC are right triangles with the same height. Let's call the height h
. From Pythagoras:
a² + h² = L4² and b² + h² = L2²
从另一个方程中减去一个方程:a²-b²=L4²-L2²
Subtracting one equation from the other you get: a² - b² = L4² - L2²
还可以将L1分为段AE,EF和FB,因此L1的长度必须为:
Also you can divide L1 into segments AE, EF, and FB, so the length of L1 must be:
L1 = a + L3 + b => a + b = L1 - L3
因此,我们在a和b中有一个方程组:
Therefore we have a system of equations in a and b:
a² - b² = L4² - L2²
a + b = L3 - L1
使用a²-b²=(a + b)(a-b)
的事实和上面的等式,您将得到:
Using the fact that a² - b² = (a+b)(a-b)
and the above equation, you get:
(L3 - L1)(a - b) = L4² - L2² => a - b = (L4² - L2²)/(L3 - L1)
(请注意,L1和L3不能相等.如果L1 = L3,则解数是无限的.)
(Note that L1 and L3 can not be equal. If L1 = L3, there is an infinite number of solutions.)
因此等式简化为:
a + b = L3 - L1
a - b = (L4² - L2²)/(L3 - L1)
解决方案是:
a = (L3 - L1 + (L4² - L2²)/(L3 - L1)) / 2
b = (L3 - L1 - (L4² - L2²)/(L3 - L1)) / 2
梯形的高度为:
h = sqrt(L4² - a²) = sqrt(L2² - b²)
您现在可以使用 a
求解A点的角度,并使用 b
求解B点的角度,然后使用它们来计算C和C的坐标.D.或者您可以直接使用 a
, b
和 h
.
You could now use a
to solve for the angle at point A and b
to solve the angle at point B, and use them to calculate the coordinates for C and D. Or you can use a
, b
, and h
directly.
例如:假设A在原点(0,0),而B在(L1,0).那么这两种解决方案是:
For example: suppose A is at the origin (0,0) and B is at (L1, 0). Then the two solutions are:
- C位于
(a,h)
,而D位于(L1-b,h)
- C位于
(a,-h)
,D位于(L1-b,-h)
- C is at
(a, h)
and D is at(L1 - b, h)
- C is at
(a, -h)
and D is at(L1 - b, -h)
这篇关于当所有4条线长都已知时,如何推断梯形的最后两个坐标的可能值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!