deps/kb_meme/meme-5.0.1/src/alph-in.c
/*
 * lab_dist
 * Calculate how different two colours look.
 */
lab_dist
Calculate how different two colours look.
lab_dist Calculate how different two colours look .
static double lab_dist(LAB_COLOUR_T lab1, LAB_COLOUR_T lab2) {
  double c1, c2, dc, dl, da, db, dh, dh_squared, first, second, third;
  c1 = sqrt((lab1.l * lab1.l) + (lab1.a * lab1.a));
  c2 = sqrt((lab2.l * lab2.l) + (lab2.a * lab2.a));
  dc = c1 - c2;
  dl = lab1.l - lab2.l;
  da = lab1.a - lab2.a;
  db = lab1.b - lab2.b;
  dh_squared = (da * da) + (db * db) - (dc * dc);
  dh = (dh_squared > 0 ? sqrt(dh_squared) : 0);
  first = dl;
  second = dc / (1.0 + (0.045 * c1));
  third = dh / (1.0 + (0.015 * c1));
  return sqrt((first * first) + (second * second) + (third * third));
}
static double lab_dist ( LAB_COLOUR_T lab1 , LAB_COLOUR_T lab2 ) { double c1 , c2 , dc , dl , da , db , dh , dh_squared , first , second , third ; c1 = sqrt ( ( lab1 . l * lab1 . l ) + ( lab1 . a * lab1 . a ) ) ; c2 = sqrt ( ( lab2 . l * lab2 . l ) + ( lab2 . a * lab2 . a ) ) ; dc = c1 - c2 ; dl = lab1 . l - lab2 . l ; da = lab1 . a - lab2 . a ; db = lab1 . b - lab2 . b ; dh_squared = ( da * da ) + ( db * db ) - ( dc * dc ) ; dh = ( dh_squared > 0 ? sqrt ( dh_squared ) : 0 ) ; first = dl ; second = dc / ( 1.0 + ( 0.045 * c1 ) ) ; third = dh / ( 1.0 + ( 0.015 * c1 ) ) ; return sqrt ( ( first * first ) + ( second * second ) + ( third * third ) ) ; }
lab_dist
 Calculate how different two colours look.
lab_dist Calculate how different two colours look .
// we don't want NaN due to rounding errors so fudge things a bit...