karansher / computer-graphics-raster-images

Computer Graphics Assignment about Raster Images
1 stars 0 forks source link

for rgb to hsv why do we have mod 6 for R max case? #80

Open woom221 opened 1 year ago

woom221 commented 1 year ago

H prime when R is maximum looks like

((G - B) / (max - min)) mod 6

however,

if we consider R max and assume B min,

we get

(G - B) / (R - B)

since G <= R, this is definitely less than 6 (less than or equal to 1)

even if we assume G is min,

(G - B) / (R - G)

if we consider B <= R, abs((G-B)/ (R-G)) is still less than or equal to 1.

So what is the point of mod 6 here?

abhimadan commented 1 year ago

See #35 - the mod 6 allows it to wrap around to be positive again, since we want our hue values to be positive angles.