How to find the third coordinate of a right triangle given 2 coordinates and lengths of each side
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}{\sqrt{1+m_B^2}},\frac{m_B}{\sqrt{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