geometry.ts

src/scene/geometry.ts
import 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

Support

Talk to the developers of this project to learn more

We have been building professional websites for big clients for over 15 years. Gallop templates and blocks is our best foundation for SEO websites and web apps.

© 2026 Web Plant Media, LLC