VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-full/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/adapt__Math.js
/*** module: adapt/Math.js ***/
"use strict";

/**
 * 
 * @param {number} x 
 * @param {number} l
 * @param {number} h
 * @param {number} L
 * @param {number} H
 * @returns {number}
 */
Math.map = function (x, l, h, L, H) {
  return (x - l) / (h - l) * (H - L) + L;
};
/**
 * Returns a random number between min (inclusive) and max (exclusive)
 */


Math.randomArbitrary = function (min, max) {
  return Math.random() * (max - min) + min;
};
/**
 * Returns a random integer between min (inclusive) and max (inclusive)
 * Using Math.round() will give you a non-uniform distribution!
 */


Math.randomInt = function (min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
};

Math.randomPick = function (arr) {
  var id = Math.randomInt(0, arr.length - 1);
  return arr[id];
};

Math.sumArr = function (arr) {
  var res = 0;

  for (var i = 0; i < arr.length; ++i) res += arr[i];

  return res;
};

Math.Vec2 = function (x, y) {
  this.x = x;
  this.y = y;
};

Math.Vec2.prototype.copy = function () {
  return new Math.Vec2(this.x, this.y);
};

Math.Vec2.prototype.toString = function () {
  return "(" + this.x + ", " + this.y + ")";
};

Math.Vec2.prototype.abs = function () {
  return Math.sqrt(this.x * this.x + this.y * this.y);
};

Math.Vec2.prototype.normalized = function () {
  var l = this.abs();
  if (l == 0) l = 1;
  return this.div(l);
};

Math.Vec2.prototype.mult = function (h) {
  return new Math.Vec2(this.x * h, this.y * h);
};

Math.Vec2.prototype.div = function (h) {
  return new Math.Vec2(this.x / h, this.y / h);
};

Math.Vec2.prototype.dist = function (v) {
  var dx = v.x - this.x;
  var dy = v.y - this.y;
  return Math.sqrt(dx * dx + dy * dy);
};

Math.Vec2.prototype.sub = function (v) {
  return new Math.Vec2(this.x - v.x, this.y - v.y);
};

Math.Vec2.prototype.add = function (v) {
  return new Math.Vec2(this.x + v.x, this.y + v.y);
};

Math.Vec2.prototype.inv = function () {
  return new Math.Vec2(-this.x, -this.y);
};

Math.Vec2.prototype.linear = function (v, h) {
  return new Math.Vec2(this.x * (1 - h) + v.x * h, this.y * (1 - h) + v.y * h);
};

Math.Vec2.prototype.dot = function (v1) {
  return this.x * v1.x + this.y * v1.y;
};

Math.Vec2.prototype.direction = function () {
  return Math.atan2(this.y, this.x);
};

Math.Vec2.fromDirection = function (angle) {
  return new Math.Vec2(Math.cos(angle), Math.sin(angle));
};

Math.radianInRange = function (x, start, end) {
  if (start > end) return Math.radianInRange(x, end, start);
  if (x < start) x += Math.PI * 2 * Math.ceil((start - x) / 2 / Math.PI);
  if (x > end) x -= Math.PI * 2 * Math.ceil((x - end) / 2 / Math.PI);
  return x >= start && x <= end;
};

Math.makeVec2 = function (x, y) {
  if (x instanceof Array) {
    return new Math.Vec2(x[0], x[1]);
  } else if (x instanceof Math.Vec2) {
    return x.copy();
  } else return new Math.Vec2(x, y);
};

Math.Rectangle = function (x, y, width, height) {
  this.width = width;
  this.height = height;
  this.x = x;
  this.y = y;

  this.A = function () {
    return new Math.Vec2(this.x, this.y);
  };

  this.B = function () {
    return new Math.Vec2(this.x + this.width, this.y);
  };

  this.C = function () {
    return new Math.Vec2(this.x + this.width, this.y + this.height);
  };

  this.D = function () {
    return new Math.Vec2(this.x, this.y + this.height);
  };

  this.square = function () {
    return this.width * this.height;
  };

  this.nearestPoint = function (arg0, arg1) {
    if (arg1) arg0 = Math.makeVec2(arg0, arg1);
    var res = this.A();
    var mind = res.dist(arg0);
    var d = this.B().dist(arg0);

    if (d < mind) {
      mind = d;
      res = this.B();
    }

    d = this.C().dist(arg0);

    if (d < mind) {
      mind = d;
      res = this.C();
    }

    d = this.D().dist(arg0);

    if (d < mind) {
      mind = d;
      res = this.D();
    }

    return res;
  };

  this.centerPoint = function () {
    return new Math.Vec2(this.x + this.width / 2, this.y + this.height / 2);
  };

  this.isCollapse = function (r, margin) {
    if (!margin) margin = 0;
    if (this.x > r.x + r.width + margin) return false;
    if (this.y > r.y + r.height + margin) return false;
    if (r.x > this.x + this.width + margin) return false;
    if (r.y > this.y + this.height + margin) return false;
    return true;
  };

  this.collapsedSquare = function (r) {
    var margin = 0;
    var maxX, minX, maxY, minY;
    if (this.x > r.x + r.width + margin) return 0;
    if (this.y > r.y + r.height + margin) return 0;
    if (r.x > this.x + this.width + margin) return 0;
    if (r.y > this.y + this.height + margin) return 0;
    minX = this.x > r.x ? this.x : r.x;
    minY = this.y > r.y ? this.y : r.y;
    maxX = this.x + this.width < r.x + r.width ? this.x + this.width : r.x + r.width;
    maxY = this.y + this.height < r.x + r.height;
    return (maxX - minX) * (maxY - minY);
  };
};

Math.makeRectangle = function (x, y, width, height) {
  return new Math.Rectangle(x, y, width, height);
};

Math.makeCenterRectangle = function (x, y, width, height) {
  return new Math.Rectangle(x - width / 2, y - height / 2, width, height);
};

Math.dist = function (x0, y0, x1, y1) {
  var dx = x0 - x1;
  var dy = y0 - y1;
  return Math.sqrt(dx * dx + dy * dy);
};

Math.Arc = function (x, y, r, start, end) {
  this.x = x;
  this.y = y;
  this.r = r;
  this.start = start;
  this.end = end;

  this.isPointInBound = function (p) {
    if (Math.dist(this.x, this.y, p.x, p.y) > r) return false;
    return Math.radianInRange(Math.atan2(p.y - this.y, p.x - this.x), start, end);
  };

  this.isRectInBound = function (rect) {
    return this.isPointInBound(rect.A()) && this.isPointInBound(rect.B()) && this.isPointInBound(rect.C()) && this.isPointInBound(rect.D());
  };

  this.isRectOutBound = function (rect) {
    return !this.isPointInBound(rect.A()) && !this.isPointInBound(rect.B()) && !this.isPointInBound(rect.C()) && !this.isPointInBound(rect.D());
  };

  this.isRectCollapse = function (rect) {
    return this.isPointInBound(rect.A()) || this.isPointInBound(rect.B()) || this.isPointInBound(rect.C()) || this.isPointInBound(rect.D());
  };

  this.centerPoint = function () {
    var mid = (this.start + this.end) / 2;
    var x = this.x + Math.cos(mid) * this.r * 2 / 3;
    var y = this.y + Math.sin(mid) * this.r * 2 / 3;
    return new Math.Vec2(x, y);
  };

  this.centerRoundPoint = function () {
    var mid = (this.start + this.end) / 2;
    var x = this.x + Math.cos(mid) * this.r;
    var y = this.y + Math.sin(mid) * this.r;
    return new Math.Vec2(x, y);
  };
};

Math.Circle = function (x, y, r) {
  this.x = x;
  this.y = y;
  this.r = r;

  this.isPointInBound = function (p) {
    return Math.dist(this.x, this.y, p.x, p.y) > r;
  };

  this.isRectInBound = function (rect) {
    return this.isPointInBound(rect.A()) && this.isPointInBound(rect.B()) && this.isPointInBound(rect.C()) && this.isPointInBound(rect.D());
  };
};

Math.makeCircle = function (x, y, r) {
  return new Math.Circle(x, y, r);
};

Math.makeArc = function (x, y, r, start, end) {
  return new Math.Arc(x, y, r, start, end);
};

VaKeR 2022