def wavelengthToRGB(wavelength):
	gamma = 0.80;
	intensityMax = 255;

	""" Taken from Earl F. Glynn's web page:
	* <a href="http://www.efg2.com/Lab/ScienceAndEngineering/Spectra.htm">Spectra Lab Report</a>
	"""

	factor = None
	r = None
	g = None
	b = None

	if((wavelength >= 380) and (wavelength<440)):
		r = -(wavelength - 440) / (440.0 - 380.0)
		g = 0.0
		b = 1.0
	elif((wavelength >= 440) and (wavelength<490)):
		r = 0.0
		g = (wavelength - 440) / (490.0 - 440.0)
		b = 1.0
	elif((wavelength >= 490) and (wavelength<510)):
		r = 0.0
		g = 1.0
		b = -(wavelength - 510) / (510.0 - 490.0)
	elif((wavelength >= 510) and (wavelength<580)):
		r = (wavelength - 510) / (580.0 - 510.0)
		g = 1.0
		b = 0.0
	elif((wavelength >= 580) and (wavelength<645)):
		r = 1.0
		g = -(wavelength - 645) / (645.0 - 580.0)
		b = 0.0
	elif((wavelength >= 645) and (wavelength<781)):
		r = 1.0
		g = 0.0
		b = 0.0
	else:
		r = 0.0
		g = 0.0
		b = 0.0

	# Let the intensity fall off near the vision limits
	if((wavelength >= 380) and (wavelength<420)):
	    factor = 0.3 + 0.7*(wavelength - 380) / (420.0 - 380.0)
	elif((wavelength >= 420) and (wavelength<701)):
	    factor = 1.0
	elif((wavelength >= 701) and (wavelength<781)):
	    factor = 0.3 + 0.7*(780 - wavelength) / (780.0 - 700.0)
	else:
	    factor = 0.0

	# Don't want 0^x = 1 for x != 0

	r = int(round(intensityMax * pow(r * factor, gamma)))
	g = int(round(intensityMax * pow(g * factor, gamma)))
	b = int(round(intensityMax * pow(b * factor, gamma)))

	return (r, g, b)