Extern :
- aggiunto FIST 6.8 ( già modificato per integrazione nelle nostre librerie).
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user