import type { TRadian } from 'fabric';
import { halfPI } from '../../constants';


export const cos = (angle: TRadian): number => {
  if (angle === 0) {
    return 1;
  }
  const angleSlice = Math.abs(angle) / halfPI;
  switch (angleSlice) {
    case 1:
    case 3:
      return 0;
    case 2:
      return -1;
  }
  return Math.cos(angle);
};
