Nodejs Number Value Map map(istart, istop, ostart, ostop)

Here you can find the source of map(istart, istop, ostart, ostop)

Method Source Code

Number.prototype.map = function (istart, istop, ostart, ostop) {
    return ostart + (ostop - ostart) * ((this - istart) / (istop - istart));
};

Related

  1. map( in_min , in_max , out_min , out_max )
    Number.prototype.map = function ( in_min , in_max , out_min , out_max ) {
      return ( this - in_min ) * ( out_max - out_min ) / ( in_max - in_min ) + out_min;
    
  2. map(in_min, in_max, out_min, out_max)
    Number.prototype.map = function (in_min, in_max, out_min, out_max) {
      return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
    Math.radians = function(degrees) {
      return degrees * Math.PI / 180;
    };
    
  3. map(in_min, in_max, out_min, out_max)
    Number.prototype.map = function (in_min, in_max, out_min, out_max) {
        return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
    };
    
  4. map(in_min, in_max, out_min, out_max)
    Number.prototype.map = function (in_min, in_max, out_min, out_max) {
      return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
    function convertToRange(value, srcRange, dstRange){
      if (value < srcRange[0] || value > srcRange[1]){
        return NaN; 
      var srcMax = srcRange[1] - srcRange[0],
        dstMax = dstRange[1] - dstRange[0],
    ...
    
  5. map(in_min, in_max, out_min, out_max)
    Number.prototype.map = function (in_min, in_max, out_min, out_max) {
        return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
    
  6. limit(min, max)
    Number.prototype.limit = function(min, max) {
        var i = this;
        if (i < min) i = min;
        if (i > max) i = max;
        return i;
    };
    
  7. limit(min, max)
    Number.prototype.limit = function (min, max) {
        return Math.min(max, Math.max(min, this));
    };