Files
2026-07-11 17:48:28 +02:00

12 lines
409 B
TypeScript

import { add, type Hit, scale, type Vec } from "./given.ts";
/**
* The new position after this frame's move, stopping at a collision if there is
* one.
* hit === null -> pos + v (take the whole move)
* hit -> pos + v * time (stop at the contact point)
*/
export function resolve(pos: Vec, v: Vec, hit: Hit | null): Vec {
return hit ? add(pos, scale(v, hit.time)) : add(pos, v);
}