如何找到给定变量的第三点坐标

How to find third point coordinates given variables

我需要 ruby 中的一个小算法来找到 x 和 y。

slope = Math.tan(ang)
x = (dInf - dSup)/(2 * slope)
y = x*slope + (dSub/2)

Y 可以是正数也可以是负数,具体取决于您想要哪个角。

这样做的原因是顶部斜线的方程式是: Y = Sin(ang) * X + (dSup/2)

所以问题就变成了"at what X do we get a Y = dInf/2"

代入 Y:Sin(ang) * X + (dSup/2) = dInf/2

重新排列:X = (dInf - dSup) / 2 Sin(ang)