[Cg1] Re: [CG1] clamp() in RGBColor

Noshaba Cheema s8nochee at stud.uni-saarland.de
Sat Oct 29 16:35:50 CEST 2016


Since "clamp()" is supposed to clamp the color in a range [0, 1], I  
guess the colors you will be working with, will also be the  
"normalized" colors (so 1 for a value of 255 and 0 for a value of 0).  
I guess clamp() is just to make sure that you have values in that  
range, so e.g. some of you operations create an RGB color like  
(0.5,-0.3, 1.7). Then this color should be clamped to RGB(0.5,0,1). So  
everything that is below 0, should be clamped to 0, everything that is  
above 1 should be clamped to 1.


Quoting 강효승 <fordicus at naver.com>:

> Please deal with 2nd question of mine here.
>
> >> Clamp() in color.h
> Yes, we know its member variables are declared to be "float"
> But we don't know what is going to happen when we actually do render  
> in future with them.
>
>
> [Q] What is the exact boundary of "RGBColor" in real number?
> Is "clamp()" something like below??
>
> Given RGBColor c(R, G, B)
> with R[0,255], G[0,255], B[0,255],
>
> c.clamp() "DO NORMALIZE" the color components
> into R[0, 1], G[0, 1], B[0, 1]???
>
> clamp() { [0 : 255] -> [0 : 1] }
>
>
> The expression clamp or clamps look insufficient without examples.
> Furthermore, these problems seem to be recurring problems also in  
> other requirements of assignments.
> I wish we could have more detailed info. for our goals, and some  
> example outputs on each function will definitely be helpful.





More information about the Cg1 mailing list