Resources Numerical accuracy Calculation policy

Plant equipment written as an IFC file

Writes the Plant add-on's equipment, with its solids and nozzle ports, as a standalone IFC4 file in millimeters.

How the precision is kept

Every real number in the file goes through one formatter that rounds to 4 decimals. For coordinates in millimeters that is a 0.0001 mm grid. The same rounding is applied to direction components, so the turn of a piece of equipment is stored as a cosine and sine with 4 decimals. The rounding, not the 64-bit arithmetic before it, sets the accuracy of the file.

Open item. Write direction components at full 64-bit precision; the 4-decimal rounding suits coordinates in millimeters, not unit vectors.

Calculations under this policy

4 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/ifc-out.js BimCraft 0.8.1 64-bit 4 calculations Reviewed

Tests None found by the review

Number written to the file

64-bit

Formats a coordinate, direction component or property value as STEP text.

num(v) = round(v × 10⁴) ÷ 10⁴

The value is rounded to 4 decimals and then printed by toString, so the file holds at most 4 decimals of every number. It is used for vertex coordinates, placement points, direction components and real properties alike.

  • addons/plant/lib/ifc-out.js
  • line 52
  • BimCraft 0.8.1
const num = (v) => { const s = (Math.round(v * 1e4) / 1e4).toString(); return /[.eE]/.test(s) ? s : s + '.'; };

Placement of an item

64-bit

The position and the turn about the vertical axis of a piece of equipment in the file.

X direction = (cos a, sin a, 0), a = rot × π ÷ 180

The cosine and sine are computed in 64-bit and then pass through the 4-decimal formatter, so the stored X direction is not exactly a unit vector and its angle differs from the angle typed. The mesh vertices are written in the item's own axes, rounded to 0.0001 mm.

  • addons/plant/lib/ifc-out.js
  • lines 94 to 96
  • BimCraft 0.8.1
const rot = ((it.rot || 0) * Math.PI) / 180;
const pl = place(pSto, [it.x || 0, it.y || 0, it.z || 0], [0, 0, 1], [Math.cos(rot), Math.sin(rot), 0]);
const list = add('IFCCARTESIANPOINTLIST3D((' + eq.mesh.verts.map(vec).join(',') + '))');

Reference direction of a nozzle port

64-bit

A unit vector square to a nozzle's outward direction, used as the X axis of the port's placement.

x = (d × a) ÷ |d × a|, a = (1, 0, 0) or (0, 1, 0)

The helper axis is X unless the first component of the direction is 0.9 or more in size, so the cross product is never near zero for a unit direction. A zero length is replaced by 1 instead of dividing by zero.

  • addons/plant/lib/ifc-out.js
  • line 56
  • BimCraft 0.8.1
const perp = (d) => { const a = Math.abs(d[0]) < 0.9 ? [1, 0, 0] : [0, 1, 0]; const c = [d[1] * a[2] - d[2] * a[1], d[2] * a[0] - d[0] * a[2], d[0] * a[1] - d[1] * a[0]]; const l = Math.hypot(...c) || 1; return c.map((x) => x / l); };

Capacity property

64-bit

The capacity in cubic meters written to the CadCraft_Plant property set.

CapacityM3 = round(V × 1000) ÷ 1000

The capacity is rounded to 3 decimals of a cubic meter (1 liter) and then written through the 4-decimal formatter.

  • addons/plant/lib/ifc-out.js
  • line 111
  • BimCraft 0.8.1
props(el, 'CadCraft_Plant', [['Tag', it.tag], ['Type', eq.type], ['Description', it.desc], ['CapacityM3', eq.capacityM3 ? Math.round(eq.capacityM3 * 1000) / 1000 : undefined]]);

In detail

Method
num(v) = Math.round(v × 10⁴) ÷ 10⁴, printed with the shortest text that reads back to the same number; solids as IfcTriangulatedFaceSet; placements as IfcAxis2Placement3D.
Number types
64-bit numbers, written as decimal text.
Tolerances
Rounding step 0.0001 for every coordinate, direction component and real property. The file states a geometric precision of 1.E-05.
Limits
A direction component can be off by up to 0.00005, which is an angle of about 0.00005 radian for a small turn: about 0.5 mm at 10 m from the item's origin.

Approach: 64-bit, stated limit

The arithmetic is 64-bit, but the method or the data sets the accuracy: a solver tolerance, a mesh, a step size, a datum shift, a table. The limit is stated where the result is shown.

Every policy that takes this approach