Kern/Huelle Phase A.1: Kern-Lecks behoben (View-/Detail-Typen nach model/viewTypes, Pick-Typen nach plan/pickTypes, geomTransform/curves/lineSegments/layoutModel in den Kern verschoben)

This commit is contained in:
karim committed 2026-10-27 19:25:06 +01:00
1 parent 1ea0fab6ce
commit cb79c13753
46 files changed
+373 -344

No files matched your search

-140
View File
@@ -1,140 +0,0 @@
import { describe, it, expect } from "vitest";
import { ellipsePts, sampleBezierChain, sampleCatmullRom, sampleUniformBSpline } from "./curves";
describe("ellipsePts", () => {
it("liegt auf der Ellipse (rotation 0): Ost/Nord-Punkte bei rx/ry", () => {
const pts = ellipsePts({ x: 0, y: 0 }, 4, 2, 0, 4);
// t=0 → Ost (rx,0); t=π/2 → Nord (0,ry)
expect(pts[0].x).toBeCloseTo(4, 6);
expect(pts[0].y).toBeCloseTo(0, 6);
expect(pts[1].x).toBeCloseTo(0, 6);
expect(pts[1].y).toBeCloseTo(2, 6);
});
it("Drehung um 90° vertauscht die Achsen", () => {
const pts = ellipsePts({ x: 0, y: 0 }, 4, 2, Math.PI / 2, 4);
// Der ehemalige Ost-Punkt (rx,0) liegt jetzt bei (0, rx).
expect(pts[0].x).toBeCloseTo(0, 6);
expect(pts[0].y).toBeCloseTo(4, 6);
});
it("Mittelpunkt-Verschiebung wird respektiert", () => {
const pts = ellipsePts({ x: 10, y: 5 }, 3, 3, 0, 8);
for (const p of pts) {
expect(Math.hypot(p.x - 10, p.y - 5)).toBeCloseTo(3, 6);
}
});
});
describe("sampleBezierChain", () => {
it("weniger als 4 Punkte: Rohpunkte unverändert (Gummiband-Vorschau)", () => {
const pts = [{ x: 0, y: 0 }, { x: 1, y: 1 }];
expect(sampleBezierChain(pts)).toEqual(pts);
});
it("ein Segment: startet bei P0, endet bei P3", () => {
const p0 = { x: 0, y: 0 }, p1 = { x: 1, y: 3 }, p2 = { x: 3, y: 3 }, p3 = { x: 4, y: 0 };
const out = sampleBezierChain([p0, p1, p2, p3], 10);
expect(out[0]).toEqual(p0);
const last = out[out.length - 1];
expect(last.x).toBeCloseTo(p3.x, 6);
expect(last.y).toBeCloseTo(p3.y, 6);
});
it("t=0.5 folgt der De-Casteljau-Formel (symmetrischer Fall)", () => {
const p0 = { x: 0, y: 0 }, p1 = { x: 0, y: 4 }, p2 = { x: 4, y: 4 }, p3 = { x: 4, y: 0 };
const out = sampleBezierChain([p0, p1, p2, p3], 2); // t = 0.5 genau bei Index 1
// Symmetrische Kontrollpunkte → Kurvenmitte liegt exakt bei (2, 3).
expect(out[1].x).toBeCloseTo(2, 6);
expect(out[1].y).toBeCloseTo(3, 6);
});
it("zwei Segmente: verbindet am gemeinsamen Anker P3=P4", () => {
const pts = [
{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 1 }, { x: 3, y: 0 },
{ x: 4, y: -1 }, { x: 5, y: -1 }, { x: 6, y: 0 },
];
const out = sampleBezierChain(pts, 5);
expect(out[0]).toEqual(pts[0]);
const last = out[out.length - 1];
expect(last.x).toBeCloseTo(6, 6);
expect(last.y).toBeCloseTo(0, 6);
});
});
describe("sampleCatmullRom", () => {
it("weniger als 3 Punkte: Rohpunkte unverändert", () => {
const pts = [{ x: 0, y: 0 }, { x: 1, y: 1 }];
expect(sampleCatmullRom(pts, false)).toEqual(pts);
});
it("offen: läuft durch den ersten und letzten Wegpunkt", () => {
const pts = [{ x: 0, y: 0 }, { x: 2, y: 3 }, { x: 5, y: 1 }, { x: 8, y: 4 }];
const out = sampleCatmullRom(pts, false, 8);
expect(out[0]).toEqual(pts[0]);
const last = out[out.length - 1];
expect(last.x).toBeCloseTo(8, 6);
expect(last.y).toBeCloseTo(4, 6);
});
it("Kollineare Punkte ergeben eine Gerade (kein Überschwingen)", () => {
const pts = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 3, y: 0 }];
const out = sampleCatmullRom(pts, false, 4);
for (const p of out) expect(p.y).toBeCloseTo(0, 6);
});
it("geschlossen: liefert keinen doppelten Schlusspunkt (Aufrufer schliesst selbst)", () => {
const pts = [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 4 }, { x: 0, y: 4 }];
const out = sampleCatmullRom(pts, true, 6);
expect(out.length).toBe(pts.length * 6);
});
});
describe("sampleUniformBSpline (Kontrollpunkt-/CV-Modus)", () => {
it("weniger als 3 Punkte: Rohpunkte unverändert (Gummiband-Vorschau, wie sampleCatmullRom)", () => {
const pts = [{ x: 0, y: 0 }, { x: 3, y: 4 }];
expect(sampleUniformBSpline(pts, false, 8)).toEqual(pts);
});
it("offen, geklemmt: berührt exakt Start- und Endpunkt", () => {
const pts = [{ x: 0, y: 0 }, { x: 2, y: 5 }, { x: 6, y: 5 }, { x: 8, y: 0 }];
const out = sampleUniformBSpline(pts, false, 10);
expect(out[0]).toEqual(pts[0]);
const last = out[out.length - 1];
expect(last.x).toBeCloseTo(8, 9);
expect(last.y).toBeCloseTo(0, 9);
});
it("offen, geklemmt: berührt die INNEREN Kontrollpunkte NICHT (Gegensatz zu Catmull-Rom, das interpoliert)", () => {
// Zwei Kontrollpunkte weit ausserhalb der Verbindungslinie Start-Ende —
// eine interpolierende Kurve (Catmull-Rom) würde exakt durch sie
// verlaufen; die B-Spline-Kurve wird nur "angezogen".
const pts = [{ x: 0, y: 0 }, { x: 2, y: 10 }, { x: 6, y: 10 }, { x: 8, y: 0 }];
const out = sampleUniformBSpline(pts, false, 20);
const touchesInner = out.some(
(p) => Math.hypot(p.x - 2, p.y - 10) < 1e-6 || Math.hypot(p.x - 6, p.y - 10) < 1e-6,
);
expect(touchesInner).toBe(false);
// Bleibt aber innerhalb der konvexen Hülle der Kontrollpunkte (y ≤ 10).
for (const p of out) expect(p.y).toBeLessThanOrEqual(10 + 1e-9);
});
it("zwei effektive Kontrollpunkte (Start/Ende mehrfach dupliziert) ergeben eine echte Gerade", () => {
// Mit 3 kollinearen Punkten bleibt die Kurve (als Kombination kollinearer
// Kontrollpunkte) exakt auf der Verbindungsgeraden.
const pts = [{ x: 0, y: 0 }, { x: 3, y: 0 }, { x: 6, y: 0 }];
const out = sampleUniformBSpline(pts, false, 8);
for (const p of out) expect(p.y).toBeCloseTo(0, 9);
expect(out[0]).toEqual(pts[0]);
expect(out[out.length - 1]).toEqual(pts[2]);
});
it("geschlossen (periodisch): liefert keinen doppelten Schlusspunkt UND berührt keinen der Kontrollpunkte", () => {
const pts = [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 4 }, { x: 0, y: 4 }];
const out = sampleUniformBSpline(pts, true, 6);
expect(out.length).toBe(pts.length * 6);
for (const cp of pts) {
expect(out.some((p) => Math.hypot(p.x - cp.x, p.y - cp.y) < 1e-6)).toBe(false);
}
});
});
-156
View File
@@ -1,156 +0,0 @@
// Geometrie-Helfer für Ellipse/Bezier/Spline — reine Sample-/Tessellierungs-
// Funktionen, gemeinsam genutzt von den Zeichen-Werkzeugen (Vorschau), dem
// Grundriss-Generator (finales Rendering als Linien-/Polygon-Primitive) und
// dem Snapping (Kandidaten-Strecken).
import type { Vec2 } from "../model/types";
/** Punkte einer (ggf. gedrehten) Ellipse, N gleichverteilte Parameterschritte. */
export function ellipsePts(
center: Vec2,
rx: number,
ry: number,
rotation: number,
n = 64,
): Vec2[] {
const pts: Vec2[] = [];
const cosR = Math.cos(rotation);
const sinR = Math.sin(rotation);
for (let i = 0; i < n; i++) {
const t = (i / n) * Math.PI * 2;
const lx = rx * Math.cos(t);
const ly = ry * Math.sin(t);
pts.push({ x: center.x + lx * cosR - ly * sinR, y: center.y + lx * sinR + ly * cosR });
}
return pts;
}
/** Punkt auf einer kubischen Bezier-Kurve (De-Casteljau-Formel) bei Parameter `t` ∈ [0,1]. */
function cubicPoint(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, t: number): Vec2 {
const u = 1 - t;
const a = u * u * u;
const b = 3 * u * u * t;
const c = 3 * u * t * t;
const d = t * t * t;
return {
x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,
y: a * p0.y + b * p1.y + c * p2.y + d * p3.y,
};
}
/**
* Tessellierte Punkte einer kubischen Bezier-Kette. `pts` folgt dem Muster
* Anker·Griff·Griff·Anker·… (`pts.length` ≡ 1 mod 3). Mit weniger als 4
* Punkten (noch im Bau) werden die Rohpunkte unverändert zurückgegeben
* (Gummiband-Vorschau).
*/
export function sampleBezierChain(pts: Vec2[], segsPerCurve = 24): Vec2[] {
if (pts.length < 4) return [...pts];
const out: Vec2[] = [pts[0]];
for (let i = 0; i + 3 < pts.length; i += 3) {
const p0 = pts[i], p1 = pts[i + 1], p2 = pts[i + 2], p3 = pts[i + 3];
for (let s = 1; s <= segsPerCurve; s++) out.push(cubicPoint(p0, p1, p2, p3, s / segsPerCurve));
}
return out;
}
/** Kontrollpunkt-Zugriff für Catmull-Rom mit Rand-Klemmung bzw. Ring-Umlauf. */
function crPoint(pts: Vec2[], i: number, closed: boolean): Vec2 {
const n = pts.length;
if (closed) return pts[((i % n) + n) % n];
if (i < 0) return pts[0];
if (i >= n) return pts[n - 1];
return pts[i];
}
/**
* Tessellierte Punkte einer glatten Kurve DURCH `pts` (uniformer Catmull-
* Rom-Spline). Mit weniger als 3 Punkten (noch im Bau bzw. entartet) werden
* die Rohpunkte unverändert zurückgegeben (Gummiband-Vorschau bzw. Gerade).
* `closed` schliesst den Ring OHNE expliziten Doppelpunkt am Ende — Aufrufer
* schliessen wie bei `polyline` selbst mit einem letzten Segment zurück zu
* `pts[0]`.
*/
export function sampleCatmullRom(pts: Vec2[], closed: boolean, segsPerSpan = 16): Vec2[] {
if (pts.length < 3) return [...pts];
const out: Vec2[] = [];
const spans = closed ? pts.length : pts.length - 1;
for (let i = 0; i < spans; i++) {
const p0 = crPoint(pts, i - 1, closed);
const p1 = crPoint(pts, i, closed);
const p2 = crPoint(pts, i + 1, closed);
const p3 = crPoint(pts, i + 2, closed);
for (let s = 0; s < segsPerSpan; s++) {
const t = s / segsPerSpan;
const t2 = t * t;
const t3 = t2 * t;
const x =
0.5 *
(2 * p1.x +
(-p0.x + p2.x) * t +
(2 * p0.x - 5 * p1.x + 4 * p2.x - p3.x) * t2 +
(-p0.x + 3 * p1.x - 3 * p2.x + p3.x) * t3);
const y =
0.5 *
(2 * p1.y +
(-p0.y + p2.y) * t +
(2 * p0.y - 5 * p1.y + 4 * p2.y - p3.y) * t2 +
(-p0.y + 3 * p1.y - 3 * p2.y + p3.y) * t3);
out.push({ x, y });
}
}
if (!closed) out.push(pts[pts.length - 1]);
return out;
}
/** Punkt auf einem uniformen kubischen B-Spline-Segment (Standard-Basis, 4 Kontrollpunkte). */
function bsplineSegPoint(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, t: number): Vec2 {
const t2 = t * t;
const t3 = t2 * t;
const b0 = (1 - t) ** 3 / 6;
const b1 = (3 * t3 - 6 * t2 + 4) / 6;
const b2 = (-3 * t3 + 3 * t2 + 3 * t + 1) / 6;
const b3 = t3 / 6;
return {
x: p0.x * b0 + p1.x * b1 + p2.x * b2 + p3.x * b3,
y: p0.y * b0 + p1.y * b1 + p2.y * b2 + p3.y * b3,
};
}
/**
* Tessellierte Punkte eines kubischen B-Splines über den KONTROLLPUNKTEN
* `pts` — Gegenstück zu `sampleCatmullRom`: die Kurve verläuft NICHT durch
* die inneren Punkte, sie wird nur von ihnen „gezogen" (Kontrollnetz statt
* Durchgangspunkte, wie CV-Modus in AutoCAD/Rhino). Offen: GEKLEMMT — die
* Kurve berührt exakt `pts[0]`/`pts[n-1]` (Rand-Kontrollpunkte werden intern
* je 2× zusätzlich dupliziert, Multiplizität 3 an beiden Enden — der
* Standard-Trick für kubische B-Splines, ohne eine generische
* Knotenvektor-Auswertung/Cox-de-Boor-Rekursion zu brauchen). Geschlossen:
* periodisch (Kontrollpunkte laufen zyklisch um), die Kurve berührt dann
* KEINEN der Punkte. Mit weniger als 3 Punkten identisches
* Fallback-Verhalten wie `sampleCatmullRom` (Rohpunkte, Gummiband-Vorschau).
*/
export function sampleUniformBSpline(pts: Vec2[], closed: boolean, segsPerSpan = 16): Vec2[] {
if (pts.length < 3) return [...pts];
const out: Vec2[] = [];
if (closed) {
const n = pts.length;
const at = (i: number) => pts[((i % n) + n) % n];
for (let i = 0; i < n; i++) {
for (let s = 0; s < segsPerSpan; s++) {
out.push(bsplineSegPoint(at(i - 1), at(i), at(i + 1), at(i + 2), s / segsPerSpan));
}
}
return out;
}
const last = pts[pts.length - 1];
const padded = [pts[0], pts[0], ...pts, last, last];
const spans = padded.length - 3;
for (let i = 0; i < spans; i++) {
for (let s = 0; s < segsPerSpan; s++) {
out.push(bsplineSegPoint(padded[i], padded[i + 1], padded[i + 2], padded[i + 3], s / segsPerSpan));
}
}
out.push(last);
return out;
}
+1 -1
View File
@@ -14,7 +14,7 @@ import { centroid as roomCentroid } from "../geometry/roomArea";
import { columnFootprint } from "../geometry/column";
import { stairOutline } from "../geometry/stair";
import type { SnapKind, SnapResult, SnapSettings } from "./types";
import { sampleBezierChain, sampleCatmullRom, sampleUniformBSpline } from "./curves";
import { sampleBezierChain, sampleCatmullRom, sampleUniformBSpline } from "../geometry/curves";
import { buildDrawingIndex, drawingsNear, isIndexable, pointSegDist, type DrawingIndex } from "../geometry/drawingIndex";
import { sheetSnapSegments } from "./sheetSnapGeometry";
+1 -161
View File
@@ -29,6 +29,7 @@ import { columnFootprint } from "../geometry/column";
import { stairOutline } from "../geometry/stair";
import type { DraftShape } from "./types";
import { drawingPreviewShapes } from "./drawingPreview";
import { mvGeom, reversesOrientation, scaleFactor, scaleGeom } from "../geometry/geomTransform";
import { uniqueId } from "./types";
import type { CommandSelection } from "../commands/types";
@@ -262,18 +263,6 @@ function gatherItems(project: Project, sel: TransformSelection, op: TransformOp)
* aktuellen Winkel) mit-transformiert und der neue Winkel daraus gemessen wird
* — das ergibt für alle drei Operationen die korrekte neue Ausrichtung.
*/
/**
* Erkennt, ob `fn` die Umlauf-Orientierung umkehrt (Spiegelung) — via
* Flächenvorzeichen eines Test-Dreiecks unter `fn` (negativ ⇒ Spiegelung).
* Funktioniert für JEDE Isometrie/Similarity (Move/Rotate/Scale erhalten die
* Orientierung, Mirror kehrt sie um), ohne dass eine Operation ihre Spiegel-
* Eigenschaft explizit markieren müsste.
*/
function reversesOrientation(fn: (p: Vec2) => Vec2): boolean {
const p0 = fn({ x: 0, y: 0 }), p1 = fn({ x: 1, y: 0 }), p2 = fn({ x: 0, y: 1 });
return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y) < 0;
}
function mvColumn(col: Column, fn: (p: Vec2) => Vec2): Column {
const base = col.position;
const rot = col.rotation ?? 0;
@@ -283,155 +272,6 @@ function mvColumn(col: Column, fn: (p: Vec2) => Vec2): Column {
return { ...col, position: nb, rotation: Math.atan2(nt.y - nb.y, nt.x - nb.x) };
}
/** Bildet jeden Punkt einer 2D-Zeichengeometrie unter `fn` ab (Move/Mirror/Rotate/Array + Block-Rendering). */
/**
* Wie {@link mvGeom}, zusätzlich für eine SKALIERUNG: `mvGeom` bildet nur
* PUNKTE ab — Radien, Schrifthöhen und der Bemassungs-Abstand sind aber keine
* Punkte und blieben sonst unverändert stehen (ein Kreis behielte unter einer
* 2×-Skalierung seinen Radius). Diese Funktion zieht die betroffenen
* Grössenfelder um denselben Faktor nach.
*
* Bewusst NICHT angefasst: `bulge` (ein Formverhältnis, skaleninvariant) und
* die Papier-mm-Felder von Bemassung/Linienenden — die beziehen sich auf das
* Blatt, nicht aufs Modell, und dürfen beim Skalieren des Objekts gleich
* bleiben.
*/
/** Skalierungsfaktor eines `op:"scale"`-Punkte-Tripels bei Interpolation `t`. */
export function scaleFactor(pts: Vec2[], t: number): number {
const c = pts[0];
const ref = Math.hypot(pts[1].x - c.x, pts[1].y - c.y) || 1;
const tgt = Math.hypot(pts[2].x - c.x, pts[2].y - c.y);
return 1 + (tgt / ref - 1) * t;
}
export const scaleGeom = (geom: Drawing2DGeom, fn: (p: Vec2) => Vec2, f: number): Drawing2DGeom => {
const g = mvGeom(geom, fn);
switch (g.shape) {
case "circle":
return { ...g, r: g.r * f };
case "arc":
return { ...g, r: g.r * f };
case "ellipse":
return { ...g, rx: g.rx * f, ry: g.ry * f };
case "dimension":
// `offset` ist der Normalabstand der Masslinie in Modellmass.
return { ...g, offset: g.offset * f };
case "text":
return {
...g,
height: g.height * f,
...(g.width !== undefined ? { width: g.width * f } : {}),
};
case "scalebar":
// Segmentlänge ist eine ECHTE Modell-Distanz (kein Papier-mm-Feld wie
// bei Kote/Bemassung) — muss bei einer Modell-Skalierung mitwachsen,
// sonst zeigt der Balken nach dem Skalieren die FALSCHE Distanz an.
return { ...g, segmentLength: g.segmentLength * f };
case "block":
// Blockinstanz-Skalierung (s. Typ-Kommentar in model/types.ts) —
// ohne diesen Fall wäre der `scale`-Befehl auf eine Blockinstanz ein
// kompletter No-Op (kein Feld zum Multiplizieren).
return { ...g, scale: (g.scale ?? 1) * f };
default:
return g;
}
};
export const mvGeom = (geom: Drawing2DGeom, fn: (p: Vec2) => Vec2): Drawing2DGeom => {
switch (geom.shape) {
case "line":
case "xline":
case "ray":
return { ...geom, a: fn(geom.a), b: fn(geom.b) };
case "polyline": {
const pts = geom.pts.map(fn);
if (!geom.bulge) return { ...geom, pts };
// Bulge-Vorzeichen ist rein relativ zur Zeichenrichtung definiert (links
// von a→b) — eine Spiegelung kehrt die Umlauf-Orientierung um und muss
// daher auch jeden Bogen umkehren, sonst wandert er auf die falsche Seite.
const bulge = reversesOrientation(fn) ? geom.bulge.map((b) => -b) : geom.bulge;
return { ...geom, pts, bulge };
}
case "rect": {
// Achsparallel nur bei reiner Verschiebung erhaltbar; sonst → Polylinie.
const c = [
geom.min,
{ x: geom.max.x, y: geom.min.y },
geom.max,
{ x: geom.min.x, y: geom.max.y },
].map(fn);
const axisAligned =
Math.abs(c[0].y - c[1].y) < 1e-6 &&
Math.abs(c[1].x - c[2].x) < 1e-6 &&
Math.abs(c[2].y - c[3].y) < 1e-6;
if (axisAligned) {
const xs = c.map((p) => p.x), ys = c.map((p) => p.y);
return {
shape: "rect",
min: { x: Math.min(...xs), y: Math.min(...ys) },
max: { x: Math.max(...xs), y: Math.max(...ys) },
};
}
return { shape: "polyline", pts: c, closed: true };
}
case "circle":
return { ...geom, center: fn(geom.center) };
case "arc":
return { ...geom, center: fn(geom.center) };
case "ellipse":
return { ...geom, center: fn(geom.center) };
case "bezier":
return { ...geom, pts: geom.pts.map(fn) };
case "spline":
return { ...geom, pts: geom.pts.map(fn) };
case "dimension":
return { ...geom, pts: geom.pts.map(fn) };
case "kote":
return { ...geom, at: fn(geom.at) };
case "detailref":
return { ...geom, at: fn(geom.at) };
case "scalebar":
return { ...geom, at: fn(geom.at) };
case "pointmarker":
return { ...geom, at: fn(geom.at) };
case "text":
// Leader-Ziel bzw. Pfadpunkte (Text-entlang-Pfad) müssen mitwandern,
// sonst zeigt der Pfeil/Pfad nach einem Move/Mirror/Rotate/Array auf die
// alte Position.
return {
...geom,
at: fn(geom.at),
...(geom.leaderTarget ? { leaderTarget: fn(geom.leaderTarget) } : {}),
...(geom.leaderBendPoints ? { leaderBendPoints: geom.leaderBendPoints.map(fn) } : {}),
...(geom.pathPts ? { pathPts: geom.pathPts.map(fn) } : {}),
};
case "block": {
// Wie Column: Winkel aus einem transformierten Richtungspunkt zurück-
// rechnen, damit Rotate/Mirror auch die Instanz-Ausrichtung mitnehmen
// (nicht nur den Einfügepunkt) — reine Translation liesse die Symbole
// beim Drehen der Auswahl in der alten Orientierung stehen.
const tip = { x: geom.at.x + Math.cos(geom.rotation), y: geom.at.y + Math.sin(geom.rotation) };
const nb = fn(geom.at);
const nt = fn(tip);
return { ...geom, at: nb, rotation: Math.atan2(nt.y - nb.y, nt.x - nb.x) };
}
case "image": {
// Wie Text: nur die Position folgt der Transformation (Zentrum wandert
// dorthin, wo `fn` es abbildet); die Box bleibt achsparallel/unverzerrt —
// ein Bild kann nicht geschert/rotiert dargestellt werden (kein `angle`-Feld).
const oldCenter = { x: (geom.min.x + geom.max.x) / 2, y: (geom.min.y + geom.max.y) / 2 };
const newCenter = fn(oldCenter);
const dx = newCenter.x - oldCenter.x;
const dy = newCenter.y - oldCenter.y;
return {
...geom,
min: { x: geom.min.x + dx, y: geom.min.y + dy },
max: { x: geom.max.x + dx, y: geom.max.y + dy },
};
}
}
};
/** Bildet Umriss + Aussparungen einer Decke unter `fn` ab. */
function mvCeiling(c: Ceiling, fn: (p: Vec2) => Vec2): Ceiling {
return {