Finding Third Points of triangle using other two points with known distances [closed]

限于喜欢 提交于 2019-12-02 02:51:24

We can solve this using a bit of trigonometry:

Cosine theorem (phi is the inner angle at the first point):

d3^2 = d1^2 + d2^2 - 2 d1 d2 cos phi
cos phi = (d1^2 + d2^2 - d3^2) / (2 d1 d2)

For a given cosine, we can calculate the according sine:

cos^2 phi + sin^2 phi = 1
sin phi = +- sqrt(1 - cos^2 phi)

So there are two solutions for the angle at the first point. One positive and one negative.

We can use this angle to rotate the difference vector diff1 = (x2 - x1, y2 - y1) to point towards the third point:

P3 = P1 + d2/d1 * / cos phi * (x2 - x1) - sin phi * (y2 - y1))
                  \ sin phi * (x2 - x1) + cos phi * (y2 - y1))

There is no need to calculate the actual angle, because we just need its sine and cosine. Put both calculated values for the sine in and you get two possible points for P3.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!