I have written a lib for working with colours and stuck trying to calculate Tc(k)
. From what I have read working in the CIE 1931 XYZ
colour space i
The Wikipedia states that the color temperature is calculated by considering the u-v chromaticities, not x-y, so you have to perform a translation. That said, I recommend using an approximation (also explained in the Wikipedia) as suggested by @sixlettervariables.
The real question is, what are you trying to find the color temperature of?. I see a reference (#FF0000) to RGB colors, which are meaningless without stating a color space. Supposing you are in sRGB (so I can point you at Wikipedia again), you have to first obtain the linear RGB co-ordinates before proceeding to XYZ.