Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate sides of a right angle triangle with JavaScript?

Tags:

javascript

enter image description here

If I did not know that side AB was 489.84 or that side BC was 12.66, how could I calculate these two lengths with JavaScript given I had all the other information?

like image 309
dbj44 Avatar asked Dec 24 '22 03:12

dbj44


1 Answers

Use the Math.sin and Math.cos functions. Note: these functions accept radians, you would thus need to convert degrees by using rad = deg * Math.PI/180:

Math.cos(88.52 * Math.PI/180) * 490; // 12.655720238100102
Math.sin(88.52 * Math.PI/180) * 490; // 489.83653676022874
like image 162
le_m Avatar answered Jan 26 '23 01:01

le_m