Add isInteger coordinate utils

This commit is contained in:
2024-12-13 14:36:41 +01:00
parent feb1b40408
commit 480a2bfbd6
2 changed files with 20 additions and 1 deletions
+8
View File
@@ -36,6 +36,14 @@ export function isCoordinateEqual(
return b[0] === a[0] && b[1] === a[1];
}
/**
* Check if a xy-coordinate has integer coefficients.
* @param coordinate Coordinate
*/
export function isInteger(coordinate: Readonly<Coordinate | CoordinateSide>) {
return coordinate[0] % 1 === 0 && coordinate[1] % 1 === 0;
}
export type DirectNeighbours = 'top' | 'left' | 'right' | 'down';
export type DiagonalNeighbours =