Nodejs Number Between between(a, b)

Here you can find the source of between(a, b)

Method Source Code

Number.prototype.between = function(a, b){
   return (this >= a && this < b);
}


function getDirection(ox, oy, tx, ty){
   var dx = tx - ox;
   var dy = ty - oy;
   var rad = Math.atan2(dx, dy);
   var degree = (rad*180)/Math.PI;
   if( degree < 0 ) degree += 360;
   if( degree.between(0, 22.5) || degree.between(337.5, 360) ){
      return 'n';
   }else if( degree.between(22.5, 67.5) ){
      return 'nw';
   }else if( degree.between(67.5, 112.5) ){
      return 'w';
   }else if( degree.between(112.5, 157.5) ){
      return 'sw';
   }else if( degree.between(157.5, 202.5) ){
      return 's';
   }else if( degree.between(202.5, 247.5) ){
      return 'se';
   }else if( degree.between(247.5, 292.5) ){
      return 'e';
   }else if( degree.between(292.5, 337.5) ){
      return 'ne';
   }//from www  . j  av  a 2s .c  o m


   return 'w';
}

Related

  1. between( a, b )
    Number.prototype.between = function( a, b ) {
        return a <= this && b >= this ||
               b <= this && a >= this;
    
  2. between()
    Number.prototype.between = function() {
      return this > arguments[0] && this < arguments[1];
    };
    
  3. between(a, b)
    Number.prototype.between = function(a, b) {
      var min = Math.min.apply(Math, [a, b]),
        max = Math.max.apply(Math, [a, b]);
      return this > min && this < max;
    };
    
  4. between(a, b, inclusive)
    Number.prototype.between = function (a, b, inclusive) {
        var min = Math.min.apply(Math, [a, b]),
            max = Math.max.apply(Math, [a, b]);
        return inclusive ? this >= min && this <= max : this > min && this < max;
    };
    
  5. between(a, b, inclusive)
    http:
    Number.prototype.between = function (a, b, inclusive) {
        var min = Math.min.apply(Math, [a,b]),
            max = Math.max.apply(Math, [a,b]);
        return inclusive ? this >= min && this <= max : this > min && this < max;
    };
    
  6. between(a, b, inclusive)
    Number.prototype.between = function (a, b, inclusive) {
        var min = Math.min.apply(Math, [a,b]),
            max = Math.max.apply(Math, [a,b]);
        return inclusive ? this >= min && this <= max : this > min && this < max;
    };
    
  7. between(n1, n2)
    Number.prototype.between = function(n1, n2){
      var min = (n1 < n2) ? n1 : n2,
          max = (n1 < n2) ? n2 : n1;
      return this >= min && this <= max;