FastLED 3.10.6
Loading...
Searching...
No Matches

◆ sourcePrimariesEncloseAreaQ16()

bool fl::anonymous_namespace{source_xyz.cpp.hpp}::sourcePrimariesEncloseAreaQ16 ( const i32(&) r[2],
const i32(&) g[2],
const i32(&) b[2] )

True when the three primaries enclose an actual area of chromaticity.

A near-singular primary set passes any determinant guard as rounding noise, so the degeneracy is caught geometrically: twice the triangle's area, in Q32, against 1e-4 (sRGB's is 0.224). Measured on the float path, red and green identical gave a determinant of -1.09e-7 and an inverse of pure noise.

Definition at line 32 of file source_xyz.cpp.hpp.

33 {
34 const i64 ux = static_cast<i64>(g[0]) - r[0];
35 const i64 uy = static_cast<i64>(g[1]) - r[1];
36 const i64 vx = static_cast<i64>(b[0]) - r[0];
37 const i64 vy = static_cast<i64>(b[1]) - r[1];
38 const i64 twice_area_q32 = ux * vy - uy * vx;
39 constexpr i64 kMinTwiceAreaQ32 = 429497; // 1e-4 * 2^32
40 return twice_area_q32 > kMinTwiceAreaQ32 || twice_area_q32 < -kMinTwiceAreaQ32;
41}
InputGamut g
Definition rgbw.h:124
fl::i64 i64
Definition stdint.h:221

References fl::FL_NO_EXCEPT, fl::g, and sourcePrimariesEncloseAreaQ16().

Referenced by sourcePrimariesEncloseAreaQ16().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: