blob: e6dfd7f06af0965d5bbf85fc248fdab05c6a2fd4 (
plain)
1
2
3
4
5
6
7
8
|
import type { Coord2D } from "../interfaces";
export const normalizeVector = (vector: Coord2D): Coord2D => {
const { x, y } = vector;
const length = Math.sqrt(x * x + y * y);
return { x: x / length, y: y / length };
};
|