mirror of
https://github.com/encounter/SDL.git
synced 2025-12-11 06:27:44 +00:00
Fixed bug 2245 - add SDL_acos and SDL_asin
Sylvain Here's some code to add arc cosine, and arc sin functions to SDL_stdlib.c There are plainly written using SDL_atan.
This commit is contained in:
@@ -112,3 +112,29 @@ double atan(double x)
|
||||
}
|
||||
}
|
||||
libm_hidden_def(atan)
|
||||
|
||||
double SDL_acos(double val)
|
||||
{
|
||||
double result;
|
||||
if (val == -1.0) {
|
||||
result = M_PI;
|
||||
} else {
|
||||
result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
|
||||
if (result < 0.0)
|
||||
{
|
||||
result += M_PI;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
double SDL_asin(double val)
|
||||
{
|
||||
double result;
|
||||
if (val == -1.0) {
|
||||
result = -(M_PI / 2.0);
|
||||
} else {
|
||||
result = (M_PI / 2.0) - SDL_acos(val);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user