SUMMARY The "atan2" function does not yeld the expected values STEPS TO REPRODUCE 1. Create new project -> Add a worksheet -> Add an xy-plot -> Add a new xy-curve from a mathematical equation. 2. As equation, type: "180*atan(1)/pi" and press "recalculate" button. 3. Should appear a stright line plot of value 45 as arctan(1)=45 degrees. 4. Now change the equation to "180*atan2(1,1)/pi", and press "recalculate" again. The plot should not change, as the "atan2" function is supposed to be defined as "atan2(Y,X) = atan(Y/X)" but being quadrant-aware. Instead, a straight-line plot of 90 degrees appears, which is erroneous. OBSERVED RESULT A value of 90 degrees EXPECTED RESULT A value of 45 degrees SOFTWARE/OS VERSIONS Linux/KDE Plasma: (available in About System) KDE Plasma Version: 5.14.5 KDE Frameworks Version: 5.54.0 Qt Version: 5.11.3 ADDITIONAL INFORMATION Labplot2 v2.8.1 compiled from source (git commit d0573f64a0)
I can not reproduce the problem. Compiling 2.8.1 on Debian 10 stable and using 180*atan2(1,1)/pi gives me 45, as expected. Can you try again and make a screenshot to see a possible problem?
Created attachment 133417 [details] Video showing the bug
(In reply to Stefan Gerlach from comment #1) > I can not reproduce the problem. Compiling 2.8.1 on Debian 10 stable and > using > 180*atan2(1,1)/pi gives me 45, as expected. > Can you try again and make a screenshot to see a possible problem? Ok, I think you and me are both right. It seems a locale problem: my default system locale is catalan, which has the comma as a decimal separator by default. If I start Labplot with an english locale (like yours, perhaps?), the atan2 function works as expected. Please see the attached video, where the problem is shown and also shows other related issues: if either argument of the atan2 function is a floating point number, the only accepted decimal separator is a comma, which is indistinguishable from the separator between the two «atan2» arguments. This confuses the parser and leads to funny results. Perhaps other character (like the semicolon, for instance) should be used as functions' argument separator when the system locale uses the comma as a decimal separator. I've seen that in other languages...
Git commit 443fbde0057f2d34df13b154c260505180b39fed by Stefan Gerlach. Committed on 21/11/2020 at 17:51. Pushed by sgerlach into branch 'master'. Support semicolon as function argument separator in parser to improve support for locale with comma decimal separator FIXED-IN: 2.8.2 M +3 -0 ChangeLog M +3 -0 src/backend/gsl/parser.y https://invent.kde.org/education/labplot/commit/443fbde0057f2d34df13b154c260505180b39fed
The parser now supports a semicolon as function argument separator for locale that have a comma already as decimal separator. A comma is still supported for these locale since some expressions (that may be used before) work with it.