wgpu-matrix
Version:
fast matrix math library for WebGPU
54 lines (53 loc) • 1.63 kB
TypeScript
export declare let EPSILON: number;
/**
* Set the value for EPSILON for various checks
* @param v - Value to use for EPSILON.
* @returns previous value of EPSILON;
*/
export declare function setEpsilon(v: number): number;
/**
* Convert degrees to radians
* @param degrees - Angle in degrees
* @returns angle converted to radians
*/
export declare function degToRad(degrees: number): number;
/**
* Convert radians to degrees
* @param radians - Angle in radians
* @returns angle converted to degrees
*/
export declare function radToDeg(radians: number): number;
/**
* Lerps between a and b via t
* @param a - starting value
* @param b - ending value
* @param t - value where 0 = a and 1 = b
* @returns a + (b - a) * t
*/
export declare function lerp(a: number, b: number, t: number): number;
/**
* Compute the opposite of lerp. Given a and b and a value between
* a and b returns a value between 0 and 1. 0 if a, 1 if b.
* Note: no clamping is done.
* @param a - start value
* @param b - end value
* @param v - value between a and b
* @returns (v - a) / (b - a)
*/
export declare function inverseLerp(a: number, b: number, v: number): number;
/**
* Compute the euclidean modulo
*
* ```
* // table for n / 3
* -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 <- n
* ------------------------------------
* -2 -1 -0 -2 -1 0, 1, 2, 0, 1, 2 <- n % 3
* 1 2 0 1 2 0, 1, 2, 0, 1, 2 <- euclideanModule(n, 3)
* ```
*
* @param n - dividend
* @param m - divisor
* @returns the euclidean modulo of n / m
*/
export declare function euclideanModulo(n: number, m: number): number;