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

◆ barycentric_xy()

bool fl::colorimetric_response::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 171 of file colorimetric_response.h.

172 {
173 const float v0x = B[0] - A[0], v0y = B[1] - A[1];
174 const float v1x = C[0] - A[0], v1y = C[1] - A[1];
175 const float v2x = t[0] - A[0], v2y = t[1] - A[1];
176 const float d00 = v0x * v0x + v0y * v0y;
177 const float d01 = v0x * v1x + v0y * v1y;
178 const float d11 = v1x * v1x + v1y * v1y;
179 const float d20 = v2x * v0x + v2y * v0y;
180 const float d21 = v2x * v1x + v2y * v1y;
181 const float den = d00 * d11 - d01 * d01;
182 if (fl::fabs(den) < 1e-20f) {
183 return false;
184 }
185 const float inv_den = 1.0f / den;
186 const float u = (d11 * d20 - d01 * d21) * inv_den;
187 const float v = (d00 * d21 - d01 * d20) * inv_den;
188 bary[0] = 1.0f - u - v;
189 bary[1] = u;
190 bary[2] = v;
191 return true;
192}
FL_DISABLE_WARNING_PUSH unsigned char * B
double fabs(double value) FL_NO_EXCEPT
Definition math.h:509

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

+ Here is the call graph for this function: