Perf: improve conversion to LCH by ~30%, avoid costly atan2

This commit is contained in:
Lovell Fuller 2020-07-19 15:29:03 +01:00
parent 72ca38cab0
commit a7357c5757

View File

@ -63,11 +63,6 @@ vips_col_ab2h( double a, double b )
{
double h;
#ifdef HAVE_ATAN2
h = VIPS_DEG( atan2( b, a ) );
if( h < 0.0 )
h += 360;
#else
/* We have to get the right quadrant!
*/
if( a == 0 ) {
@ -89,7 +84,6 @@ vips_col_ab2h( double a, double b )
else
h = VIPS_DEG( t + VIPS_PI );
}
#endif
return( h );
}
@ -97,13 +91,7 @@ vips_col_ab2h( double a, double b )
void
vips_col_ab2Ch( float a, float b, float *C, float *h )
{
#ifdef HAVE_ATAN2
*h = VIPS_DEG( atan2( b, a ) );
if( *h < 0.0 )
*h += 360;
#else
*h = vips_col_ab2h( a, b );
#endif
#ifdef HAVE_HYPOT
*C = hypot( a, b );