mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-06 03:50:26 +01:00
mesa: fix/improve the atan(y,x) function
This commit is contained in:
parent
8336fbc35c
commit
91de7b6cd3
1 changed files with 11 additions and 10 deletions
|
|
@ -401,16 +401,17 @@ vec4 atan(const vec4 y_over_x)
|
|||
|
||||
float atan(const float y, const float x)
|
||||
{
|
||||
if (x == 0.0)
|
||||
return 0.0;
|
||||
float z = atan(y / x);
|
||||
if (x < 0.0)
|
||||
{
|
||||
if (y < 0.0)
|
||||
return z - 3.141593;
|
||||
return z + 3.141593;
|
||||
}
|
||||
return z;
|
||||
float r;
|
||||
if (abs(x) > 1.0e-4) {
|
||||
r = atan(y / x);
|
||||
if (x < 0.0) {
|
||||
r = r + sign(y) * 3.141593;
|
||||
}
|
||||
}
|
||||
else {
|
||||
r = sign(y) * 1.5707965; // pi/2
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
vec2 atan(const vec2 u, const vec2 v)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue