10 lines
378 B
TypeScript
10 lines
378 B
TypeScript
import type { Location } from "@deadhead/content";
|
|
import { locationPosition } from "./positions";
|
|
|
|
/** Straight-line distance between two locations, in million km; fixed (decision 0.5.93). */
|
|
export function routeDistance(from: Location, to: Location): number {
|
|
const a = locationPosition(from);
|
|
const b = locationPosition(to);
|
|
return Math.hypot(b.x - a.x, b.y - a.y);
|
|
}
|