diff --git a/src/geometry/roof.ts b/src/geometry/roof.ts index a6e4f5d..6b5d646 100644 --- a/src/geometry/roof.ts +++ b/src/geometry/roof.ts @@ -128,6 +128,37 @@ function computeCanonical( case "sattel": { const rz = e + h; + const hh = Math.min(0.9, Math.max(0, roof.halfHipRatio ?? 0)); + if (hh > 1e-6 && halfW > halfD * hh + 1e-6) { + // Krüppelwalm: oberer Giebelteil (Anteil `hh` der Firsthöhe) als kleine Walmflächen + // gleicher Neigung — Walmlauf = halbe Tiefe · hh, First entsprechend verkürzt. + const kz = e + h * (1 - hh); + const yk0 = y0 + halfD * (1 - hh); + const yk1 = y1 - halfD * (1 - hh); + const d = halfD * hh; + return { + eaves, + ridges: [[P(x0 + d, yc), P(x1 - d, yc)]], + hips: [ + [P(x0, yk0), P(x0 + d, yc)], + [P(x0, yk1), P(x0 + d, yc)], + [P(x1, yk0), P(x1 - d, yc)], + [P(x1, yk1), P(x1 - d, yc)], + ], + breaks: [], + planes: [ + { pts: [[x0, y0, e], [x1, y0, e], [x1, yk0, kz], [x1 - d, yc, rz], [x0 + d, yc, rz], [x0, yk0, kz]] }, + { pts: [[x0, y1, e], [x1, y1, e], [x1, yk1, kz], [x1 - d, yc, rz], [x0 + d, yc, rz], [x0, yk1, kz]] }, + { pts: [[x0, yk0, kz], [x0, yk1, kz], [x0 + d, yc, rz]] }, + { pts: [[x1, yk0, kz], [x1, yk1, kz], [x1 - d, yc, rz]] }, + ], + gables: [ + [[x0, y0, e], [x0, y1, e], [x0, yk1, kz], [x0, yk0, kz]], + [[x1, y0, e], [x1, y1, e], [x1, yk1, kz], [x1, yk0, kz]], + ], + ridgeHeight: h, + }; + } return { eaves, ridges: [[P(x0, yc), P(x1, yc)]], diff --git a/src/geometry/roofSkeleton.test.ts b/src/geometry/roofSkeleton.test.ts index 6c54b5e..b268362 100644 --- a/src/geometry/roofSkeleton.test.ts +++ b/src/geometry/roofSkeleton.test.ts @@ -143,3 +143,22 @@ describe("Walmdach über beliebigen einfachen Umrissen", () => { expect(roofGeometry(mk(rect), 0).planes.length).toBe(4); }); }); + +describe("Krüppelwalm (halfHipRatio) am Satteldach", () => { + const rect = [{ x: 0, y: 0 }, { x: 10, y: 0 }, { x: 10, y: 6 }, { x: 0, y: 6 }]; + const mk = (halfHipRatio?: number) => + ({ id: "R", type: "roof", floorId: "eg", categoryCode: "31", outline: rect, shape: "sattel", pitchDeg: 45, overhang: 0, ridgeAxis: "x", halfHipRatio }) as unknown as Roof; + it("ohne Krüppelwalm: 2 Flächen, mit 0.3: 4 Flächen, gleiche Firsthöhe, Grundfläche bleibt", () => { + expect(roofGeometry(mk(), 0).planes.length).toBe(2); + const g = roofGeometry(mk(0.3), 0); + expect(g.planes.length).toBe(4); + expect(g.ridgeHeight).toBeCloseTo(3, 6); + expect(g.planes.reduce((s, p) => s + planArea(p.pts), 0)).toBeCloseTo(60, 6); + }); + it("First um die Walmlänge verkürzt (halbe Tiefe 3 · 0.3 = 0.9 m je Seite)", () => { + const g = roofGeometry(mk(0.3), 0); + const [a, b] = g.ridges[0]; + expect(a.x).toBeCloseTo(0.9, 6); + expect(b.x).toBeCloseTo(9.1, 6); + }); +}); diff --git a/src/i18n/de.ts b/src/i18n/de.ts index e8d3908..24f9af4 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -468,6 +468,7 @@ export const de = { "objinfo.roof.mansard.walm": "Walm-Mansarde", "objinfo.roof.mansard.zelt": "Zelt-Mansarde", "objinfo.roof.mansardKnee": "Knicklage (% Spannweite)", + "objinfo.roof.halfHip": "Krüppelwalm (% Firsthöhe)", "objinfo.roof.width": "Breite (m)", "objinfo.roof.depth": "Tiefe (m)", "objinfo.roof.overhang": "Überstand Traufe (m)", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 3f86d7c..5409e96 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -466,6 +466,7 @@ export const en: Record = { "objinfo.roof.mansard.walm": "Hip mansard", "objinfo.roof.mansard.zelt": "Pavilion mansard", "objinfo.roof.mansardKnee": "Knee position (% span)", + "objinfo.roof.halfHip": "Half-hip (% ridge height)", "objinfo.roof.width": "Width (m)", "objinfo.roof.depth": "Depth (m)", "objinfo.roof.overhang": "Eaves overhang (m)", diff --git a/src/model/types.ts b/src/model/types.ts index 5ce25cc..4131f68 100644 --- a/src/model/types.ts +++ b/src/model/types.ts @@ -1326,6 +1326,11 @@ export interface Roof { * gemessen von der Traufe. Kleiner ⇒ steiler Sockel kürzer; fehlt ⇒ 0.4. */ mansardKneeRatio?: number; + /** + * Nur Satteldach: Krüppelwalm. Anteil der Firsthöhe (0..0.9), der an BEIDEN Giebeln + * abgewalmt wird — 0/fehlt = voller Giebel, 0.3 = oberes Drittel als kleine Walmflächen. + */ + halfHipRatio?: number; /** Dachüberstand an der TRAUFE (Meter, senkrecht zum First); 0 = bündig. */ overhang: number; /** diff --git a/src/panels/ObjectInfoPanel.tsx b/src/panels/ObjectInfoPanel.tsx index 82bf908..330830b 100644 --- a/src/panels/ObjectInfoPanel.tsx +++ b/src/panels/ObjectInfoPanel.tsx @@ -915,6 +915,11 @@ export function RoofSection({ host.onSetRoofPatch({ mansardKneeRatio: Math.max(5, Math.min(49, v)) / 100 }), )} + {roof.shape === "sattel" && + numField("objinfo.roof.halfHip", (roof.halfHipRatio ?? 0) * 100, 5, (v) => + host.onSetRoofPatch({ halfHipRatio: Math.max(0, Math.min(90, v)) / 100 }), + )} + {/* Grundriss-Masse (Breite/Tiefe): das Umriss-Rechteck neu bilden, die untere/linke Ecke (minX/minY) bleibt fix. */} {numField("objinfo.roof.width", roof.width, 0.1, (v) => { diff --git a/src/state/selectionInfo.ts b/src/state/selectionInfo.ts index 17c429c..ee304e1 100644 --- a/src/state/selectionInfo.ts +++ b/src/state/selectionInfo.ts @@ -96,6 +96,7 @@ export interface RoofInfo { mansardType?: "giebel" | "walm" | "zelt"; /** Mansarde-Knicklage (0..0.5 der halben Spannweite) — nur Mansarde relevant. */ mansardKneeRatio?: number; + halfHipRatio?: number; /** Dachüberstand an der Traufe (Meter). */ overhang: number; /** Dachüberstand am Ortgang (Giebelseite, Meter); fehlt ⇒ = Traufüberstand. */ @@ -843,6 +844,7 @@ function roofSelection(project: Project, roof: Roof): Selection { roofTypeId: roof.roofTypeId, mansardType: roof.mansardType, mansardKneeRatio: roof.mansardKneeRatio, + halfHipRatio: roof.halfHipRatio, overhang: roof.overhang, overhangGable: roof.overhangGable, ridgeAxis: roof.ridgeAxis,