Just to add a super-pedantic side note: the transformation is not only a 1d scaling. See this by comparing the picture above to a screenshot from your solution:
Still though, your solution is close enough, fast and a very smart way to solve this. Very good!