Python Forum
How do I get the tangent of a degree
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I get the tangent of a degree
#1
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
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
(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.
Reply
#4
Duh, listen to scidam.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to map 360 degree angle over 1024 counts breadcat248 3 2,440 May-17-2019, 07:13 AM
Last Post: breadcat248
  Python function to get colorwheel RGB values from compass degree? wrybread 5 8,164 Sep-06-2017, 05:36 PM
Last Post: wrybread

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020