# How to find the third coordinate of a right triangle given 2 coordinates and lengths of each side

 p2
|\
|b\
|  \
A|   \C
|    \
|c___a\
p1  B   p3


If given point p1 & p2, side A & B how would you find point p3? I know given this information you can find side C and all of the interior angles.

side C:
C^2 = A^2 + B^2

angle c = 90
angle a = A/SIN(a) = C/SIN(c)
angle b = 180 - (a+c)


But after this, I am trying to find point p3 and I am not sure what direction to take. Any help would be appreciated.

Edit: The triangle will not necessarily be facing upwards along an axis, it will be rotated at angles depending on exterior variables such as position of a mouse on the computer screen.

-
You know the length of side $B$, and it seems one leg of your right triangle is horizontal. Thus, just add that length to the $x$-coordinate of p1... –  Ｊ. Ｍ. Sep 15 '11 at 16:47
the triangle is going to be rotated at random angles that solution wont work. –  Hussein Sabbagh Sep 15 '11 at 16:49
Then rotate the coordinates such that side $B$ is horizontal. You know the slope of side $A$, you can then derive the appropriate rotation matrix... –  Ｊ. Ｍ. Sep 15 '11 at 16:51
Knowing points p1 and p2 you can find the line between them. You need the perpendicular to this line through point p1 and distance B along it. You may not know which direction to take, because given the information you have presented you can take either direction on the perpendicular. –  Mark Bennet Sep 15 '11 at 16:59

Let the coordinates of $p_n$ be $(x_n,y_n)$. Then the slope of $A$ is $m_A=\frac{y_2-y_1}{x_2-x_1}$. The slope of $B$ is $m_B=\frac{-1}{m_A}=\frac{x_1-x_2}{y_2-y_1}$. Then $p_3=p_1\pm B(\frac{1}{1+m_B^2},\frac{m_B}{1+m_B^2})$ where the sign ambiguity corresponds to two orientations of the triangle. I have ignored issues when the sides are vertical or horizontal, which can lead to division by zero

-
+1 correct answer. –  Jim Thio Jan 27 '12 at 8:14
I could very well be wrong, but shouldn't it be $p_3=p_2\pm B(\frac{1}{1+m_B^2},\frac{m_B}{1+m_B^2})$ ? –  JohnB 14 hours ago
@JohnB: No, because side B is attached to $p_1$, so we reference $p_3$ to it. –  Ross Millikan 7 hours ago