Dach: Pultdach ueber rechtwinkligen nicht-rechteckigen Grundrissen (eine Ebene, Giebel quer zum First)
This commit is contained in:
1 parent
b84e78ce29
commit
707944a045
2 files changed
+61
-1
No files matched your search
+50
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
import type { Project, Roof, Vec2 } from "../model/types";
|
||||
import { getFloor } from "../model/types";
|
||||
import { cleanRing, isRectilinearNonRect, offsetRectilinear, rectilinearHipRoof } from "./roofSkeleton";
|
||||
import { cleanRing, convexPieces, isRectilinearNonRect, offsetRectilinear, rectilinearHipRoof } from "./roofSkeleton";
|
||||
|
||||
/** 3D-Punkt [x, y, z=Höhe] in Modell-Metern. */
|
||||
export type Vec3 = [number, number, number];
|
||||
@@ -341,6 +341,9 @@ export function roofGeometry(roof: Roof, eavesZ: number): RoofGeometry {
|
||||
if ((roof.shape === "walm" || roof.shape === "sattel") && isRectilinearNonRect(roof.outline)) {
|
||||
return rectilinearWalm(roof, eavesZ);
|
||||
}
|
||||
if (roof.shape === "pult" && isRectilinearNonRect(roof.outline)) {
|
||||
return rectilinearPult(roof, eavesZ);
|
||||
}
|
||||
const bb = roofBBox(roof.outline);
|
||||
const oe = Math.max(0, roof.overhang); // Traufüberstand (senkrecht zum First)
|
||||
const og = Math.max(0, roof.overhangGable ?? roof.overhang); // Ortgang (entlang First)
|
||||
@@ -408,6 +411,52 @@ function rectilinearWalm(roof: Roof, eavesZ: number): RoofGeometry {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Pultdach auf rechtwinkligem Grundriss: EINE Ebene über dem (um Traufe/Ortgang
|
||||
* geweiteten) Umriss. Tief bei kleinstem y (First entlang x) bzw. x (First entlang y),
|
||||
* Steigung wie beim Rechteck-Pult; Kanten quer zum First bekommen senkrechte Giebel.
|
||||
*/
|
||||
function rectilinearPult(roof: Roof, eavesZ: number): RoofGeometry {
|
||||
let ring = cleanRing(roof.outline);
|
||||
let area = 0;
|
||||
for (let i = 0; i < ring.length; i++) {
|
||||
const p = ring[i];
|
||||
const q = ring[(i + 1) % ring.length];
|
||||
area += p.x * q.y - q.x * p.y;
|
||||
}
|
||||
if (area < 0) ring = [...ring].reverse();
|
||||
const oe = Math.max(0, roof.overhang);
|
||||
const og = Math.max(0, roof.overhangGable ?? roof.overhang);
|
||||
const ax = roof.ridgeAxis === "x";
|
||||
const eaves = offsetRectilinear(ring, (a, b) => {
|
||||
const alongX = Math.abs(b.x - a.x) > Math.abs(b.y - a.y);
|
||||
return alongX === ax ? oe : og;
|
||||
});
|
||||
const tan = Math.tan(Math.max(0, roof.pitchDeg) * DEG);
|
||||
const s = (p: Vec2) => (ax ? p.y : p.x);
|
||||
const smin = Math.min(...eaves.map(s));
|
||||
const smax = Math.max(...eaves.map(s));
|
||||
const z = (p: Vec2) => eavesZ + tan * (s(p) - smin);
|
||||
const up = (p: Vec2): Vec3 => [p.x, p.y, z(p)];
|
||||
const base = (p: Vec2): Vec3 => [p.x, p.y, eavesZ];
|
||||
const gables: Vec3[][] = [];
|
||||
eaves.forEach((a, i) => {
|
||||
const b = eaves[(i + 1) % eaves.length];
|
||||
const alongX = Math.abs(b.x - a.x) > Math.abs(b.y - a.y);
|
||||
if (alongX === ax) return;
|
||||
gables.push([base(a), base(b), up(b), up(a)]);
|
||||
});
|
||||
return {
|
||||
eaves,
|
||||
ridges: [], // höchste Kante(n): Rand bei smax
|
||||
hips: [],
|
||||
breaks: [],
|
||||
planes: convexPieces(eaves).map((pc) => ({ pts: pc.map(up) })),
|
||||
gables,
|
||||
ridgeHeight: (smax - smin) * tan,
|
||||
};
|
||||
}
|
||||
|
||||
/** Punkt-in-Polygon (Ray-Casting), 2D-Aufsicht. */
|
||||
function pointInPolygon2D(p: Vec2, poly: Vec2[]): boolean {
|
||||
let inside = false;
|
||||
|
||||
@@ -72,3 +72,14 @@ describe("Satteldach auf L: Ortgang-Überstand", () => {
|
||||
expect(Math.max(...ys)).toBeCloseTo(6.5, 6);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Pultdach auf L-Grundriss", () => {
|
||||
const roof = { id: "R", type: "roof", floorId: "eg", categoryCode: "31", outline: L, shape: "pult", pitchDeg: 45, overhang: 0, ridgeAxis: "x" } as unknown as Roof;
|
||||
it("eine Ebene über dem Umriss: Fläche = Grundriss, Höhe steigt mit y bis 6 m", () => {
|
||||
const g = roofGeometry(roof, 0);
|
||||
expect(g.planes.reduce((s, p) => s + planArea(p.pts), 0)).toBeCloseTo(11 * 4 + 8 * 2, 6);
|
||||
expect(g.ridgeHeight).toBeCloseTo(6, 6);
|
||||
for (const pl of g.planes) for (const v of pl.pts) expect(v[2]).toBeCloseTo(v[1], 6);
|
||||
expect(g.gables.length).toBe(3);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user