Re: [Python-ideas] Trigonometry in degrees

Is this going to be backported all the way to Python 2.7? More generally, there is a huge body of code in C, C++, Java, JavaScript, etc etc where angles are always passed as radians. Python programmers will almost certainly have to read, and often write, such code. If everybody else is doing something in a particular way then there is a strong case for doing the same thing. It's not as if Python programmers cannot use degrees. The built in conversion functions make it easier to do so than most other languages.
The degrees and radian functions follow the Python idiom for converting values, eg str(x) is interpreted as converting x into a str. However the analogy breaks down because str(x) is a NOP if x is already a string, while degrees(x) can't tell whether x is already in degrees or not. Maybe rad2deg would have been better, but the current solution is good enough - and as noted above, much better than what you get in C or JavaScript.
See above. Why do Python subscripts start from zero? Because most programmers expect them to.
But I want them to be more accurate. I didn't make myself clear. Like you, I want cos(90 degrees) to be 0, not some small number. Other people have pointed out the problem with trying to guess the result from the argument value, so I am suggesting that the functions should instead look at the calculated result and if it is sufficiently close to 0.0 or 1.0, assume that the argument value was 90 degrees or some multiple thereof.
Well I program using the OpenGL API in Python, so there's at least one person who will find the d suffix confusing for that reason. And the d suffix is used for types and functions in OpenGL shading language, C, ARM/Intel assembler. The intersection with Python programmers may not be very large, but again it is at least 1. So no they are not utterly unrelated.
Is d used as a suffix by mathematicians though? The h works because the context makes it clear which sense is being used, mathematics, C, or struct module. Here we are discussing functions in the same module. Whether to use d or deg is an arbitrary choice for mathematicians (AFAIK), so either would work equally well. Since d can be confusing for others, to me that would make deg preferable. But see below where I change my mind.
OK, that's interesting, I did not know that. And a quick google shows that Matlab also has sind and similar variants for degrees.
If Julia and Matlab are sufficiently well known, I would prefer d as suffix rather than prefix. -- cheers, Hugh Fisher

2018-06-08 15:19 GMT+02:00 Hugh Fisher <hugo.fisher@gmail.com>:
I graduated less than a year ago - Matlab at the very least is quite well-known, we got lessons about it (although I was the one kid who used python for his matlab assignments...you can make do, with matplotlib, google, opencv, and numpy.). I also believe they give free/heavily discounted licenses to schools, hoping that after graduation, those students are used to matlab and will try to make their employers buy full-priced versions. I don't know about Julia, though.

2018-06-08 15:19 GMT+02:00 Hugh Fisher <hugo.fisher@gmail.com>:
I graduated less than a year ago - Matlab at the very least is quite well-known, we got lessons about it (although I was the one kid who used python for his matlab assignments...you can make do, with matplotlib, google, opencv, and numpy.). I also believe they give free/heavily discounted licenses to schools, hoping that after graduation, those students are used to matlab and will try to make their employers buy full-priced versions. I don't know about Julia, though.
participants (2)
-
Hugh Fisher
-
Jacco van Dorp