Dach: Satteldach auf L/T/U mit eigenem Ortgang-Ueberstand

This commit is contained in:
karim committed 2026-10-21 23:13:49 +02:00
1 parent c94793714a
commit b84e78ce29
3 files changed
+27 -3

No files matched your search

+12 -1
View File
@@ -383,7 +383,18 @@ function rectilinearWalm(roof: Roof, eavesZ: number): RoofGeometry {
area += p.x * q.y - q.x * p.y;
}
if (area < 0) ring = [...ring].reverse();
const eaves = offsetRectilinear(ring, Math.max(0, roof.overhang));
const oe = Math.max(0, roof.overhang);
const og = Math.max(0, roof.overhangGable ?? roof.overhang);
// Satteldach: Kanten quer zum First sind Ortgang (eigener Überstand), sonst Traufe.
const eaves = offsetRectilinear(
ring,
roof.shape === "sattel"
? (a, b) => {
const alongX = Math.abs(b.x - a.x) > Math.abs(b.y - a.y);
return alongX === (roof.ridgeAxis === "x") ? oe : og;
}
: oe,
);
const tan = Math.tan(Math.max(0, roof.pitchDeg) * DEG);
const sk = rectilinearHipRoof(eaves, tan, eavesZ, roof.shape === "sattel" ? roof.ridgeAxis : undefined);
return {
+12
View File
@@ -60,3 +60,15 @@ describe("Satteldach, First entlang y", () => {
expect(r.gables.length).toBe(3);
});
});
describe("Satteldach auf L: Ortgang-Überstand", () => {
it("overhangGable verschiebt nur die Giebelkanten", () => {
const roof = { id: "R", type: "roof", floorId: "eg", categoryCode: "31", outline: L, shape: "sattel", pitchDeg: 45, overhang: 0.5, overhangGable: 1, ridgeAxis: "x" } as unknown as Roof;
const xs = roofGeometry(roof, 0).eaves.map((p) => p.x);
const ys = roofGeometry(roof, 0).eaves.map((p) => p.y);
expect(Math.min(...xs)).toBeCloseTo(-1, 6);
expect(Math.max(...xs)).toBeCloseTo(12, 6);
expect(Math.min(...ys)).toBeCloseTo(-0.5, 6);
expect(Math.max(...ys)).toBeCloseTo(6.5, 6);
});
});
+3 -2
View File
@@ -72,13 +72,14 @@ export function isRectilinearNonRect(outline: Vec2[]): boolean {
}
/** Rechtwinkligen Ring (CCW) um `d` nach aussen versetzen (Traufüberstand). */
export function offsetRectilinear(ring: Vec2[], d: number): Vec2[] {
if (d <= 0) return ring.map((p) => ({ ...p }));
export function offsetRectilinear(ring: Vec2[], dist: number | ((a: Vec2, b: Vec2) => number)): Vec2[] {
if (typeof dist === "number" && dist <= 0) return ring.map((p) => ({ ...p }));
const n = ring.length;
// Aussen-Normale je Kante (CCW → rechte Normale).
const off = ring.map((p, i) => {
const q = ring[(i + 1) % n];
const len = Math.hypot(q.x - p.x, q.y - p.y) || 1;
const d = typeof dist === "number" ? dist : dist(p, q);
return { x: ((q.y - p.y) / len) * d, y: (-(q.x - p.x) / len) * d };
});
// Ecke i = Schnitt der versetzten Kanten (i−1) und i; bei rechten Winkeln