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
2 Answers
Reset to default 5Simply 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