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.
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.
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.
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.