I'm calculating the Correlated Color Temperature (CCT) from a chromacity pair, and I am trying to find how far from the Planckian Locus the coordinates are.
What I'm currently doing is I read RGB values off a sensor, I do a matrix transformation to get to XYZ. Then I calculate the xy values, and lastly I use McCamy’s formula to get CCT.
McCamy’s formula gives me the Correlated Color Temperature, the nearest point along the Planckian Locus for the xy coordinates (roughly a orange to blue axis). I am trying to find the green/magenta content of the light, so I need to find how far from the locus the coordinates are (roughly a green to magenta axis).
I guess McCamy’s formula finds the normal down to the locus, and that I need to calculate how long that normal is. I also have to do it fast (this is running on a small embedded processor). I'm using the CIE 1931 color space. (EDIT: The illustration is from CIE 1960 as pointed out below, but I could not find a chart showing isothermal lines for CIE 1931)