# Find right angle coordinates in a right triangle (Matlab)

Is is possible to find the coordinates of the right angle (C) in a right triangle, knowing the coordinates and rads of the other two angles (A,B), all sides length?

Image

• There are infinitely many possible positions of C, all lying on a circle with diameter AB.
– user436658
Jul 5, 2017 at 8:12

See e.g. Thales' theorem why this problem has many solutions.

We know that, in a right triangle, $a^2+b^2=c^2$

We can write the lengths of each side in terms of their coordinates:

\begin{align}\overrightarrow{AB}&=\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}\\ \overrightarrow{BC}&=\sqrt{(x_2-X)^2+(y_2-Y)^2}\\ \overrightarrow{CA}&=\sqrt{(X-x_1)^2+(Y-y_1)^2}\end{align}

So now we can say that \begin{align}\overrightarrow{AB}^2&=\overrightarrow{BC}^2+\overrightarrow{CA}^2\\ \sqrt{(x_1-x_2)^2+(y_1-y_2)^2}^2&=\sqrt{(x_2-X)^2+(y_2-Y)^2}^2+\sqrt{(X-x_1)^2+(Y-y_1)^2}^2\\ (x_1-x_2)^2+(y_1-y_2)^2&=(x_2-X)^2+(y_2-Y)^2+(X-x_1)^2+(Y-y_1)^2\\ {x_1}^2-2x_1x_2+{x_2}^2+{y_1}^2-2y_1y_2+{y_2}^2&={x_1}^2-2x_1X+{x_2}^2-2x_2X\\ &\color{white}=\qquad+{y_1}^2-2y_1Y+{y_2}^2-2y_2Y+2X^2+2Y^2\\ -2x_1x_2-2y_1y_2&=-2x_1X-2x_2X-2y_1Y-2y_2Y+2X^2+2Y^2\\ -x_1x_2-y_1y_2&=-x_1X-x_2X-y_1Y-y_2Y+X^2+Y^2\\ -x_1x_2-y_1y_2&=X^2-X(x_1+x_2)+Y^2-Y(y_1+y_2)\\ -x_1x_2-y_1y_2&=\left(X-\frac{x_1+x_2}{2}\right)^2-\left(-\frac{x_1+x_2}{2}\right)^2\\ &\color{white}=\qquad+\left(Y-\frac{y_1+y_2}{2}\right)^2-\left(-\frac{y_1+y_2}{2}\right)^2\\ -x_1x_2-y_1y_2&=\left(X-\frac{x_1+x_2}{2}\right)^2-\frac{{x_1}^2+2x_1x_2+{x_2}^2}4\\ &\color{white}=\qquad+\left(Y-\frac{y_1+y_2}{2}\right)^2-\frac{{y_1}^2+2y_1y_2+{y_2}^2}4\\ \left(X-\frac{x_1+x_2}{2}\right)^2+\left(Y-\frac{y_1+y_2}{2}\right)^2&=\frac{{x_1}^2+2x_1x_2+{x_2}^2}4+\frac{{y_1}^2+2y_1y_2+{y_2}^2}4-x_1x_2-y_1y_2\\ &=\frac 14\left({x_1}^2-2x_1x_2+{x_2}^2+{y_1}^2-2y_1y_2+{y_2}^2\right)\end{align}

We can therefore see that the solutions to $(X,Y)$ fall on the circle with centre $$\left(\frac{x_1+x_2}2,\frac{y_1+y_2}2\right)$$

which we note is the midpoint of $AB$

It also has a radius$$\sqrt{\frac 14\left({x_1}^2-2x_1x_2+{x_2}^2+{y_1}^2-2y_1y_2+{y_2}^2\right)}=\frac 12 \sqrt{(x_1-x_2)^2 + (y_1-y_2)^2}$$

which we note is half the length of ${AB}$

In conclusion, there are infinitely many points satisfying the criteria which lie on the circle which has the diameter $AB$