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.
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$: