@@ -25,7 +25,8 @@ IGL_INLINE void igl::hsv_to_rgb(
// From medit
double f,p,q,t,hh;
int i;
- hh = ((int)h % 360) / 60.;
+ // shift the hue to the range [0, 360] before performing calculations
+ hh = ((360 + ((int)h % 360)) % 360) / 60.;
i = (int)std::floor(hh); /* largest int <= h */
f = hh - i; /* fractional part of h */
p = v * (1.0 - s);
@@ -14,7 +14,7 @@ namespace igl
// Convert RGB to HSV
//
// Inputs:
- // h hue value (degrees: [0,360])
+ // h hue value (degrees: [0,360]. Values outside this range will be mapped periodically to [0,360].)
// s saturation value ([0,1])
// v value value ([0,1])
// Outputs: