import type { Direction } from "./Enums" ; export type QuadrantDirection = Direction . UL | Direction . UR | Direction . LL | Direction . LR ; type PerQuadrantBase < T > = readonly [ T , T , T , T ] ; /** 一個索引只能是  QuadrantDirection 的唯讀陣列，可以配合  makePerQuadrant 產生之  export interface PerQuadrant < T > extends PerQuadrantBase < T > { } export const quadrantNumber = 4 ; const quadrants = [ 0 , 1 , 2 , 3 ] ; export const previousQuadrantOffset = 3 ; export const nextQuadrantOffset = 1 ; export function makePerQuadrant < T > ( factory ) { return quadrants . map ( factory ) as unknown as PerQuadrant < T > ; } export function isQuadrant ( direction ) { return direction < quadrantNumber ; } export function opposite ( direction ) { return ( direction + 2 ) % quadrantNumber ; }