How to use degrees with trigonometric functions?

A forum for general discussion of the Python programming language.

How to use degrees with trigonometric functions?

Postby ismaelvc » Tue Apr 01, 2014 3:53 pm

Hello everyone!

I'm trying to get myself around how trigonometric functions from the math module work in Python, after, lots of errors, I noticed that for example the return value of "tan()" is in radians (finally got to "help(tan)" :mrgreen: ), but when I try to convert the radians to degrees the answer doesn't make sense to me, Im very rusted in this topic:

google: tan(7) = 0.122784560903
wolfram: tan(7) = 0.122784560903...
Kcalc: tan(7) = 0.122784560903 # Deg mode
python: degrees(tan(7)) = 49.93029147529294

Image

I'm trying to define an extended set of trig functions, sec, cot, etc, but I don't really understand how to use the normal ones to get tan(7) = 0.122784560903

Thanks in advance!
ismaelvc
 
Posts: 7
Joined: Tue Apr 01, 2014 3:35 pm

Re: How to use degrees with trigonometric functions?

Postby stranac » Tue Apr 01, 2014 4:21 pm

You have to give math.tan() a number of radians.
That means you have to convert your number from degrees to radians, not the other way around:
Code: Select all
>>> import math
>>> math.radians(7)
0.12217304763960307
>>> math.tan(math.radians(7))
0.1227845609029046
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1209
Joined: Thu Feb 07, 2013 3:42 pm

Re: How to use degrees with trigonometric functions?

Postby ismaelvc » Tue Apr 01, 2014 6:30 pm

Thank you very much stranac!
ismaelvc
 
Posts: 7
Joined: Tue Apr 01, 2014 3:35 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests