Resources Numerical accuracy
Calculations
Every calculation under our calculation policies: what it works out, its formula and the precision it runs at. Open one to see its code as it is in the released app.
Calculations
-
Text position, height and angle
Where each run of text starts, how tall it is, its angle and its width, in displayed-page points.
height = |M·(t₂, t₃)|; angle = atan2 of M·(t₀, t₁); width = |w| × |(m₀, m₁)|
PDF page vectors and snapping to them pdf-vector.js64-bit- CadCraft
- BimCraft
-
Flattening curves to segments
Turns every line and curve of the page into straight segments for snapping.
B(t) = u³p₀ + 3u²t·c₁ + 3u·t²·c₂ + t³p₃, u = 1 − t, t = 1⁄8 … 8⁄8
PDF page vectors and snapping to them pdf-vector.js32-bit in part- CadCraft
- BimCraft
-
Nearest point on a segment
The point of a segment closest to the pointer.
t = ((p − a)·(b − a)) ÷ |b − a|², held to [0, 1]; q = a + t(b − a)
PDF page vectors and snapping to them pdf-snap.js32-bit in part- CadCraft
- BimCraft
-
Crossing of two segments
The point where two segments of the page cross, or nothing when they are parallel, apart, or only meet end to end.
den = r × s; u = ((c − a) × s) ÷ den; v = ((c − a) × r) ÷ den; point = a + u·r
PDF page vectors and snapping to them pdf-snap.js32-bit in part- CadCraft
- BimCraft
-
Choosing the snap point
Picks the end, crossing, middle or nearest point within the snap distance of the pointer.
midpoint = (a + b) ÷ 2; candidate kept when |candidate − p| ≤ tol
PDF page vectors and snapping to them pdf-snap.js32-bit in part- CadCraft
- BimCraft
-
Unit sizes
Builds each unit's row: its fraction of the base unit and the factor used for quick conversion.
factor = n ÷ d (× π for degrees and gons)
Unit table: reading and writing values unit-table.js Every appExact -
Numbers and fractions
Reads 6, 6.5, 6 1/2, 6-1/2 or 1/2 as a number.
whole + numerator ÷ denominator
Unit table: reading and writing values unit-table.js Every app64-bit -
Feet and inches
Reads 12'6", 12'-6 1/2" or 6" as inches.
inches = feet × 12 + inches
Unit table: reading and writing values unit-table.js Every app64-bit -
Degrees, minutes and seconds
Reads 45°30'15" or 45d30m15s as degrees.
degrees + minutes ÷ 60 + seconds ÷ 3600
Unit table: reading and writing values unit-table.js Every app64-bit -
Slopes
Reads 2%, 3H:1V, 1:3 or 6/12 as a grade (rise over run).
percent ÷ 100; H:V → V ÷ H; rise:run → rise ÷ run
Unit table: reading and writing values unit-table.js Every app64-bit -
Writing feet and inches
Writes a length as feet, inches and a fraction of an inch.
n = round(|inches| × den); feet = ⌊n ÷ 12den⌋; inches = ⌊rest ÷ den⌋; fraction = rest ÷ den, reduced
Unit table: reading and writing values unit-table.js Every app64-bit -
Writing degrees, minutes and seconds
Writes an angle as degrees, minutes and seconds.
t = round(|degrees| × 3600 × 10^dec); split by 3600 and 60
Unit table: reading and writing values unit-table.js Every app64-bit -
Writing decimals
Writes a number with a fixed count of decimals.
text = v.toFixed(dec)
Unit table: reading and writing values unit-table.js Every app64-bit -
Rigid fit from point pairs
The rotation and shift that best take the picked points of one scan onto their targets, with the error left at each pair.
R from the top eigenvector (a quaternion) of Horn's 4 × 4 matrix; t = c_dst − R·c_src; rms = √(Σ rᵢ² ÷ n)
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Eigenvalues of a symmetric matrix
Eigenvalues and eigenvectors of the 3 × 3 and 4 × 4 symmetric matrices the fit and the normals use.
Jacobi rotations: θ = (a_qq − a_pp) ÷ 2a_pq; t = sign(θ) ÷ (|θ| + √(θ² + 1))
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Combining transforms
The product of two 4 × 4 transforms, used to add each iteration's step to the running transform.
o = a · b, each entry a sum of four products
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Inverse of a rigid transform
The transform that undoes a rotation and shift.
R⁻¹ = Rᵀ; t′ = −Rᵀ·t
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Transform in shifted coordinates
Rewrites a transform for coordinates measured from the working origin, and back.
t_local = t + R·o − o; back: t = t_local − R·o + o
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Is a matrix a rigid transform
Checks that a matrix is a pure rotation and shift before it is accepted.
|rᵢ·rⱼ − δᵢⱼ| ≤ tol; |det − 1| ≤ tol; last row 0 0 0 1 within tol
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Rotation about an axis
The 4 × 4 matrix for a turn by an angle about an axis through a center.
R = c·I + s·[axis]ₓ + (1 − c)·axis·axisᵀ; t = center − R·center
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Angle and shift of a transform in words
The rotation angle in degrees and the length of the shift that a result is reported with.
angle = acos((trace − 1) ÷ 2); shift = |t|
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Working points of a scan
The thinned copy of a scan's points, measured from the session origin, that registration works on.
work = pos + cloud origin − session origin, every stride-th point
Scan registration register.js32-bit in part- CadCraft
- BimCraft
-
Nearest point in the fixed scans
For a moved point, the closest point of the fixed scans within the match distance.
d² = Δx² + Δy² + Δz², smallest over the grid cells searched ring by ring
Scan registration register.js64-bit- CadCraft
- BimCraft
-
Surface normals
The direction square to the surface at each fixed point, from its 10 nearest neighbors.
normal = eigenvector of the smallest eigenvalue of the neighbors' covariance
Scan registration register.js32-bit in part- CadCraft
- BimCraft
-
Matching and the error of a step
Pairs each moving point with its nearest fixed point and reports the root-mean-square distance, and the distance along the normals.
rms = √(Σ d² ÷ matched); plane rms = √(Σ ((p − q)·n)² ÷ matched)
Scan registration register.js32-bit in part- CadCraft
- BimCraft
-
Point-to-plane step
The small turn and shift that reduce the distances along the normals in one iteration.
minimize Σ ((ω × p + t + p − q)·n)²: 6 × 6 normal equations for (ω, t); R = rotation by |ω| about ω
Scan registration register.js32-bit in part- CadCraft
- BimCraft
-
Solving the 6 × 6 system
Solves the linear equations of the point-to-plane step.
Gaussian elimination with partial pivoting, then back substitution
Scan registration register.js64-bit- CadCraft
- BimCraft
-
When the iteration stops
Decides when a phase has settled and narrows the match distance for the next step.
stop when |previous − error| ≤ tol × max(error, 1e-12) or error < 1e-12; cut = min(start, max(2.5 × rms, 1e-6 × diagonal))
Scan registration register.js64-bit- CadCraft
- BimCraft
-
A level written as text
Reads a level such as 104.37, +104,37 or EL 104.37 from a text.
value = Number(whole digits . decimal digits) × sign
Survey levels from text and the survey check survey.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Levels into project units
A level point's x, y and z in project units.
x·k, y·k, z·k
Survey levels from text and the survey check survey.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Extent and distance from the origin
How far the data spans and how far it lies from zero, in meters.
span = |(maxX − minX, maxY − minY)| × m per unit; far = max |coordinate| × m per unit
Survey levels from text and the survey check survey.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Median
The middle value of a list of levels.
odd count: the middle value; even: mean of the two middle values
Survey levels from text and the survey check survey.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Level outliers
Counts levels that are far from the rest, and levels of exactly 0 that look like missing heights.
MAD = median(|z − median|) × 1.4826; limit = max(6 × MAD, 5 m); outlier when |z − median| > limit
Survey levels from text and the survey check survey.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Duplicate points
Counts points that sit on top of another point, with the same or a different level.
cell = 1 mm; key = (round(x ÷ cell), round(y ÷ cell)); same level when |Δz| ≤ cell
Survey levels from text and the survey check survey.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Height unit factor
The factor that turns a file's heights into the project's unit.
factor = meters per file unit ÷ meters per project unit
Elevation grids into survey points and a grid surface terrain.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Cell center in the file's coordinates
The x and y of a raster cell's center.
x = g₀ + (col + 0.5)·g₁ + (row + 0.5)·g₂; y = g₃ + (col + 0.5)·g₄ + (row + 0.5)·g₅
Elevation grids into survey points and a grid surface terrain.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Cells inside a box
The range of columns and rows whose centers can fall inside a picked box.
(col, row) = G⁻¹·(x − g₀, y − g₃) − 0.5; c₀ = ⌈min − 1e-9⌉, c₁ = ⌊max + 1e-9⌋ + 1
Elevation grids into survey points and a grid surface terrain.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
A box through a coordinate conversion
The box round a rectangle after its outline is converted to another coordinate system.
17 points along each side, converted, then minimum and maximum
Elevation grids into survey points and a grid surface terrain.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Survey points from a grid
One survey point per grid node that has a height.
(x, y) = conversion(cell center); z = file height × unit factor
Elevation grids into survey points and a grid surface terrain.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Grid surface
A triangulated surface from the grid: two triangles per cell.
cell corners a (SW), b (SE), c (NE), d (NW): triangles a–b–c and a–c–d
Elevation grids into survey points and a grid surface terrain.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
1-2-5 step
Rounds a step up to 1, 2 or 5 times a power of ten.
p = 10^⌊log₁₀ x⌋; m = x ÷ p; 1, 2, 5 or 10 × p
Elevation grids into survey points and a grid surface terrain.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Turning a direction
A direction turned by an angle in degrees.
(x·cos a − y·sin a, x·sin a + y·cos a), each rounded to 6 decimals
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Turn between two walls
The signed angle from one wall direction to the next, in degrees.
atan2(u₀ × u₁, u₀ · u₁) × 180 ÷ π
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
End of a wall typed as length and angle
The end point of a wall from its start, length and angle.
(x + L·cos a, y + L·sin a), rounded to 6 decimals
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
End of an arc typed as radius and sweep
The end point of an arc wall from its radius, sweep and the heading of its chord.
chord = 2·R·sin(|sweep| ÷ 2); end = start + chord at the heading
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Sagitta
How far the middle of a straight back of width w stands off a circle of radius r.
s = r − √(r² − w² ÷ 4)
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Arc through three points
The radius, center and signed sweep of the arc picked as start, middle and end.
d = 2·(aₓ(bᵧ − cᵧ) + bₓ(cᵧ − aᵧ) + cₓ(aᵧ − bᵧ)); uₓ = Σ |p|²·(Δy) ÷ d; uᵧ = Σ |p|²·(Δx) ÷ d; r = |a − u|
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Arc from two ends and a sweep
The radius, center, chord, arc length and sagitta of an arc wall.
r = chord ÷ (2·sin(θ ÷ 2)); center = middle ± normal × r·cos(θ ÷ 2); arc length = r·θ; sagitta = r·(1 − cos(θ ÷ 2))
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Points along an arc wall
An arc wall as n straight pieces.
φᵢ = a₀ ± |θ|·i ÷ n; point = center + r·(cos φ, sin φ), rounded to 6 decimals
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Back line and half angle of each cabinet on an arc
The radius of each cabinet's back line and the half angle it takes up.
bay: H = √(R² − w² ÷ 4); bow or curved front: H = R; half angle = atan2(w ÷ 2, H), or w ÷ (2R) for a curved front; front radius = H − d
Cabinets on angled and curved walls addons/cabinetcraft/lib/angled.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
A calculation is added only after its source was read. Each statement can be checked in the code shown on its policy's page; the app repositories are public. When a release changes a calculation, its page says so until it has been read again.