1_ In one of my software projects, I need to implement Planck's Law in terms of wavelength. I can't be sure if it's right because I've seen different variations of it, and all the implementations that I've tried give different results (besides, it's been years since I've had to do physics). Could someone verify that it's correct? Have I got the units right?
It looks something like this, and it's the implementation of Planck's Law in terms of wavelength found on this wikipedia page:
h = 6.6260695729e-34 J*s
k = 1.3806488e-23 J*K^-1
c = 2.998e8 m/s
c2 = pow(c, 2) m^2/s^2
h_c = h * c
_2_h_c2 = 2.0 * h * c2
planck(wavelength, temp) {
return _2_h_c2 / (pow(wavelength, 5.0) * (exp(h_c / (wavelength * k * temp)) - 1.0))
}
temp is the temperature in Kelvins, and wavelength is in nanometers.
2_ If I wanted it normalized about 555nm, similar to this wikipedia page, what would it look like? This is what I have so far, but, again, I can't be sure if it's right:
planck(wavelength, temp) {
Real norm = pow(555.0, 5.0) * (exp(h_c / (555.0 * k * temp)) - 1.0);
return norm / (pow(wavelength, 5.0) * (exp(h_c / (wavelength * k * temp)) - 1.0));
}
3_ Say I have an array of wavelengths from 360nm to 830nm, in increments of 5nm, and I apply the planck function with temperature of 6504k to each wavelength, and store the results in a new array. If I use this new array (spectral power distribution) and calculate the XYZ values for it, it should match CIE Standard Illuminant D65, should it not?