77 lines
2.1 KiB
JavaScript
77 lines
2.1 KiB
JavaScript
export const abs = Math.abs;
|
|
export const acos = Math.acos;
|
|
export const acosh = Math.acosh;
|
|
export const asin = Math.asin;
|
|
export const asinh = Math.asinh;
|
|
export const atan = Math.atan;
|
|
export const atanh = Math.atanh;
|
|
export const atan2 = Math.atan2;
|
|
export const ceil = Math.ceil;
|
|
export const cbrt = Math.cbrt;
|
|
export const expm1 = Math.expm1;
|
|
export const clz32 = Math.clz32;
|
|
export const cos = Math.cos;
|
|
export const cosh = Math.cosh;
|
|
export const exp = Math.exp;
|
|
export const floor = Math.floor;
|
|
export const fround = Math.fround;
|
|
export const hypot = Math.hypot;
|
|
export const imul = Math.imul;
|
|
export const log = Math.log;
|
|
export const log1p = Math.log1p;
|
|
export const log2 = Math.log2;
|
|
export const log10 = Math.log10;
|
|
export const max = Math.max;
|
|
export const min = Math.min;
|
|
export const pow = Math.pow;
|
|
export const random = Math.random;
|
|
export const round = Math.round;
|
|
export const sign = Math.sign;
|
|
export const sin = Math.sin;
|
|
export const sinh = Math.sinh;
|
|
export const sqrt = Math.sqrt;
|
|
export const tan = Math.tan;
|
|
export const tanh = Math.tanh;
|
|
export const trunc = Math.trunc;
|
|
export const E = Math.E;
|
|
export const LN10 = Math.LN10;
|
|
export const LN2 = Math.LN2;
|
|
export const LOG10E = Math.LOG10E;
|
|
export const LOG2E = Math.LOG2E;
|
|
export const PI = Math.PI;
|
|
export const PI_180 = Math.PI / 180;
|
|
export const SQRT1_2 = Math.SQRT1_2;
|
|
export const SQRT2 = Math.SQRT2;
|
|
|
|
export const add = (l, r) => l + r;
|
|
export const div = (l, r) => l / r;
|
|
export const frac = (number) => number % 1;
|
|
export const fromRad = (r) => {
|
|
return (r % (Math.PI * 2)) / PI_180;
|
|
}
|
|
export const mul = (l, r) => l * r;
|
|
export const normalizeAngleRange = (min, max) => {
|
|
if (min < 0) {
|
|
min += Math.PI * 2;
|
|
max += Math.PI * 2;
|
|
}
|
|
if (min > max) {
|
|
[min, max] = [max, min + Math.PI * 2];
|
|
}
|
|
while (max >= Math.PI * 2) {
|
|
min -= Math.PI * 2;
|
|
max -= Math.PI * 2;
|
|
}
|
|
return [min, max];
|
|
}
|
|
export const randomNumber = (min, max) => {
|
|
if (min > max) {
|
|
[max, min] = [min, max];
|
|
}
|
|
return min + Math.random() * (max - min);
|
|
};
|
|
export const sub = (l, r) => l - r;
|
|
export const toRad = (a) => {
|
|
return (a % 360) * PI_180;
|
|
}
|