triangles angles

Can any one tell me what calculation you have to make to calculate scalene triangles angles if you know all the lengths of the sides?

i am trying to make ik system that will suit my needs and i need to calculate the angles at which my bones should be but i need some angles. i looked on internet but i have no idea how to do all of that in script.

You have not search real well have you :slight_smile:

The law of cosines is your answer.

Check there for instance.

Note that this is more of a math question than a unity question.

float AngleOfTriangle(float a, float b, float c){
   float cAng = (a*a+b*b- c*c)/(2*a*b);
   float rad = Mathf.Acos(cAng);
   return Mathf.Rad2Deg(rad);
}

In this case, the c angle represents the angle opposite to the last edge provided as parameter.

EDIT: I realized I made one mistake, it was given as a^a+b^b-c^c but it is aa+bb-c*c those are squared not power of itself.
As requested in Js:

function AngleOfTriangle:float(a:float , b:float, c:float){
   var cAng:float = (a*a+b*b- c*c)/(2*a*b);
   var rad:float = Mathf.Acos(cAng);
   return Mathf.Rad2Deg(rad);
}

And it is “Can you PLEASE write this in Javascript?” :slight_smile:

thanks a lot!!!
i was stuck on this for 5 hours

function AngleOfTriangle (a:float , b:float, c:float): float{
var cAng:float = (aa+bb-cc)/(2ab);
var rad:float = Mathf.Acos(cAng);
return Mathf.Rad2Deg
rad;
}