11 lines
449 B
TypeScript
11 lines
449 B
TypeScript
import type { Location } from "@deadhead/content";
|
|
import type { GameTime } from "./clock";
|
|
import { locationPosition } from "./positions";
|
|
|
|
/** Straight-line distance between two locations at a game time, in million km. */
|
|
export function routeDistance(from: Location, to: Location, gameTime: GameTime): number {
|
|
const a = locationPosition(from, gameTime);
|
|
const b = locationPosition(to, gameTime);
|
|
return Math.hypot(b.x - a.x, b.y - a.y);
|
|
}
|