Python Forum

Full Version: How do I get the tangent of a degree
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was trying to get the tangent of a degree, but math.tan returns the radian. How do I get the tangent of a degree? I hope I worded that right.

I figured it out, I just need to use math.radians on the number I was trying to find the tangent of according to a stackoverflow thread I found here - https://stackoverflow.com/questions/9875...to-degrees
The math module has two functions for converting between radians and degrees, so to get the tangent in degrees of a measurement in degrees, you would use math.degrees(math.tan(math.radians(theta)), where theta is the angle you are getting the tangent for.
(Oct-24-2019, 01:33 AM)SheeppOSU Wrote: [ -> ]I was trying to get the tangent of a degree, but math.tan returns the radian


math.tan(x) doesn't return radians (it returns value of tangent for specific angle -- x which is (expected to be) given in radians). math.atan is inverse function to math.tan, therefore, it returns radians. So, math.tan(x) requires x to be in radians. If you want to calculate, e.g. tan(60 degrees), you need to convert 60 degrees to radians: tan(60 degrees) = math.tan(math.radians(60)). Note, that conversion between radians and degrees is very simple: math.radians(deg) = deg * math.pi / 180.0.
Duh, listen to scidam.