What is the intuition behind mapping one range of numbers onto another range? If I have a range $x \to y$ and I want to map it to $x' \to y'$, what is the logic behind the mapping process? I found the formula online as:
$$R = (y' - x') / (y - x)$$
$$\text{output} = (\text{input} - x) * R + x'$$
I understand that $R$ is the ratio of both ranges, but I don't understand the second part where we subtract $x$ from the input? Why do we do this, I can't seem to wrap my head around this.

As per the hint given by the comments, I managed to derive the equation by using the point slope formula. I found the slope with the two points as described by dxiv and the rest smoothly followed.
EDIT:
The real confusion was actually the part where I didn't realize that the range could be thought of as being 
$$f(a) = a'$$
$$f(b) = b'$$
Once I realized this it all came together and made more sense. Nothing really beats understanding how to derive the formula instead of just remembering it.
