add luz_spectrum_interpolate_nm

parent 41bdc209
......@@ -550,7 +550,7 @@ static void add_items ()
}
#endif
#if 1
#if 0
float rgb[3];
for (rgb[0] = 0.0; rgb[0] <= 1.0; rgb[0] += 0.1)
for (rgb[1] = 0.0; rgb[1] <= 1.0; rgb[1] += 0.1)
......@@ -559,6 +559,20 @@ static void add_items ()
add_item (luz, COLORITTO_RGB, &rgb[0], 0.01);
}
#endif
#if 1
{
float rgb[3]={1,0,0};
add_item (luz, COLORITTO_RGB, &rgb[0], 0.01);
}
{
float rgb[3]={0,1,0};
add_item (luz, COLORITTO_RGB, &rgb[0], 0.01);
}
{
float rgb[3]={0,0,1};
add_item (luz, COLORITTO_RGB, &rgb[0], 0.01);
}
#endif
#if 0
......
......@@ -1044,3 +1044,19 @@ Spectrum luz_coats_to_spectrum (Luz *luz,
{
return coats_to_spectrum (luz, coat_levels);
}
/* for now, linear interpolation */
float luz_spectrum_interpolate_nm (Spectrum *spectrum, float nm)
{
float offset = (nm - LUZ_SPECTRUM_START) / LUZ_SPECTRUM_GAP;
float delta;
if (offset < 0)
return spectrum->bands[0];
delta = offset - ((int)offset);
if (offset >= LUZ_SPECTRUM_START + LUZ_SPECTRUM_GAP * LUZ_SPECTRUM_BANDS)
{
return spectrum->bands[LUZ_SPECTRUM_BANDS-1];
}
return spectrum->bands[(int)offset] * (1.0-delta) +
spectrum->bands[(int)offset+1] * delta;
}
......@@ -79,6 +79,8 @@ void luz_spectrum_to_xyz (Luz *luz,
float *y,
float *z);
float luz_spectrum_interpolate_nm (Spectrum *spectrum, float nm);
struct _Spectrum {
float bands[LUZ_SPECTRUM_BANDS];
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment