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
-
Turn angle of a fitting
The angle a two-port fitting turns the pipe through.
turn = 180 − acos(p · q) × 180 ÷ π, rounded to 2 decimals
Piping in an IFC file as PCF components ifc/pipes.js64-bit- BimCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
-
Center point of a bend
The corner where the axes of a bend's two ports meet.
s = (b e − c d) ÷ (a c − b²), t = (a e − b d) ÷ (a c − b²); center = midpoint of the two closest points
Piping in an IFC file as PCF components ifc/pipes.js64-bit- BimCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
-
A group value by its code
Turns one group's text into a real number, a whole number, a true or false, or text.
codes 10–59, 110–149, 210–239, 460–469, 1010–1059: parseFloat; 60–99, 160–179, 270–289, 370–389, 400–409, 420–429, 440–459, 1060–1071: parseInt
DXF reading into the shared drawing model dxf-model.js64-bit- CadCraft
- BimCraft
- TakeoffCraft
- CivilCraft
-
Arc angles
An arc's start and end angles in radians.
angle = degrees × (π ÷ 180)
DXF reading into the shared drawing model dxf-model.js64-bit- CadCraft
- BimCraft
- TakeoffCraft
- CivilCraft
-
Multi-line text direction
The direction vector of multi-line text, from the file's vector or from its rotation angle.
x axis = group 11 when present; otherwise (cos(a), sin(a)), a = degrees × (π ÷ 180)
DXF reading into the shared drawing model dxf-model.js64-bit- CadCraft
- BimCraft
- TakeoffCraft
- CivilCraft
-
Hatch arc and ellipse edges
The center, radius or axes, and start and end angles of the curved edges of a hatch boundary.
angle = degrees × (π ÷ 180); missing end angle = 360 degrees
DXF reading into the shared drawing model dxf-model.js64-bit- CadCraft
- BimCraft
- TakeoffCraft
- CivilCraft
-
abs, round, ceil and floor
The four functions an expression may call.
round(x) = floor(x + 0.5) for x ≥ 0, −floor(−x + 0.5) for x < 0; ceil(x) = ⌈x − 1e-9·max(1, |x|)⌉; floor(x) = ⌊x + 1e-9·max(1, |x|)⌋
Arithmetic on typed lengths lencalc.js64-bit- CadCraft
- ModelCraft
- MarkupCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
-
Adding and subtracting
Sums and differences of lengths, left to right.
Arithmetic on typed lengths lencalc.js64-bit- CadCraft
- ModelCraft
- MarkupCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
-
Multiplying and dividing
Products and quotients of a length and plain numbers, left to right.
Arithmetic on typed lengths lencalc.js64-bit- CadCraft
- ModelCraft
- MarkupCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
-
The answer
The final value and whether it is a length or a plain number.
Arithmetic on typed lengths lencalc.js64-bit- CadCraft
- ModelCraft
- MarkupCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
-
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 -
Guard on every written measure
Decides what is written when a value is missing or not a number.
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Arc angles brought into one turn
Brings an angle into the range from 0 up to 2π before it is written.
r = a mod 2π; r + 2π when r < 0
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Arc
Writes an arc's center, radius and two angles.
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Line
Writes a line's two end points.
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Polyline vertices
Writes the vertices of a lightweight polyline.
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Vertex widths
Writes the start and end width at a polyline vertex.
equal widths: one value, −|width|
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Linetype pattern length
The total length of a linetype's dash pattern.
length = Σ |element length|
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Text direction
The x-axis direction written for a block of text.
x axis = (cos θ, sin θ, 0)
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Block scale
Writes the three scale factors of a block reference in the format's compact form.
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Single-line text
Writes a text's insertion point, height, rotation, width factor and oblique angle.
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Extension record values
Writes the numbers kept in an extension record.
DWG object values written and read dwg/objects-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Block content matrix of a multileader
The 4 × 4 matrix written for a multileader's block content when the model gives none.
M = translate(l) · rotate_z(θ) · scale(s)
DWG object values written and read dwg/mleader-write.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Line read
Reads a line's two end points.
DWG object values written and read dwg/objects-read.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Polyline vertices read
Reads the vertices of a lightweight polyline.
DWG object values written and read dwg/objects-read.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
North direction of older geolocation data
Turns the north angle of a version 1 geolocation object into a direction vector.
north = (sin a, cos a)
DWG object values written and read dwg/objects-read.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Fit point parameters and knots
The parameter of each fit point along the spline, and the knot vector built from them.
u₀ = 0; uᵢ = uᵢ₋₁ + |Qᵢ − Qᵢ₋₁|; knots = [0,0,0,0, u₁ … uₙ₋₂, L,L,L,L]
Spline through fit points dwg/spline-fit.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Cubic basis functions at a parameter
The four B-spline basis values that weigh the control points at one fit point.
Cox–de Boor recurrence, degree 3
Spline through fit points dwg/spline-fit.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Start condition
The rows that pin the first control point and set the spline's start tangent or a natural start.
P₀ = Q₀; P₁ − P₀ = T₀ × u₄ ÷ 3 or P₀ ÷ u₄ − P₁ (1 ÷ u₄ + 1 ÷ u₅) + P₂ ÷ u₅ = 0
Spline through fit points dwg/spline-fit.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
End condition
The rows that pin the last control point and set the spline's end tangent or a natural end.
Pₘ₋₁ = Qₙ₋₁; Pₘ₋₁ − Pₘ₋₂ = T₁ × (L − uₘ₋₁) ÷ 3 or the zero second derivative row
Spline through fit points dwg/spline-fit.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Solve for the control points
Solves the banded system for the x, y and z of every control point.
A · P = B
Spline through fit points dwg/spline-fit.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Unit vector
A vector scaled to length 1.
n = a ÷ |a|; [0, 0, 0] when |a| ≤ 1e-15
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Polygon normal
The unit normal of a polygon given by its corner points.
N = Σ (pᵢ − pᵢ₊₁) × (pᵢ + pᵢ₊₁) taken per axis, then normalized
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Polygon area in 3D
The area of a flat polygon in space.
area = |Σ (pᵢ − pᵢ₊₁) × (pᵢ + pᵢ₊₁)| ÷ 2
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Plane through a point
A plane as a unit normal and an offset, with the normal's sign made canonical.
n·p = d; first component of n with |n| > 1e-9 is made positive
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Same plane test
Whether two planes are the same plane.
|n₁·n₂| > 1 − 1e-9 and |d₁ × sign(n₁·n₂) − d₂| ≤ 1e-6
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Closest points of a line and a segment
The nearest points between a ray's line and an edge.
den = (d·d)(u·u) − (d·u)²; t = (B·E − C·D) ÷ den; s = (A·E − B·D) ÷ den, clamped to [0, 1]
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Closest points of two lines
The nearest points between two infinite lines, or nothing when they are parallel.
den = A·C − B²; parallel when |den| < 1e-14 × A × C
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Ray and plane
The point where a ray's line meets a plane.
t = (d_plane − n·o) ÷ (n·dir); p = o + t × dir
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Ray and triangle
The distance along a ray to a triangle, or nothing when it misses.
Möller–Trumbore: det = e₁·(d × e₂); u, v, t from three scalar triple products ÷ det
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Rotation about an axis through a point
The 4×4 matrix that turns geometry by an angle about an axis through a given point.
M = T(about) × R(axis, θ) × T(−about), R from Rodrigues' formula
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Transform a point
A point moved by a 4×4 matrix.
p′ = (M × [x, y, z, 1]) ÷ w
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Inverse of a 4×4 matrix
The matrix that undoes a transform, used to move points into a group's own coordinates.
M⁻¹ = adj(M) ÷ det(M), with det from twelve 2×2 minors
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
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.