degrees and radians.
Jim Richardson
warlock at eskimo.com
Tue May 7 01:02:28 EDT 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, 06 May 2002 15:15:50 -0600,
Fernando PĂ©rez <fperez528 at yahoo.com> wrote:
> Raymond Hettinger wrote:
>
>>> I am trying to get the math module to deal with degrees rather than
>>> radians. (that it deals with radians for the angular functions like
>>> sin() isn't mentioned in the docs, which was sort of an eyeopener :) I
>>> can't find any info on doing this. I can convert from-to degrees in the
>>> code calling the function, but that's a bit clunky. Any pointers to an
>>> FM to R? :)
>>
>> There is a patch for adding degree/radian conversions.
>> See http://www/python.org/sf/552452
>
> Sorry to sound critical, but I doubt this will make it in (and I hope it
> doesn't). Reason: bloat. Yes, it's only two functions, but still, bloat is
> bloat. Plus, if you really need those conversions, it's less typing and more
> efficient (no function call) to simply use a multiplicative constant:
>
> In [7]: to_rad = pi/180
>
> In [8]: to_deg = 1/to_rad
>
> In [9]: sin pi/4
> ------> sin (pi/4)
> Out[9]: 0.70710678118654746
>
> In [10]: sin 45*to_rad
> -------> sin (45*to_rad)
> Out[10]: 0.70710678118654746
>
> In [11]: (pi/4)*to_deg
> Out[11]: 45.0
>
> I realize you have good intentions, but I truly don't think that in this case
> the benefits outweigh the cost. OTOH, one could add a comment in the
> docstrings to the effect of 'trig functions expect arguments in radians',
> since it does seem to cause confusion among newbies.
>
> Cheers,
>
Well, it was a lightbulb going off in my head when I finally figured out
*why* the numbers my code was giving me were so wrong. Doh! after I
thought about it, it made perfect sense, but before I had thought about
it :)....
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE811/kd90bcYOAWPYRAmF6AKCya2mJ44k0UCixEg5SCl7KCjPevACeJJ5C
0DF1Qa/PoRvFn2L1wa9SihI=
=dCLr
-----END PGP SIGNATURE-----
--
Jim Richardson
Anarchist, pagan and proud of it
http://www.eskimo.com/~warlock
Linux, from watches to supercomputers, for grandmas and geeks.
More information about the Python-list
mailing list