[Math] Calculate third point of triangle from two points and angles

trigonometry

I've got two points(p1 and p2) and two angles(angle1 and angle2), I can calculate the third angle, but how do I calculate the coordinates of point p? Not just the distances from the points, but coordinates.

I'm trying to use this to do texture mapping on triangles. Here is an image of my idea

p1 = (2, 0)
p2 = (6, 4)

angle1 is angle next to p1,  
angle2 is angle next to p2.

figure

Best Answer

Let us fix some notations:

  • let $\alpha_1,\alpha_2,\alpha_3$ be "angle1,angle2,angle3" resp.

  • let length of $p_1p_2 = a_3$ and the other sides' lengthes names by cyclic permutation.

  • let $u=x_2-x_1, v=y_2-y_1$. Thus $a_3=\sqrt{u^2+v^2}$.

First of all: $\alpha_3=\pi-(\alpha_1+\alpha_2)$.

Then, using the law of sines (https://en.wikipedia.org/wiki/Law_of_sines):

$$\dfrac{a_1}{\sin \alpha_1}=\dfrac{a_2}{\sin \alpha_2}=\dfrac{a_3}{\sin \alpha_3}$$

one obtains in particular $a_2=a_3\dfrac{\sin \alpha_2}{\sin \alpha_3}$ where where $\alpha_2,\alpha_3$ and $a_3$ are known quantities.

Let us now express

  • the dot product $\vec{p_1p_2}.\vec{p_1p_3}=a_2 a_3 \cos \alpha_1$ and

  • the norm of the cross product $\|\vec{p_1p_2}\times\vec{p_1p_3}\|=a_2 a_3 \sin \alpha_1$

by using coordinates:

$$\begin{cases} u(x_3-x_1)+v(y_3-y_1)&=&a_2 a_3 \cos \alpha_1\\ u(y_3-y_2)-v(x_3-x_2)&=&a_2 a_3 \sin \alpha_1\end{cases}$$

One obtains a linear system of 2 equations with the two unknowns $x_3$ and $y_3$ ; the solution of this system is without difficulty.

Here is a complete Matlab program with explicit formulas for $x_3$ and $y_3$:

x1=0;y1=0;x2=6;y2=0; % initial data
alp1=2*pi/3;alp2=pi/6; % initial data
u=x2-x1;v=y2-y1;a3=sqrt(u^2+v^2);
alp3=pi-alp1-alp2;
a2=a3*sin(alp2)/sin(alp3);
RHS1=x1*u+y1*v+a2*a3*cos(alp1);
RHS2=y2*u-x2*v-a2*a3*sin(alp1);
x3=(1/a3^2)*(u*RHS1-v*RHS2);
y3=(1/a3^2)*(v*RHS1+u*RHS2);
Related Question