DEV Community

Max Trukhinov
Max Trukhinov

Posted on

Help with trigonometry in Python needed!

Hey, guys! So, right to the problem - I have a formula that has sines and I want to make a python version of it (to relieve me from counting it by hand - it's really complex).

So you know that sine of 30 degrees is 0.5, sine of 45 degrees is sqrt of 2 divided by 2 etc.
And I need a function that would do the opposite - get a number (like 0.5) and turn it into a degree (like 30).

Disclaimer: I don't know trigonometry that well, so I'm quite probably missing something.

Thanks! :)

Top comments (4)

Collapse
 
cicirello profile image
Vincent A. Cicirello • Edited

You want the trig function arcsine, which in Python is asin in the math module. It gives you result in radians, so if you are looking for degrees you'll need to convert. All of the trig functions assume radians.

Also in math module there are functions degrees and radians for converting.

Collapse
 
striderdunedain profile image
Max Trukhinov

Big thanks! Gonna try it out)

Collapse
 
mccurcio profile image
Matt Curcio

Do you mean the arcsine function?

Collapse
 
striderdunedain profile image
Max Trukhinov

Thanks!)