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

math - Any way to get inverse sine in javascript - Stack Overflow

programmeradmin0浏览0评论

I'm working on a project to solve triangles, but I cant seem to figure out how to get the inverse of sine, I've already set up switching from radians to degrees in my program I just need inverse operators.

I'm working on a project to solve triangles, but I cant seem to figure out how to get the inverse of sine, I've already set up switching from radians to degrees in my program I just need inverse operators.

Share Improve this question edited Mar 22, 2019 at 4:52 N8888 6702 gold badges14 silver badges21 bronze badges asked Mar 22, 2019 at 2:23 The NuthouseThe Nuthouse 1731 silver badge10 bronze badges 8
  • 1 Do you mean Math.asin() ? – haopeng Commented Mar 22, 2019 at 2:24
  • So its just Math.asin(); ? – The Nuthouse Commented Mar 22, 2019 at 2:27
  • Check this out: developer.mozilla/en-US/docs/Web/JavaScript/Reference/… – haopeng Commented Mar 22, 2019 at 2:29
  • @haopeng I tried it and it didn't work. – The Nuthouse Commented Mar 22, 2019 at 2:29
  • What does radians to degree conversion has to do with this question? Are you trying to find the inverse of sin, or degree to radian? – Kaiido Commented Mar 22, 2019 at 2:37
 |  Show 3 more ments

2 Answers 2

Reset to default 5

Simply use Math.asin:

Math.asin(opposite / hypotenuse);

Math.sin(x) takes a radian and outputs a range [-1 , 1].
Math.asin(x) takes a range [-1 , 1] and outputs a radian value.

To convert these radian values, use these two functions:

degreeToRadian = d => d * Math.PI * 180 ** -1

radianToDegree = r => r * 180 * Math.PI ** -1

For example:

Math.sin(degreeToRadian(30)).toFixed(3) * 1

results -> 0.5

or:

radianToDegree(Math.asin(0.5)).toFixed(3) * 1

results -> 30

发布评论

评论列表(0)

  1. 暂无评论