Ensure translated value does not blow up

This commit is contained in:
2023-02-23 12:54:42 +02:00
parent 59d20e121d
commit 5f7c16c2bb

View File

@@ -184,8 +184,13 @@ public:
{ {
float lspan = lmax - lmin; float lspan = lmax - lmin;
float rspan = rmax - rmin; float rspan = rmax - rmin;
val = (val - lmin) / lspan; float out = (val - lmin) / lspan;
return rmin + (val * rspan); out = rmin + (val * rspan);
// Ensure that output is within bounds
out = std::max(rmin, out);
out = std::min(rmax, out);
return out;
} }
/** /**