Finding coordinates of the third point of a triangle from given?

860 Views Asked by At

In ABC triangle we know the coordinates of A and B vertices. We also know lengths of 2 edges shown in the picture and the third edge is calculatable. What is the most efficient functon to find x3 and y3?
Note: I guess there is 2 possible C points. (Don't know how this effects)
Note(2): This question is also similar to finding intersection points of 2 circles.

enter image description here

1

There are 1 best solutions below

0
On

You already said you can compute it as the intersection of two circles. Here's another way, assuming both sides have length $a$ as in the picture:

Find the midpoint $M$ of $AB$ as $$M = (m_1, m_2) = ( (x_1+x_2)/2, (y_1+y_2)/2).$$ Compute a normal vector to the side $AB$ (orthogonal to $AB$) as: $$n = (n_1, n_2) = (-(y_2-y_1), (x_2-x_1))$$ The normal $n$ has by construction the length $AB$. Find it via Pythagoras $$ |n| = \sqrt{n_1^2+n_2^2}.$$ To find the point C, you have to go from $M$ in the direction of $n$ by a distance which equals the height of $C$ with respect to the side $AB$. This height $h$ is given by Pythagoras again: $$a^2=h^2+\left(\frac{|AB|}{2}\right)^2=h^2+\left(\frac{|n|}{2}\right)^2$$ Then, you get $C$ as: $$C = M \pm \frac{h}{|n|}n = (m_1 \pm \frac{h}{|n|}n_1, m_2 \pm \frac{h}{|n|}n_2)$$