FastLED 3.9.15
Loading...
Searching...
No Matches

◆ barycentric_xy()

bool fl::colorimetric_detail::barycentric_xy ( const float t[2],
const float A[2],
const float B[2],
const float C[2],
float bary[3] )
inline

Definition at line 102 of file rgbw_colorimetric.h.

103 {
104 const float v0x = B[0] - A[0], v0y = B[1] - A[1];
105 const float v1x = C[0] - A[0], v1y = C[1] - A[1];
106 const float v2x = t[0] - A[0], v2y = t[1] - A[1];
107 const float d00 = v0x * v0x + v0y * v0y;
108 const float d01 = v0x * v1x + v0y * v1y;
109 const float d11 = v1x * v1x + v1y * v1y;
110 const float d20 = v2x * v0x + v2y * v0y;
111 const float d21 = v2x * v1x + v2y * v1y;
112 const float den = d00 * d11 - d01 * d01;
113 if (fl::fabs(den) < 1e-20f) {
114 return false;
115 }
116 const float inv_den = 1.0f / den;
117 const float u = (d11 * d20 - d01 * d21) * inv_den;
118 const float v = (d00 * d21 - d01 * d20) * inv_den;
119 bary[0] = 1.0f - u - v;
120 bary[1] = u;
121 bary[2] = v;
122 return true;
123}
double fabs(double value) FL_NOEXCEPT
Definition math.h:509
FL_DISABLE_WARNING_PUSH unsigned char * B

References fl::B, fl::fabs(), FL_NOEXCEPT, and fl::t.

+ Here is the call graph for this function: