Askerman
Askerman

Reputation: 847

How do i use inversed tan in javascript?

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.

Upvotes: 7

Views: 1912

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115212

There 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);

Upvotes: 8

Related Questions