In general, you can map the range $[a_1, b_1]$ to the range $[a_2, b_2]$ with a linear equation.
You need $f(a_1) = a_2$, and $f(b_1) = b_2$. Since we'll be using a linear equation, $f(x) = mx+c$, we get a system of equations:
\begin{align*}
a_2 &= ma_1 + c \\
b_2 &= mb_1 + c
\end{align*}
and we may subtract the second from the first, so that
$$a_2 - b_2 = m(a_1 - b_1),$$ in other words, $m = \frac{a_2 - b_2}{a_1 - b_1}.$ To find $c$, we can simply substitute our $m$-value in, to see that
\begin{align*}
a_2 &= ma_1 + c\\
a_2 - ma_1 &= c.\\
\end{align*}
Thus, if you store the value $m = \frac{a_2 - b_2}{a_1 - b_1}$, your equation sending the interval $[a_1, a_2]$ to the interval $[a_2, b_2]$ will be given by
$$f(x) = mx + a_2 - ma_1 = m(x - a_1) + a_2 .$$