Definition at line 559 of file rt_util.c.
559 {
560 int i;
561
562 double minc;
563 double maxc;
564
565 double h = 0.;
567 double v = 0.;
568
569 minc = rgb[0];
570 maxc = rgb[0];
571
572
573 for (i = 1; i < 3; i++) {
574 if (rgb[i] > maxc)
575 maxc = rgb[i];
576 if (rgb[i] < minc)
577 minc = rgb[i];
578 }
579 v = maxc;
580
581 if (maxc != minc) {
582 double diff = 0.;
583 double rc = 0.;
584 double gc = 0.;
585 double bc = 0.;
586 double junk = 0.;
587
588 diff = maxc - minc;
590 rc = (maxc - rgb[0]) / diff;
591 gc = (maxc - rgb[1]) / diff;
592 bc = (maxc - rgb[2]) / diff;
593
595 h = bc - gc;
596 else if (
DBL_EQ(rgb[1], maxc))
597 h = 2.0 + rc - bc;
598 else
599 h = 4.0 + gc - rc;
600
601 h = modf((h / 6.0), &junk);
602 }
603
604 hsv[0] = h;
606 hsv[2] = v;
607
609}
References DBL_EQ, ES_NONE, and s.
Referenced by test_rgb_to_hsv().