最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do i use inversed tan in javascript? - Stack Overflow

programmeradmin2浏览0评论

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.

Share Improve this question edited Sep 29, 2015 at 12:20 Wolf 10.3k8 gold badges68 silver badges112 bronze badges asked Sep 29, 2015 at 11:50 AskermanAskerman 8471 gold badge14 silver badges31 bronze badges 2
  • 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
Add a ment  | 

1 Answer 1

Reset to default 8

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

发布评论

评论列表(0)

  1. 暂无评论