Determine third point of triangle when two points and all sides are known?

The distance between two points $P(p_1,p_2)$ and $Q(q_1,q_2)$ in the plane is$\sqrt{(q_1-p_1)^2+(q_2-p_2)^2}$.

Let us denote coordinates of $C$ by $(x,y)$. Then the distances between from $C$ to $A$ and from $C$ to $B$ will be $$\sqrt{x^2+y^2}=3 \Rightarrow x^2+y^2=9$$ $$\sqrt{(x-5)^2+y^2}=4\Rightarrow (x-5)^2+y^2=16$$ respectively. Substracting the first equation from the second equation we get $$(x-5)^2-x^2=7 \Rightarrow x^2-10x+25-x^2=7$$ $$\Rightarrow -10x+25=7 \Rightarrow x=\frac{-18}{-10}=\frac{9}{5}$$ Now if we substitute $x=\frac95$ into one of the above equations we get $y=\pm \frac{12}5$ So we find $(x,y)=(\frac95,\frac{12}{5})$ and $(x',y')=(\frac95,-\frac{12}{5})$.

As you see from the picture these two points are symmetric w.r.t $-x$ axis.

enter image description here


Given coordinates of $A$ and $B$ and lengths $\overline{AB}$, $\overline{AC}$ and $\overline{BC}$ we want to find coordinates of $C$. Let's assume that $A$ is at $(0,0)$ and $B$ is at $(0,\overline{AB})$ i.e. in the $y$-direction. Let's also assume that we know point $C$ is in the positive $x$-direction (there is another solution in the other direction). It should be simple to reduce a more general problem to this case. The solution is then:

$$C_y = \frac {\overline{AB}^2 + \overline{AC}^2 - \overline{BC}^2} {2\overline{AB}}$$

$$C_x = \sqrt{\overline{AC}^2 - {C_y}^2}$$

The derivation of this is given below:

Consider the triangle $ABC$ as two right angle triangles as shown:

Solution of triangle coordinates

If we call $C_x$ and $C_y$ the coordinates of $C$, then Pythagoras theorem for each of the two triangles gives:

$(1) \qquad \overline{AC}^2 = {C_y}^2 + {C_x}^2$

$(2) \qquad \overline{BC}^2 = (\overline{AB}-C_y)^2 + {C_x}^2$

Rearranging $(1)$ gives

$(3) \qquad {C_x}^2 = \overline{AC}^2-{C_y}^2$

Substituting $(3)$ into $(2)$ and rearranging gives

$$\overline{BC}^2 = (\overline{AB}-{C_y})^2 + \overline{AC}^2-{C_y}^2 = \overline{AB}^2 - 2\overline{AB}\cdot{C_y} + \overline{AC}^2$$

$$C_y = \frac{AB^2 + AC^2 - BC^2}{2\overline{AB}}$$

Since $C_y$ is now known $C_x$ can be found by rearranging $(1)$ to give

$$C_x = \pm \sqrt{\overline{AC}^2 - {C_y}^2}$$


Here is a solution in JavaScript https://gist.github.com/JulienSansot/d394d210c772a48be067d7e3b856dd1e

//a,b,c are the sides of the triangle
function get_third_point_coordinates(a, b, c){
  var result = {x:0,y:0};

  if(a > 0){
    result.x = (c*c - b*b + a*a) / (2*a);
  }

  result.y = Math.sqrt(c*c - result.x*result.x);
  return result;
}

The triangle is Pythagorean. Since $ab=ch$ the second coordinate of $C$ is $\pm12/5$. From $a^2=cp$ the first coordinate of $C$ is $5/9$ thus there are two solutions.