Resources Numerical accuracy Calculation policy

Rooms handed to add-ons with their doors, windows and walls

Gives an add-on each room of a level with its outline, area and elevation, and decides which doors, windows and walls belong to the room's edge.

How the precision is kept

The outline, holes and area are passed on as the room finder returns them; this file adds no arithmetic to them. Doors, windows and walls are attached by the 64-bit distance from a point to the nearest edge of the room outline, compared with fixed distances in millimeters.

Calculations under this policy

1 calculation in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.

addons/bimcraft-api.js BimCraft 0.8.1 64-bit 1 calculation Reviewed

Tests None found by the review

Openings and walls on a room's edge

64-bit

Finds the doors, windows and walls that lie on the outline of a room.

t = clamp(((p − a) · (b − a)) ÷ |b − a|², 0, 1); d = |p − a − t (b − a)|; on the edge if d ≤ tolerance

The distance is one Math.hypot of two differences; a zero-length edge uses a divisor of 1 instead of dividing by zero. The tolerances are 700 mm for doors and windows and half the wall thickness plus 60 mm for a wall's midpoint, neither scaled to the room.

  • addons/bimcraft-api.js
  • lines 193 to 198
  • BimCraft 0.8.1
const segD = (p, a, b) => { const dx = b[0] - a[0], dy = b[1] - a[1], L = dx * dx + dy * dy || 1, t = Math.max(0, Math.min(1, ((p[0] - a[0]) * dx + (p[1] - a[1]) * dy) / L)); return Math.hypot(p[0] - a[0] - dx * t, p[1] - a[1] - dy * t); };
for (const r of rooms) {
  const edge = (p, tol) => r.poly.some((q, i) => segD(p, q, r.poly[(i + 1) % r.poly.length]) <= tol);
  out.push(clone({ storey: lv.guid, storeyName: lv.name, index: r.index, name: lv.name + ': ' + String(r.index + 1), poly: r.poly, holes: r.holes, area: r.area, z: lv.elevation,
    doors: doors.filter((d) => edge([d.x, d.y], 700)), windows: windows.filter((d) => edge([d.x, d.y], 700)),
    walls: walls.filter((x) => edge([(x.a[0] + x.b[0]) / 2, (x.a[1] + x.b[1]) / 2], (x.t || 0) / 2 + 60)).map((x) => x.guid) }));

In detail

Method
Point-to-segment distance to every edge of the room outline; the least distance decides.
Number types
64-bit numbers; the result is copied through JSON, which keeps every 64-bit digit.
Tolerances
A door or window belongs to a room when its point is within 700 mm of the outline. A wall belongs when its midpoint is within half its thickness plus 60 mm. Both are absolute.
Limits
A wall is tested at its midpoint only, so a long wall that borders a room along part of its length is attached only if its midpoint lies on that room's edge.

Approach: 64-bit, direct

Every value is a 64-bit number from input to result. Formulas are closed form or a direct solve, and every comparison uses a stated tolerance.

Every policy that takes this approach