42 static constexpr scalar
oneThird = 1.0 / 3.0;
44 static constexpr scalar
twoThird = 2.0 / 3.0;
45 static constexpr scalar
fiveSixth = 5.0 / 6.0;
51 const scalar r,
const scalar
g,
const scalar
b,
52 scalar&
h, scalar&
s, scalar& v
55 scalar cmin = r, cmax = r;
75 s = (v > 0.0) ? ((cmax - cmin) / cmax) : 0.0;
107 const scalar
h,
const scalar
s,
const scalar v,
108 scalar& r, scalar&
g, scalar&
b 155 r = (
s * r + (1.0 -
s));
156 g = (
s *
g + (1.0 -
s));
157 b = (
s *
b + (1.0 -
s));
166 static inline scalar
to_XYZ(scalar val)
168 const scalar p3 =
pow3(val);
169 return (p3 > 0.008856 ? p3 : (val - 16.0 / 116.0) / 7.787);
176 return (val > 0.008856) ?
cbrt(val) : (7.787 * val) + (16.0 / 116.0);
180 static constexpr scalar
ref_X = 0.9505;
181 static constexpr scalar
ref_Y = 1.000;
182 static constexpr scalar
ref_Z = 1.089;
186 const scalar
L,
const scalar a,
const scalar
b,
187 scalar&
x, scalar&
y, scalar& z
190 const scalar var_Y = (
L + 16.0) / 116.0;
191 const scalar var_X = a / 500 + var_Y;
192 const scalar var_Z = var_Y -
b / 200;
202 const scalar
x,
const scalar
y,
const scalar z,
203 scalar&
L, scalar& a, scalar&
b 210 L = (116 * var_Y) - 16;
211 a = 500 * (var_X - var_Y);
212 b = 200 * (var_Y - var_Z);
224 ? (1.055 * (
pow(val, 1.0/2.4)) - 0.055)
235 ? (
pow((val + 0.055) / 1.055, 2.4))
244 const scalar
x,
const scalar
y,
const scalar z,
245 scalar& r, scalar&
g, scalar&
b 254 if (cmax <
g) cmax =
g;
255 if (cmax <
b) cmax =
b;
271 scalar r, scalar
g, scalar
b,
272 scalar&
x, scalar&
y, scalar& z
279 x = r * 0.4124 +
g * 0.3576 +
b * 0.1805;
280 y = r * 0.2126 +
g * 0.7152 +
b * 0.0722;
281 z = r * 0.0193 +
g * 0.1192 +
b * 0.9505;
290 const scalar&
L = lab[0];
291 const scalar& a = lab[1];
292 const scalar&
b = lab[2];
295 msh[1] = (msh[0] > 0.001) ?
acos(
L / msh[0]) : 0.0;
296 msh[2] = (msh[1] > 0.001) ?
atan2(
b,a) : 0.0;
303 lab[0] = msh[0]*
cos(msh[1]);
304 lab[1] = msh[0]*
sin(msh[1])*
cos(msh[2]);
305 lab[2] = msh[0]*
sin(msh[1])*
sin(msh[2]);
310 static inline scalar
angleDiff(scalar angle1, scalar angle2)
312 scalar adiff = angle1 - angle1;
313 if (adiff < 0.0) adiff = -adiff;
325 if (msh[0] >= unsatM - 0.1)
333 const scalar hueSpin =
334 msh[1]*
sqrt(unsatM*unsatM - msh[0]*msh[0]) / (msh[0]*
sin(msh[1]));
339 return msh[2] + hueSpin;
343 return msh[2] - hueSpin;
354 RGB_to_HSV(rgb[0], rgb[1], rgb[2], hsv[0], hsv[1], hsv[2]);
359 HSV_to_RGB(hsv[0], hsv[1], hsv[2], rgb[0], rgb[1], rgb[2]);
365 RGB_to_XYZ(rgb[0], rgb[1], rgb[2], xyz[0], xyz[1], xyz[2]);
370 XYZ_to_RGB(xyz[0], xyz[1], xyz[2], rgb[0], rgb[1], rgb[2]);
376 LAB_to_XYZ(lab[0], lab[1], lab[2], xyz[0], xyz[1], xyz[2]);
382 XYZ_to_LAB(xyz[0], xyz[1], xyz[2], lab[0], lab[1], lab[2]);
389 RGB_to_XYZ(rgb[0], rgb[1], rgb[2], xyz[0], xyz[1], xyz[2]);
390 XYZ_to_LAB(xyz[0], xyz[1], xyz[2], lab[0], lab[1], lab[2]);
430 scalar Mmid =
std::max(msh1[0], msh2[0]);
431 Mmid =
std::max(scalar(88.0), Mmid);
434 msh2[0] = Mmid; msh2[1] = 0; msh2[2] = 0;
439 msh1[0] = Mmid; msh1[1] = 0; msh1[2] = 0;
447 if ((msh1[1] < 0.05) && (msh2[1] > 0.05))
451 else if ((msh2[1] < 0.05) && (msh1[1] > 0.05))
479 if (hsv1[0] - hsv2[0] > 0.5 || hsv2[0] - hsv1[0] > 0.5)
481 if (hsv1[0] > hsv2[0])
Different types of constants.
dimensionedScalar acos(const dimensionedScalar &ds)
static constexpr scalar ref_X
const vector L(dict.get< vector >("L"))
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void mshToLab(const vector &msh, vector &lab)
Convert from special polar version of CIELAB.
dimensionedScalar sqrt(const dimensionedScalar &ds)
static constexpr scalar oneSixth
static constexpr scalar fiveSixth
static constexpr scalar oneThird
static scalar adjustHue(const vector &msh, scalar unsatM)
static void RGB_to_HSV(const scalar r, const scalar g, const scalar b, scalar &h, scalar &s, scalar &v)
dimensionedScalar cos(const dimensionedScalar &ds)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
static void RGB_to_XYZ(scalar r, scalar g, scalar b, scalar &x, scalar &y, scalar &z)
constexpr scalar twoPi(2 *M_PI)
static void XYZ_to_LAB(const scalar x, const scalar y, const scalar z, scalar &L, scalar &a, scalar &b)
static scalar gamma_from_xyz(const scalar val)
static void HSV_to_RGB(const scalar h, const scalar s, const scalar v, scalar &r, scalar &g, scalar &b)
static scalar to_XYZ(scalar val)
dimensionedScalar cbrt(const dimensionedScalar &ds)
static scalar angleDiff(scalar angle1, scalar angle2)
constexpr scalar pi(M_PI)
static void LAB_to_XYZ(const scalar L, const scalar a, const scalar b, scalar &x, scalar &y, scalar &z)
static scalar gamma_to_xyz(const scalar val)
static constexpr scalar ref_Z
const uniformDimensionedVectorField & g
dimensionedScalar sin(const dimensionedScalar &ds)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
static scalar from_XYZ(scalar val)
const dimensionedScalar h
Planck constant.
void labToMsh(const vector &lab, vector &msh)
Convert to special polar version of CIELAB.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar pow3(const dimensionedScalar &ds)
static void XYZ_to_RGB(const scalar x, const scalar y, const scalar z, scalar &r, scalar &g, scalar &b)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static constexpr scalar ref_Y
static constexpr scalar twoThird