|
![](/i/fill.gif) |
I'm having a problem converting between units. Here is the code I'm
trying to adapt to POV-Ray:
https://github.com/THEjoezack/ColorMine/blob/master/ColorMine/ColorSpaces/Conversions/LchConverter.cs
internal static IRgb ToColor(ILch item)
{
var hRadians = item.H * Math.PI / 180.0;
var lab = new Lab
{
L = item.L,
A = Math.Cos(hRadians) * item.C,
B = Math.Sin(hRadians) * item.C
};
return lab.To<Rgb>();
}
Here is the POV-Ray version I created:
// input L = between 0 and 100
// input C = between 0 and 100
// input H = between 0 and 360
// output L = between 0 and 100
// output A = between -128 and +128
// output B = between -128 and +128
#macro CLCH2LAB(Color)
#local LCHFT = color Color;
#local L = LCHFT.red;
#local C = LCHFT.green;
#local H = LCHFT.blue;
#local hRadians = radians(H);
#local A = cos(hRadians) * C;
#local B = sin(hRadians) * C;
<L,A,B>
#end
When I plug the vector <50,50,180> into this function I get
<50.00000,-50.00000,0.00000> as a result. However, the Web converter
(http://colormine.org/convert/lch-to-lab) says it should be
<51.622535970468874,-37.18943330724933,2.558221480506817>
It's a simple function. I don't see anything obvious that is wrong with
it. Do you?
Mike
Post a reply to this message
|
![](/i/fill.gif) |