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

Nils Lipp nlipp at hotmail.de
Sat Oct 29 18:54:33 CEST 2016

I was also confused with what values we should be dealing with. 0-1? 0-255?

Because usually when you think of RGB values, you would think of 0-255, but then I don't get why you would clamp to 0-1.

So am I  right thinking that we are supposed to use 0-1 and clamp( ) is (or can be) used in every addition/subtraction/multiplication/scaling opaeration so we dont end up with values  <0 and >1?

From: Cg1 <cg1-bounces at cg.uni-saarland.de> on behalf of Noshaba Cheema <s8nochee at stud.uni-saarland.de>
Sent: Saturday, October 29, 2016 4:35 PM
To: cg1 at cg.uni-saarland.de
Subject: [Cg1] Re: [CG1] clamp() in RGBColor

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.

Cg1 mailing list
Cg1 at cg.uni-saarland.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.cg.uni-saarland.de/pipermail/cg1/attachments/20161029/3cc1a9f9/attachment-0001.html>

More information about the Cg1 mailing list