[Python-ideas] Trigonometry in degrees
Steven D'Aprano
steve at pearwood.info
Fri Jun 8 21:04:40 EDT 2018
On Fri, Jun 08, 2018 at 08:45:54AM +0000, Robert Vanden Eynde wrote:
> from math import sin, tau
> from fractions import Fraction
> sin(Fraction(1,6) * tau)
> sindeg(Fraction(1,6) * 360)
>
> These already work today by the way.
You obviously have a different understanding of the words "already work"
than I do:
py> sindeg(Fraction(1,6) * 360)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sindeg' is not defined
Since tau is a float, writing Fraction(1,6) * tau instead of tau/6 is a
waste of time. Also, Fraction(1,6) * 360 is also a waste of time, since
360/6 is not only exact, but can be done at compile-time.
--
Steve
More information about the Python-ideas
mailing list