This commit is contained in:
Schluffe
2026-03-16 23:19:18 +01:00
parent 6e95c538fb
commit a2af7b9940
3 changed files with 29 additions and 24 deletions
+9
View File
@@ -58,6 +58,15 @@ export function setDistanceNormal(normal: Vector, a: Vector, b: Vector): void {
}
}
export function setEdgeNormal(normal: Vector, a: Vector, b: Vector): void {
const nx = -(b.y - a.y);
const ny = b.x - a.x;
const inv = 1.0 / Math.sqrt(nx * nx + ny * ny);
normal.x = nx * inv;
normal.y = ny * inv;
}
export function getDotProduct(a: Vector, b: Vector): number {
return a.x * b.x + a.y * b.y;
}