Files
NextFloor/frontend/src/solar/fixtures.ts
T
2026-11-09 10:37:41 +01:00

18 lines
880 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Builders for the solar tests.
import { emptyBuilding, newFloor, type Building, type SolarField } from "../model.ts";
export const near = (a: number, b: number, eps = 1e-6) => {
if (Math.abs(a - b) >= eps) throw new Error(`${a} is not close to ${b}`);
};
/** A one-floor house of 12 × 7 m with 2.6 m high walls and the given roof. */
export function cottage(roof: Building["settings"]["roof"], elevation = 0): Building {
const b = emptyBuilding();
b.floors = [{ ...newFloor("g", "G", elevation), height: 2.6, rooms: [{ id: "r", name: "R", area_id: null, points: [[0, 0], [12, 0], [12, 7], [0, 7]], floor_material: "wood" }] }];
b.settings = { ...b.settings, wall_exterior: 0.3, roof };
return b;
}
export const field = (face: string, extra: Partial<SolarField> = {}): SolarField => ({ id: "f", face, u: 0.5, v: 0.5, rows: 1, cols: 2, portrait: true, ...extra });