There might already be a map function in NETMF but I’m not able to find it, so I stole some code from Arduino.
The map function is useful when you need to map a value from a known range over to another range. For example my control system gives me rudder values for my boat in the range -40 to +40 and I needed to map this over to servo period values ranging from 800 to 2200.
The map function looks like this;
private uint map(int x, int in_min, int in_max, int out_min, int out_max)
{
int Puls = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
return (uint)Puls;
}