my $x = (($tap - $min) * ($new_max - $new_min) / ($max - $min)) + $new_min;