Convert frequency to RGB

Jim Hurley jhurley at infostations.com
Mon Aug 11 22:31:31 EDT 2003


Dear Dar and Monte,

I should have specified more clearly what I need the conversion 
formula for. I am doing an optics/education stack. One of the 
substacks is on the physics of the rainbow. Actually that part is a 
little complicated. It involves a caustic formed by the light after 
it emerges from the drop after one internal reflection (for the 
primary bow)--a different caustic for each frequency. The light 
entering the drop is white--lots of frequencies. But since each 
frequency is refracted differently. It follows that the emergent 
light is composed of rays of pure frequency at each angle--if a ray 
at a given angle  were composite, each component would refract at a 
different angle. A prism does the same thing.

So I need a formula that gives Frequency to RGB and not RGB to 
frequency. As you have pointed out quite  correctly, RGB colors will 
be a mix of frequencies.

Although the *geometry* of the rays drawn by RunRev will be 
accurately represented on the screen since they are calculated using 
Snell's law given the index of refraction as a function of frequency. 
But the question is how give a reasonable *approximation* to the 
color of each ray and that is where the RGB values come in. I have 
done this in the stack that is posted on the RR education site for 
the seven conventional *discrete* colors (Roy G. Biv). (Aristotle 
said there were only three colors, but he has a thing about the 
number three.)

But I have had a thought about how to simulate a continuous variation 
in frequency of emerging light rays. So I would like a formula which 
allows for a continuous variation in color of the graphic lines. 
Actually I think the scheme I mentioned earlier might work. That is 
get an image with a smooth transition, left to right, from red to 
violet, use the imageData function to extract the RGB values and hope 
that something like a Switch--case wavelength > x and wavelength < y 
will yield a reasonably smooth, effective formula.

But I'll bet that someone has worked out a reasonable least squares 
fit (or whatever) of the tables you spoke of to reduce them to a nice 
simple algebraic formula.

Jim



More information about the use-livecode mailing list