I need to calculate an angle of a triangle by using the tan^-1
function. On my calculator I can do this:
tan^-1(3/4)
// 3 and 4 are triangle side lengths
And it outputs 36 degrees. What is the alternative to this function in JavaScript? I tried Math.tan(3/4)
, Math.atan(3/4)
and all of the other tan functions I saw in the list, but none of them outputs the result in degrees I need (36).
Thank you.
I need to calculate an angle of a triangle by using the tan^-1
function. On my calculator I can do this:
tan^-1(3/4)
// 3 and 4 are triangle side lengths
And it outputs 36 degrees. What is the alternative to this function in JavaScript? I tried Math.tan(3/4)
, Math.atan(3/4)
and all of the other tan functions I saw in the list, but none of them outputs the result in degrees I need (36).
Thank you.
- 2 javascript works in radians – Jaromanda X Commented Sep 29, 2015 at 11:51
- By the way it should be 36.8698976, not 36. Math.atan(3/4) * 180 / Math.PI – Jaromanda X Commented Sep 29, 2015 at 11:54
1 Answer
Reset to default 8There is no build in function for that, since 1 radian = 180/pi degrees
you can do the following using Math.atan()
and Math.PI
var degree = Math.atan(3 / 4) * (180 / Math.PI);
document.write(degree);