code: public static float mapPoint(float x, float sourceStart, float sourceEnd,
        float targetStart, float targetEnd) {
  
      if (x <= sourceStart) {
        return targetStart;
      }
  
      if (x >= sourceEnd) {
        return targetEnd;
      }
  
      return (x - sourceStart) / (sourceEnd - sourceStart)
          * (targetEnd - targetStart) + targetStart;
    }
docs: This method maps a number x, which is in the range [sourceStart,
  sourceEnd], to a new range [targetStart, targetEnd]
  
  <p>
  sourceStart <= x <= sourceEnd <br/>
  targetStart <= returnValue <= targetEnd
  </p>
  
  @param x
  The value that should be mapped
  @param sourceStart
  The source range start (inclusive)
  @param sourceEnd
  The source range end (inclusive)
  @param targetStart
  The target range start (inclusive)
  @param targetEnd
  The target range end (inclusive)
  @return The corresponding value of x in the target range