[Solved] Calculate one side of a triangle (Law of Cosines) in javascript or jquery [closed]


Use sine rule:
http://media.tiscali.co.uk/images/feeds/hutchinson/ency/c02395.jpg

If you have side a and angle A, and you want to work out the length of side b and you have angle b, the formula would be

b = sin B * (a/sinA)

In Javascript this can be done by

var B = 45; //size of angle B
var a = 5;  //length of side a
var A = 45; //size of angle A
var calculateLength = Math.sin(B/180*Math.PI) * (a/Math.sin(A/180*Math.PI));

Here is a live example

10

solved Calculate one side of a triangle (Law of Cosines) in javascript or jquery [closed]