- aggiunto FIST 6.8 ( già modificato per integrazione nelle nostre librerie).
This commit is contained in:
SaraP
2025-03-04 16:37:58 +01:00
parent f5f6a9cb47
commit 05ca0d3376
24 changed files with 4148 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
inline double atan2(const double &y, const double &x)
{
if( fabs(x) >= fabs(y) )
{
// Sector to the right
if( x > 0 )
{
const double phi = y/x;
return atan(phi);
}
// Sector to the left
else if( x < 0 )
{
const double phi = y/x;
if( y >= 0) {
return atan(phi) + M_PI;
} else {
return atan(phi) - M_PI;
}
}
// Hence, x and y are zero
else
{
return 0.0;
}
}
else if( fabs(y) >= fabs(x) )
{
// Sector to the top
if( y > 0 )
{
const double phi = x/y;
return M_PI_2 - atan(phi);
}
// Sector to the bottom
if( y < 0 )
{
const double phi = x/y;
return - M_PI_2 - atan(phi);
}
// Actually, the impossible case, x=y=0. Should be catched above.
else
{
assert(false);
return 0.0;
}
}
// This can only happen, if x or y is NaN.
else
{
return 0.0;
}
}