Ensure translated value does not blow up
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user