UNPKG

@2d-game-grid/square

Version:
15 lines (14 loc) 491 B
import {euclideanDistance} from './euclideanDistance.js' import {manhattanDistance} from './manhattanDistance.js' /** * @param start The start coordinate * @param end The end coordinate * @param algorithm The algorithm that should be used for the distance calculation * @returns The distance between the given coordinates */ export function getDistance(start, end, algorithm) { return { EUCLIDEAN: euclideanDistance, MANHATTAN: manhattanDistance, }[algorithm](start, end) }