/**
 * Common utility methods for math operations.
 */ export class MathUtil { /** The value for which all absolute numbers smaller than are considered equal to zero. */ static readonly zeroTolerance : number = 1e-6 ; /** The conversion factor that radian to degree. */ static readonly radToDegreeFactor : number = 180 / Math . PI ; /** The conversion factor that degree to radian. */ static readonly degreeToRadFactor : number = Math . PI / 180 ; param v param min param max returns static clamp ( v , min , max ) { return Math . max ( min , Math . min ( max , v ) ) ; } param a param b returns static equals ( a , b ) { return Math . abs ( a - b ) <= MathUtil . zeroTolerance ; } param v returns static isPowerOf2 ( v ) { return ( v & ( v - 1 ) ) === 0 ; } param r returns static radianToDegree ( r ) { return r * MathUtil . radToDegreeFactor ; } param d returns static degreeToRadian ( d ) { return d * MathUtil . degreeToRadFactor ; } }