Calculate the coordinates of the third vertex of triangle given the other two and the length of edges in the cheapest computational way

7.3k Views Asked by At

I simply have a triangle say $\triangle ABC$. Given coordinates of $A$ & $B$ and the length of $AC$ and $BC$.

I can calculate the length between ab via the distance square rule.

$$D = \sqrt{(X_2 - X_1)^2 + (Y_2 - Y_1)^2} $$

I have tried to use the distance rule to compute the third vertex, but it has a lot of steps. I wonder if there is another method that yields the two possible solutions for the vertex

2

There are 2 best solutions below

4
On BEST ANSWER

Let $A = (x_A, y_A)$ and $B = (x_B,y_B)$ the known vertices of your triangle. Let's call $d_{AB}$, $d_{BC}$ and $d_{CA}$ the lengths of each side.

  1. Translate your points subtracting $x_A$ and $y_A$ so that $A$ corresponds with the origin. That is:

$$A' = (0, 0), B' = (x_B-x_A, y_B-y_A ) = (x_B', y_B').$$

  1. Rotate $B'$ so that it lies on the $x$-axis. This can be done without knowing the angle, indeed:

$$A'' = (0,0), B'' = (d_{AB}, 0).$$

Anyway, the value of the rotation angle is important for the next steps. In particular it is $$\theta = \arctan2\left(y_B-y_A,x_B-x_A\right),$$

where $\arctan2(\cdot, \cdot)$ is defined in details here.

  1. At this point, it is easy to find $C''$. Notice that there are two solutions, since the point $C''$ can be placed above or below the side $AB$.

$$x_C'' = \frac{d_{AB}^2+d_{AC}^2-d_{BC}^2}{2d_{AB}},$$

and

$$y_C'' = \pm\frac{\sqrt{(d_{AB}+d_{AC}+d_{BC})(d_{AB}+d_{AC}-d_{BC})(d_{AB}-d_{AC}+d_{BC})(-d_{AB}+d_{AC}+d_{BC})}}{2d_{AB}}.$$

  1. Now, rotate back your point $C''$ using $-\theta$ (see step 2), thus obtaining $C'$.
  2. Finally, translate $C'$ by adding $x_A$ and $y_A$ to the components in order to obtain $C$.
0
On

Reasoning with vectors you can obtain the solutions without translations, rotations and avoiding angles altogether.

Let u, v, w be the 3 vectors representing the sides of triangle, where

$$\textbf{w} = P_2-P_1 = [x_2-x_1,\;y_2-y_1]$$

is known, being the vector going from $P_1$ to $P_2$. We have to find 4 equations able to determine the 4 unknow components of vectors u and v ($u_x, u_y, v_x, v_y$).

Provided that u and v are chosen so that $\textbf{u}+\textbf{v}+\textbf{w}=\textbf{0}$ (i.e. u, v, w form a circuit) we already have 2 equations:

$$w_x+v_x+u_x=0$$ $$w_y+v_y+u_y=0$$

Another condition can be obtained remembering that the module of the cross product of any of 2 vectors is the double of triangle area (provided that you choose u and v so that the circuit $\;\textbf{u} \to \textbf{v} \to \textbf{w}\;$ is counterclockwise, otherwise $A$ is negative)

$$||\textbf{u} \times \textbf{v}||= u_x v_y-u_y v_x = 2 A$$ $$||\textbf{v} \times \textbf{w}||= v_x w_y-v_y w_x = 2 A$$ $$||\textbf{w} \times \textbf{u}||= u_y w_x-u_x w_y = 2 A$$

where the area $A$ is known because can be calulated with Erone's formula. The equation to be used is the sum of the 3 equations above.

The last equation is the sum of the equations which relate dot products with sides lengths:

$$\textbf{u} \cdot \textbf{u}=u_x^2+u_y^2={L_u}^2$$ $$\textbf{v} \cdot \textbf{v}=v_x^2+v_y^2={L_v}^2$$

where ${L_u}$ and ${L_v}$ are the known lengths of the corresponding sides of triangle.

Here is the Maxima code you can use to perform the calculations described above (you can use an online Maxima calculator if you don't have Maxima installed):

load(vect);

u:[u_x,u_y];
v:[v_x,v_y];
w:[w_x,w_y];

[e1,e2]:makelist(e=0,e,u+v+w); /* triangle constraints */
e3:express(u~v)=2*A; /* cross product */
e4:express(v~w)=2*A;
e5:express(w~u)=2*A;
e6:u.u=Lu^2; /* side length square */
e7:v.v=Lv^2;

solve([e1,e2,e3+e4+e5,e6+e7],[u_x,u_y,v_x,v_y]);

With some semplifications by hand the 2 solutions (notice the $\pm$ and $\mp$ symbols, the order of signs must be respected) can be written as (hoping I did it right, the numeric checks I made were ok)

$${u_x}=\frac{\mp\left| {{L_v}^2}-{{L_u}^2}\right| w_x-{{L_w}^2} w_x-4 A w_y}{2 {{L_w}^2}}\;\;\;{u_y}=\frac{\mp\left| {{L_v}^2}-{{L_u}^2}\right| w_y-{{L_w}^2} w_y+4 A w_x}{2 {{L_w}^2}}$$ $${v_x}=\frac{\pm\left| {{L_v}^2}-{{L_u}^2}\right| w_x-{{L_w}^2} w_x+4 A w_y}{2 {{L_w}^2}}\;\;\;{v_y}=\frac{\pm\left| {{L_v}^2}-{{L_u}^2}\right| w_y-{{L_w}^2} w_y-4 A w_x}{2 {{L_w}^2}}$$

Once you calculate the known terms $A$, ${L_w}^2$ and $\left| {{L_v}^2}-{{L_u}^2}\right|$, getting to the solutions is computationally straightforward and, as already said, no reference system transformations are needed and no angles are involved.

With the following Maxima code (where solutions are written directly), you can enter the known coordinates of points $P_1$ and $P_2$ and the known lengths $L_u$ and $L_v$ of the two other sides of triangle, and you can compute the vectors u and v. The unknown vertex of triangle is given by $\;P_2+\textbf{u}\;$.

sol1:[u_x=(-w_x*abs(Lv^2-Lu^2)-Lw^2*w_x-4*A*w_y)/(2*Lw^2),u_y=(-w_y*abs(Lv^2-Lu^2)-Lw^2*w_y+4*A*w_x)/(2*Lw^2),v_x=(w_x*abs(Lv^2-Lu^2)-Lw^2*w_x+4*A*w_y)/(2*Lw^2),v_y=(w_y*abs(Lv^2-Lu^2)-Lw^2*w_y-4*A*w_x)/(2*Lw^2)];
sol2:[u_x=(w_x*abs(Lv^2-Lu^2)-Lw^2*w_x-4*A*w_y)/(2*Lw^2),u_y=(w_y*abs(Lv^2-Lu^2)-Lw^2*w_y+4*A*w_x)/(2*Lw^2),v_x=(-w_x*abs(Lv^2-Lu^2)-Lw^2*w_x+4*A*w_y)/(2*Lw^2),v_y=(-w_y*abs(Lv^2-Lu^2)-Lw^2*w_y-4*A*w_x)/(2*Lw^2)];

P_1:[0,0]; /* enter point coordinates here */
P_2:[2,0]; /* enter point coordinates here */
Lu:3; /* enter side length here */
Lv:4; /* enter side length here */
w:[w_x,w_y];
[w_x,w_y]:P_2-P_1$
Lw:ev(sqrt(w.w))$
p:(Lu+Lv+Lw)/2$
A:factor(sqrt(p*(p-Lu)*(p-Lv)*(p-Lw)))$

ev(sol1),numer;
ev(sol2),numer;
ev(P_2+u,ev(sol1)),numer; /* coordinates of unknown vertex solution 1 */
ev(P_2+u,ev(sol2)),numer; /* coordinates of unknown vertex solution 2 */