Converts cameras and section planes between the viewer and the model's own coordinates, and writes and reads them in BCF issue files.
How the precision is kept
Points and directions go through a 4 × 4 matrix and its inverse in 64-bit; the change between Y up and Z up is a swap and a sign. On writing, every number is rounded to six decimals. On reading, numbers are taken at full 64-bit digits and directions are normalized again.
Open item. Write direction components with all their digits; six decimals suit positions in meters but are coarse for unit vectors.
Calculations under this policy
8 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.
bcf.jsBimCraft 0.8.164-bit8 calculationsReviewed
Tests bin/test-bimcraft.mjs
Inverse of a 4 × 4 matrix
64-bit
The inverse of the model's coordination matrix.
M⁻¹ = adj(M) ÷ det(M)
Cofactor expansion in 64-bit and one division by the determinant. A zero determinant gives an all-zero matrix, not an error. The determinant is a sum of products with mixed signs, so digits are lost as the matrix nears singular.
How each coordinate, direction, field of view and scale is written in a viewpoint.
round(v × 10⁶) ÷ 10⁶
Every number written is rounded to six decimals. For a position in meters that is 0.001 mm. For a unit direction it limits the direction to about one part in a million, up to about 0.1 mm across 100 m for a section plane.
Each part is read with Number() at full 64-bit digits. A missing or non-numeric part drops the whole point.
bcf.js
lines 155 to 156
BimCraft 0.8.1
const num = (v) => { const x = Number(v); return Number.isFinite(x) ? x : null; };
const xyz = (n) => { if (!n) return null; const v = ['X', 'Y', 'Z'].map((k) => num(txt(n, k))); return v.every((x) => x !== null) ? v : null; };
Camera read from a viewpoint
64-bit
The camera of an issue as BimCraft keeps it.
The direction and the up vector are normalized again after reading. A missing or zero field of view becomes 60 and a missing or zero scale becomes 10.
bcf.js
lines 231 to 232
BimCraft 0.8.1
const vp = xyz(kid(cam, 'CameraViewPoint')), d = xyz(kid(cam, 'CameraDirection')), up = xyz(kid(cam, 'CameraUpVector'));
if (vp && d && up) camera = pc ? { kind: 'perspective', viewPoint: vp, direction: norm(d), up: norm(up), fov: num(txt(pc, 'FieldOfView')) || 60 } : { kind: 'orthogonal', viewPoint: vp, direction: norm(d), up: norm(up), scale: num(txt(oc, 'ViewToWorldScale')) || 10 };
In detail
Method
General 4 × 4 inverse by cofactors; IFC (x, y, z) = (x, −z, y) of the viewer point taken back through the coordination matrix.
Number types
64-bit numbers in plain arrays; decimal text in the file.
Tolerances
None in the conversions. Written values are rounded to 1e-6.
Limits
A coordination matrix with a zero determinant gives an all-zero inverse without an error. Unit directions written to six decimals are accurate to about one part in a million.
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.