| Summary: | add SDL_acos and SDL_asin | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Sylvain <sylvain.becker> |
| Component: | *don't know* | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
src for SDL_acos and SDL_asin
new version asin acos + test case |
||
Looks pretty good... When is this condition true? if (val > 1e-6 && val < -1e-6) Actually never, this is a mistake. I wanted to write: if (val > -1e^-6 && val < 1e^-6) to avoid the division by 0. but this has been catched anyway by SDL_atan, because it gave me the correct results with my test cases. (but I dont know if this would have been also catched by the ulibc version ?) sin() asin() mismatch at -PI/2: Unexpected result: y = -1.570796, x = -1.000000, result = 1.570796 Created attachment 1449 [details]
new version asin acos + test case
new version of asin/acos + test case printf
yes a modulo 2 PI problem. I also check the "-inf and +inf" and also the "+0 and -O" Okay, I treat 0 and -0 as equivalent, and I never got -nan result in my testing, so here's the code I checked in: https://hg.libsdl.org/SDL/rev/13da154af020 Thanks! ok thanks great ! This is not a problem for me, but for information I now get the difference on -NaN and -O. here's some log I got on linux : case -2.000000. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case -1.685841. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case -1.371681. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case -1.057522. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case -0.743363. asin=-0.838084 SDL_asin=-0.838084 acos=2.408880 SDL_acos=2.408880 case -0.429204. asin=-0.443611 SDL_asin=-0.443611 acos=2.014407 SDL_acos=2.014407 case -0.115044. asin=-0.115300 SDL_asin=-0.115300 acos=1.686096 SDL_acos=1.686096 case 0.199115. asin=0.200455 SDL_asin=0.200455 acos=1.370342 SDL_acos=1.370342 case 0.513274. asin=0.538995 SDL_asin=0.538995 acos=1.031801 SDL_acos=1.031801 case 0.827433. asin=0.974522 SDL_asin=0.974522 acos=0.596275 SDL_acos=0.596275 case 1.141593. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case 1.455752. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case 1.769911. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case inf. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case -inf. asin=nan SDL_asin=-nan acos=nan SDL_acos=-nan case 0.000000. asin=0.000000 SDL_asin=0.000000 acos=1.570796 SDL_acos=1.570796 case -0.000000. asin=-0.000000 SDL_asin=0.000000 acos=1.570796 SDL_acos=1.570796 case 1.000000. asin=1.570796 SDL_asin=1.570796 acos=0.000000 SDL_acos=0.000000 case -1.000000. asin=-1.570796 SDL_asin=-1.570796 acos=3.141593 SDL_acos=3.141593 Also, it seems to compile correctly on linux, but on android it bring an undefined reference ! I just built on Android with no problems. What are you seeing? I see a link error when building androind while using the function ! "libm" seems not to be in the Android.mk file |
Created attachment 1448 [details] src for SDL_acos and SDL_asin Here's some code to add arc cosine, and arc sin functions to SDL_stdlib.c There are plainly written using SDL_atan.