Resources Numerical accuracy Calculation policy

Pipe run points with fall applied

Applies the fall of a sloped pipe run to its corner points and reads the outside diameter of the pipe.

How the precision is kept

Point coordinates are 64-bit numbers in millimeters. The fall is accumulated along the horizontal length of each leg and subtracted from the height.

Calculations under this policy

2 calculations 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/plant/lib/runs.js BimCraft 0.8.1 64-bit 2 calculations Reviewed

Tests None found by the review

Fall along a run

64-bit

The corner points with the slope applied to the heights.

zᵢ = zᵢ − slope × Σ √(Δx² + Δy²)

Math.hypot for each horizontal leg and a running sum for the fall, all in 64-bit. The filter compares each point with the previous point before filtering, not with the last kept point.

  • addons/plant/lib/runs.js
  • lines 20 to 29
  • BimCraft 0.8.1
export function withSlope(points, slope) {
  const out = [];
  let fall = 0;
  for (let i = 0; i < points.length; i++) {
    const q = points[i];
    if (i) { const p = points[i - 1]; fall += (slope || 0) * Math.hypot(q[0] - p[0], q[1] - p[1]); }
    out.push([q[0], q[1], (q[2] || 0) - fall]);
  }
  return out.filter((q, i) => !i || Math.hypot(q[0] - out[i - 1][0], q[1] - out[i - 1][1], q[2] - out[i - 1][2]) > 0.5);
}

Outside diameter of a run

64-bit

The pipe outside diameter in millimeters from the size table.

od = in × 25.4

Table inches times 25.4, which is exact; no rounding. A pipe whose size is not in the table gets 60.

  • addons/plant/lib/runs.js
  • lines 42 to 46
  • BimCraft 0.8.1
const ps = kind === 'pipe' ? pipeSize(mat, cls, size) : null;
const valves = parseJson(g('Valves'), []);
return {
  guid: String(p.guid || p.id), id: p.id, tag: String(p.name || p.tag || ''), kind, system: String(g('System') || ''), mat, cls, size,
  od: ps ? ps.od * 25.4 : 60, points, slope,

In detail

Method
fall at a corner = slope × the sum of horizontal leg lengths up to it; z = z − fall.
Number types
64-bit numbers.
Tolerances
Points that end up closer than 0.5 mm (absolute, 3D distance) to the previous kept point in the list are dropped.
Limits
When the pipe size is not found in the table the outside diameter defaults to 60 mm.

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