Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinities, NaNs, Atan2, and Windows TM portability #756

Open
donbright opened this issue Apr 15, 2014 · 3 comments
Open

infinities, NaNs, Atan2, and Windows TM portability #756

donbright opened this issue Apr 15, 2014 · 3 comments

Comments

@donbright
Copy link
Sponsor Member

donbright commented Apr 15, 2014

it seems that atan2 is giving different values for the tests of infinity on Windows vs Linux.

I am working on a solution which is to force it to work like the OpenGroup / linux manpage standard and add many more tests to testdata/scad/functions/inf-tests. But I wanted to post this to see if anyone else has ideas.

Some interesting links:

http://pubs.opengroup.org/onlinepubs/009695399/functions/atan2.html

http://www.cplusplus.com/reference/cmath/atan2/

http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@donbright donbright self-assigned this Apr 15, 2014
@tim-caper
Copy link
Contributor

Nothing to tell about atan2() just want to let you know that I have an idea to rewrite builtin functions to avoid duplicate arguments computation and return exact value for cos(90) :-)

@donbright
Copy link
Sponsor Member Author

The problem is with infinity and NaN arguments to Atan2, and then only when running the 32-bit under 64-bit Windows 7 .... funnily enough this is not reproducable under Wine. Result of

 ctest -R inf

http://files.openscad.org/tests/win_586_amd-m880g-with_sicj_report.html

The key part here is

-ECHO: "atan2( 1/0, 1/0)", 45
-ECHO: "atan2( 1/0,-1/0)", 135
-ECHO: "atan2(-1/0, 1/0)", -45
-ECHO: "atan2(-1/0,-1/0)", -135
+ECHO: "atan2( 1/0, 1/0)", nan
+ECHO: "atan2( 1/0,-1/0)", nan
+ECHO: "atan2(-1/0, 1/0)", nan
+ECHO: "atan2(-1/0,-1/0)", nan

Under 64 bit Windows TM this is fine, but running the 32 bit binary under 64 bit windows TM produces this alternate output. As noted in the links above, the 'standard' for Atan2 differs between manufacturers when it comes to infinities and NaNs.


There is also a bizarro bug under 64 bit windows that only affects OpenCSG and ThrownTogether rendering of infinites when used in transformations like translate() or rotate()

 ctest -R inf

http://files.openscad.org/tests/win_8664_amd-m880g-with_ewcb_report.html

The most bizarre part is that the ordinary 'echo tests' of infinities does not have any problem. It doesnt even have the 32-bit bug as noted above. Only the actual Preview (f5) drawing of transformed objects is a problem here.... f6 mode works fine. (Note the "Cubes" should not be drawn... they are normally removed because they have been rotated by infinity and/or NaN)

@donbright donbright changed the title atan2 and portability infinities, NaNs, Atan2, and Windows TM portability Apr 17, 2014
@kintel
Copy link
Member

kintel commented Oct 14, 2014

See also #978 for a simple test program and some results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants