/** * a collection of math utility functions * @namespace math */ /** * constant to convert from degrees to radians */ export declare const DEG_TO_RAD: number; /** * constant to convert from radians to degrees */ export declare const RAD_TO_DEG: number; /** * constant equals to 2 times pi */ export declare const TAU: number; /** * constant equals to half pi */ export declare const ETA: number; /** * the difference between 1 and the smallest floating point number greater than 1 */ export declare const EPSILON = 0.000001; /** * returns true if the given value is a power of two * @param val number to test * @returns true if number is a power of two */ export declare function isPowerOfTwo(val: number): boolean; /** * returns true if the given value is a power of four * @param val number to test * @returns true if number is a power of four */ export declare function isPowerOfFour(val: number): boolean; /** * returns the next power of two for the given value * @param val any number * @returns next power of two relative to the given number */ export declare function nextPowerOfTwo(val: number): number; /** * Converts an angle in degrees to an angle in radians * @param angle - angle in degrees * @returns corresponding angle in radians * @example * // convert a specific angle * math.degToRad(60); // return 1.0471... */ export declare function degToRad(angle: number): number; /** * Converts an angle in radians to an angle in degrees. * @param radians - angle in radians * @returns corresponding angle in degrees * @example * // convert a specific angle * math.radToDeg(1.0471975511965976); // return 60 */ export declare function radToDeg(radians: number): number; /** * clamp the given value * @param val - the value to clamp * @param low - lower limit * @param high - higher limit * @returns clamped value */ export declare function clamp(val: number, low: number, high: number): number; /** * return a random integer between min (included) and max (excluded) * @param min - minimum value. * @param max - maximum value. * @returns random value * @example * // Print a random number; one of 5, 6, 7, 8, 9 * console.log(math.random(5, 10)); */ export declare function random(min: number, max: number): number; /** * return a random float between min, max (exclusive) * @param min - minimum value. * @param max - maximum value. * @returns random value * @example * // Print a random number; one of 5, 6, 7, 8, 9 * console.log(math.randomFloat(5, 10) ); */ export declare function randomFloat(min: number, max: number): number; /** * return a weighted random between min, max (exclusive) * @param min - minimum value. * @param max - maximum value. * @returns random value * @example * // Print a random number; one of 5, 6, 7, 8, 9 * console.log(math.weightedRandom(5, 10) ); */ export declare function weightedRandom(min: number, max: number): number; /** * round a value to the specified number of digit * @param num - value to be rounded. * @param [dec] - number of decimal digit to be rounded to. * @returns rounded value * @example * // round a specific value to 2 digits * math.round(10.33333, 2); // return 10.33 */ export declare function round(num: number, dec?: number): number; /** * check if the given value is close to the expected one * @param expected - value to be compared with. * @param actual - actual value to compare * @param [precision] - float precision for the comparison * @returns if close to * @example * // test if the given value is close to 10 * if (math.toBeCloseTo(10, value)) { * // do something * } */ export declare function toBeCloseTo(expected: number, actual: number, precision?: number): boolean; /** * Calculates the power of a number. * @param n - The number to be raised to the power of 2. * @returns The result of raising the number to the power of 2. */ export declare function pow(n: number): number; /** * Linearly interpolate a value from an array at the given position. * The array is treated as evenly spaced samples along the 0–1 range. * @param values - array of values to interpolate between * @param position - position along the array (0.0–1.0). Values above 1.0 clamp to the last element. Values below 0.0 extrapolate before the first element. * @returns interpolated value * @example * // interpolate halfway through a curve * math.lerpArray([0, 10, 20], 0.5); // returns 10 * math.lerpArray([1, 0], 0.75); // returns 0.25 */ export declare function lerpArray(values: number[], position: number): number; //# sourceMappingURL=math.d.ts.map