Files
nage/workshop/steps/09-slide/slide.ts
T
2026-07-11 17:48:28 +02:00

12 lines
347 B
TypeScript

import { dot, scale, sub, type Vec } from "./given.ts";
/**
* Remove the component of `v` that points into a wall with the given (unit)
* normal, leaving only the motion that runs along the wall.
*
* vSlide = v - normal * dot(v, normal)
*/
export function slide(v: Vec, normal: Vec): Vec {
return sub(v, scale(normal, dot(v, normal)));
}