param degrees returns export function degreesToRadians ( degrees ) { return degrees * ( Math . PI / 180 ) ; } param radians returns export function radiansToDegrees ( radians ) { return radians * ( 180 / Math . PI ) ; } param r param theta returns { x export function polarToCartesian ( r , theta ) { return { x : r * Math . cos ( theta ) , y : r * Math . sin ( theta ) } ; } param x param y returns { r export function cartesianToPolar ( x , y ) { return { r : Math . sqrt ( x * x + y * y ) , theta : Math . atan2 ( y , x ) } ; } param radians param min param max returns export function normalizeRadians ( radians , min = - Math . PI , max = Math . PI ) { return normalize ( radians , min , max ) ; } param degrees param min param max returns export function normalizeDegrees ( degrees , min = - 180 , max = 180 ) { return normalize ( degrees , min , max ) ; } param value param min param max returns export function normalize ( value , min , max ) { const spread = max - min ; const offsetValue = value - min ; return ( offsetValue - ( Math . floor ( offsetValue / spread ) * spread ) ) + min ; }