/**
 * General math-related and numeric utility functions.
 */ export default class MathUtils { private MathUtils ( ) { } /**
     * Ends up being a bit faster than  Math . This merely rounds its
     * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut
     * differ slightly from  Math in that half rounds down for negative
     * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference.
     *
     *  param d return public static round ( d ) { if ( NaN === d ) return 0 ; if ( d <= Number . MIN_SAFE_INTEGER ) return Number . MIN_SAFE_INTEGER ; if ( d >= Number . MAX_SAFE_INTEGER ) return Number . MAX_SAFE_INTEGER ; return ( d + ( d < 0.0 ? - 0.5 : 0.5 ) ) | 0 ; } param aX param aY param bX param bY return public static distance ( aX , aY , bX , bY ) { const xDiff = aX - bX ; const yDiff = aY - bY ; return Math . sqrt ( xDiff * xDiff + yDiff * yDiff ) ; } param aX param aY param bX param bY return param array return public static sum ( array ) { let count = 0 ; for ( let i = 0 , length = array . length ; i != length ; i ++ ) { const a = array [ i ] ; count += a ; } return count ; } }