# Calculate coordinates of 3rd point (vertex) of a scalene triangle if angles and sides are known.

I am writing a program and I need to calculate the 3rd point of a triangle if the other two points, all sides and angles are known.

            A (6,14)
^
/ \
14.14 /   \ 10.14
/     \
/       \
B (16,4)--------- C (x,y)
10.98


A (6,14), B (16,4). Side AB is 14.14, AC is 10.14 and BC is 10.98 Angle A, B, C are 50, 45 and 85 degrees respectively...

I want to calculate the position of C. I don't know which formula to use for this. Actually i am performing triangluation. I am calculating the position of an incoming object (C).

-
You can use parametric equations for the lines with those angles. Then, just take the intersection. But I guess that there is some formula with trigonometric informations. –  Sigur Aug 26 '12 at 14:23
Thanks! I've thought of this but as you said there got to be some formula for this! Got to pass high school again! –  Krat Aug 26 '12 at 14:30
@Sigur Yes you are right, trig is probably the way to go for this kind of problem. –  mathguy Aug 26 '12 at 15:28
Hint : One useful point will be, using distance formula. However it will be hard to use it but it will provide you at least one significant equation for(x,y). I think it would be $x + y = -14.131$ –  Rahul Taneja Aug 26 '12 at 18:05
@Krat : The singular is "vertex"; the plural is "vertices". I changed the title accordingly. –  Michael Hardy Aug 26 '12 at 19:08

It is enough to take the middle point of $BC$ and duplicate it. Let me explain:

Consider $M=1/2(AB+AC)$. Then $C=2BM$. Now you have the vector and its norm, so is enough to solve an equation.

-
I think if we find the equation of lines BC and AC, we can find their point of intersection. If we drop a perpendicular CD to AB, what will be the slope of AC? Is it CD/AD?? –  Krat Aug 28 '12 at 9:38

Thanks everyone for the help! I found the answer. The formula for which is given here (Section: Intersection of two circles. It's not in the plot, but $d$ is the euclidean distance between the centers of the circles or $d=a+b$).

a = (r0 - r12 + d2 ) / (2d)

h = r0 sinP0 (or) r1 sinP1

P2 = P0 + a ( P1 - P0 ) / d i.e., x2 = x0 + a (x1 - x0) / d (and) y2 = y0 + a (y1 - y0) / d

x3 = x2 ± h ( y1 - y0 ) / d

y3 = y2 ± h ( x1 - x0 ) / d

-
I struggled for a while to understand where the formula for the coordinates of $P_2$ came from. The key is to realize that $(P_1 - P_0)/d$ is just the unit vector that points in the direction of $a$ (The original vector is $v = (P_{1y} - P_{0y}, P_{1x} - P_{0x})$), so multiplying it by $a$ gives the coordinates for $P_2$. –  nachocab Sep 7 at 15:59
And the key to the last step (the coordinates of $P_3$) is understanding that the unit vector along $h$ is perpendicular to the unit vector along $a$. –  nachocab Sep 7 at 20:29

Take the following figure I made in paint:

So basically, you want to find the lengths $AD$ and $DC$. So lets make the coordinates $(X_A,Y_A),(X_B,Y_B),(X_C,Y_C)$. The length $AO = |Y_A - Y_B|$ and $BO = |X_A - X_B|$. That means that $\tan(\angle ABO) = \frac{AO}{BO} \leftrightarrow \angle ABO = \arctan(\frac{AO}{BO})$.
Because the angles of a triangle sum up to $180$ degrees, $\angle BAO = 180 - \angle ABO - 90 \leftrightarrow \angle BAO = 90 - \angle ABO$.
$\angle DAC = \angle BAC - \angle BAO$.
$\sin(\angle DAC) = \frac{DC}{AC} \longleftrightarrow DC = AC \sin(\angle DAC)$
$\cos(\angle DAC) = \frac{AD}{AC} \longleftrightarrow AD = AC \cos(\angle DAC)$
$X_C = X_A + DC$
$Y_C = Y_A + AD$
Now if you want two formulas with all the information compacted, you get:
$X_C = X_A + AC\sin(\angle BAC - 90 + \arctan(\frac{AO}{BO}))$
$Y_C = Y_A + AC\cos(\angle BAC - 90 + \arctan(\frac{AO}{BO}))$
Just for the record, the angles and lengths are good information to have, but because of the way trigonometric functions work, the coordinates $(x,y)$ might appear on the opposite side of line $AB$ in your example, while still fulfilling your constraints. You may have to add some if statements if you want it going in a certain direction. Let me know if this equation works.

-
There got to be some easy way(s). One way as I have answered.. Another is to find the equations of lines AC and BC by using point-slope form y-y1 = m(x-x1). If CD is perpendicular to AB, we can find the angles BCD and ACD. From these angles can we find the slopes of BC and AC? –  Krat Aug 28 '12 at 9:52
@Krat CD and AB are not perpendicular (at least if you are referring to my image). Did you mean to say CD and AB? –  mathguy Aug 28 '12 at 10:07
not this image Sid! I am referring to the image I've drawn in the question.. –  Krat Aug 28 '12 at 10:19
@Krat What is point D on your picture? –  mathguy Aug 28 '12 at 22:37
D is a point on AB such that CD is perpendicular to AB. –  Krat Aug 29 '12 at 17:45