code: public static double scale(double x, double fromMin, double fromMax,
              double toMin, double toMax, boolean bounded) {
          double result = (toMax - toMin) / (fromMax - fromMin) * (x - fromMin)
                  + toMin;
          return bounded ? Op.bound(x, toMin, toMax) : result;
      }
docs: Linearly interpolates the parameter `x` in range `[fromMin,fromMax]` to
  a new value in the range `[toMin,toMax]`, truncated to the range
  `[toMin,toMax]` if bounded is `true`.
  
  @param x is the source value to interpolate
  @param fromMin is the minimum value of the source range
  @param fromMax is the maximum value of the source range
  @param toMin is the minimum value of the target range
  @param toMax is the maximum value of the target range
  @param bounded determines whether the resulting value is bounded to the
  range
  @return the source value linearly interpolated to the target range:
  ` y = y_a + (y_b - y_a) \dfrac{x-x_a}{x_b-x_a} `