MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / evalPoly

Function evalPoly

pj_widgets/src/Colormap.cpp:36–43  ·  view source on GitHub ↗

Degree-6 RGB polynomial (Matt Zucker's matplotlib fits), Horner-evaluated. viridis and plasma differ only by this coefficient table (c[0]..c[6]).

Source from the content-addressed store, hash-verified

34// Degree-6 RGB polynomial (Matt Zucker's matplotlib fits), Horner-evaluated.
35// viridis and plasma differ only by this coefficient table (c[0]..c[6]).
36[[nodiscard]] ColormapRgb evalPoly(const ColormapRgb (&c)[7], float t) noexcept {
37 t = std::clamp(t, 0.0f, 1.0f);
38 ColormapRgb acc = c[6];
39 for (int i = 5; i >= 0; --i) {
40 acc = {c[i].r + t * acc.r, c[i].g + t * acc.g, c[i].b + t * acc.b};
41 }
42 return acc;
43}
44
45[[nodiscard]] ColormapRgb viridis(float t) noexcept {
46 static constexpr ColormapRgb kCoeffs[7] = {

Callers 2

viridisFunction · 0.85
plasmaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected