Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a triangle that I know the lengths of all the sides. But I need to know the angles. Needs to work with non-right triangles as well.

I know it is possible, and I could have easily done this years ago when I was in trig, but it has completely slipped my mind.

Id prefer a solution that I can code into a function, or something that does not require constructing right triangles from it.

share|cite|improve this question
You should take a look at the Law of Cosines. – Austin Mohr Mar 19 '12 at 23:36
Recall the cosine law: if $a,b,c$ are the lengths of the triangle and $\theta$ is the angle opposite $c$ then $c^2=a^2+b^2-2abcos\theta$ – you Mar 19 '12 at 23:37
up vote 4 down vote accepted

As has been mentioned in comments, the formula that you're looking for is the Law of Cosines. The three formulations are: $$c^2 = a^2 + b^2 - 2ab \cos(C)$$ $$b^2 = a^2 + c^2 -2ac \cos(B)$$ $$a^2 = b^2 + c^2 - 2bc \cos(A)$$

You can use this law to find all three angles. Alternatively, once you have one of the angles, you can find the next using the Law of Sines, which states that: $${\sin{A} \over a} = {\sin{B} \over b} = {\sin{C} \over c}$$

And of course, once you have solved for two of the angles, you need only subtract their sum from $180$ degrees to get the measure of the third.

share|cite|improve this answer
@Théophile: (Now if we delete all these comments, no one will ever know...) – The Chaz 2.0 Mar 20 '12 at 15:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.