/** * vips_col_ab2h: * @a: CIE a * @b: CIE b * * Returns: Hue (degrees) */ double vips_col_ab2h( double a, double b ) { double h; /* We have to get the right quadrant! */ if( a == 0 ) { if( b < 0.0 ) h = 270; else if( b == 0.0 ) h = 0; else h = 90; } else { double t = atan( b / a ); if( a > 0.0 ) if( b < 0.0 ) h = VIPS_DEG( t + VIPS_PI * 2.0 ); else h = VIPS_DEG( t ); else h = VIPS_DEG( t + VIPS_PI ); } return( h ); }
/** * vips_col_ab2h: * @a: CIE a * @b: CIE b * * Returns: Hue (degrees) */ double 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 ) { if( b < 0.0 ) h = 270; else if( b == 0.0 ) h = 0; else h = 90; } else { double t = atan( b / a ); if( a > 0.0 ) if( b < 0.0 ) h = VIPS_DEG( t + VIPS_PI * 2.0 ); else h = VIPS_DEG( t ); else h = VIPS_DEG( t + VIPS_PI ); } #endif return( h ); }
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 ); #else *C = sqrt( a * a + b * b ); #endif }