export const round = ( number ) : number => Math . round ( number * 1e6 ) / 1e6 ; export const radToAngle = ( rad ) : number => ( rad * 180 ) / Math . PI ; export const angleToRad = ( angle ) : number => ( angle * Math . PI ) / 180 ; export const randomRange = ( min , max ) : number => Math . random ( ) * ( max - min ) + min ; export const radiansDelta = ( prev , cur ) : number => { if ( prev < 0 ) prev = 2 * Math . PI - Math . abs ( prev ) ; if ( cur < 0 ) cur = 2 * Math . PI - Math . abs ( cur ) ; let delta ; if ( prev < cur ) delta = Math . abs ( prev + ( Math . PI * 2 - cur ) ) ; else delta = Math . abs ( prev - cur ) ; return delta ; } ; export const getType = ( item ) : string => { if ( Array . isArray ( item ) ) return "array" ; if ( typeof item === "object" ) return "object" ; if ( typeof item === "number" ) return "number" ; } ; export const all = ( value ) => ( numOfVertexes ) => Array ( numOfVertexes ) . fill ( value ) ; export const perVertex = ( ... values ) => [ ... values ] ; export const randomRangeForEach = ( min , max ) => ( numOfVertexes ) : number [ ] => Array ( numOfVertexes ) . fill ( 0 ) . map ( ( ) => Math . random ( ) * ( max - min ) + min ) ; export const randomRangeForAll = ( min , max ) => ( numOfVertexes ) : number [ ] => Array ( numOfVertexes ) . fill ( Math . random ( ) * ( max - min ) + min ) ; export const perArm = ( first , second ) : number [ ] => [ first , second ] ;