Mapping uint to value within min/max set
I would recommend considering this using more explicitly the Two-Point Equation of a Line. Your code is basically doing the same thing, but thinking more explicitly in terms of the underlying mathematics would help avoid errors or extra complication.

Here is how I would implement this:


public static uint LinearTransform(uint x, uint x1, uint y1, uint x2, uint y2) {
    ulong a = (ulong)(y2 - y1)*(x - x1);
    uint b = (x2 - x1);
    return (uint)(a/b) + (a%b*2 >= b)?1:0 + y2;
}


I don't actually know C#, so it is likely that the code is not syntactically correct, or breaks the style rules of the language, but it should get the point across.

The (a%b*2 &gt;= b)?1:0 term is to compensate for the way integer division always truncates to zero. This will make it instead round up if the fractional part would be 1/2 or more, so we don't need to do any floating point computations.

This function can then be used to perform your original task by calling it as LinearTransform(input, 0, min, uint.MaxValue, max).