src/scene/geometry.tsimport type { Opening, Vec2, Wall } from './schema';/** Bounding-box width (x extent) and depth (y extent) of a polygon. */export function polygonBounds(points: Vec2[]): { w: number; d: number } {let minX = Infinity;let minY = Infinity;let maxX = -Infinity;let maxY = -Infinity;for (const p of points) {if (p.x < minX) minX = p.x;if (p.y < minY) minY = p.y;if (p.x > maxX) maxX = p.x;if (p.y > maxY) maxY = p.y;}return { w: maxX - minX, d: maxY - minY };}export function wallLength(w: Wall): number {const dx = w.end.x - w.start.x;const dy = w.end.y - w.start.y;
Showing the first 20 lines.
Get full code