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
-
Rounding of stored values
The two rounding helpers every stored number of an item goes through.
r4(v) = round(v × 10000) ÷ 10000; r2(v) = round(v × 100) ÷ 100
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Block to millimeters
The transform from a block's own coordinates and units to the item's millimeters.
M = [mm, 0, 0, mm, −base.x·mm, −base.y·mm]; scale of a transform = √|det|; angle = r4(atan2(y, x) in degrees)
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Lines, circles and arcs of a block
A block's lines, circles and arcs as plan entities in millimeters.
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Nested block references
The transform of a block reference inside the block, with its rows and columns.
local = T(insert) · R(rotation) · S(sx, sy) · T(−base + column·spacing ÷ sx, row·spacing ÷ sy)
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Mesh body from a block's 3D faces
The item's 3D body and height when the block holds 3D faces.
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Arcs as points, 5° steps
The points that replace a circle or arc that cannot stay an arc.
n = max(8, ⌈sweep ÷ 5°⌉); point = c + r·(cos a, sin a)
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Splines as points
The points that replace a block's spline in the item's plan.
de Boor recurrence at u = lo + (hi − lo)·s ÷ n, n = max(16, 8 × control points)
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Arc points for bounds
The points of an arc used to find a plan's bounds.
n = max(4, ⌈sweep ÷ 10°⌉); point = c + r·(cos a, sin a)
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Bounds of a plan
The box round an item's plan, from which its width and depth are taken.
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Box body on a plan
A box body standing on the plan's bounds with a given height.
w = max x − min x; d = max y − min y; each of x, y, z, w, d, h rounded to 4 decimals
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Item from a mesh file
A mesh file's triangles as an item body in millimeters, with its footprint and sizes.
p = file point × unit in mm; Y-up: (x, y, z) → (x, −z, y); stored = r4(p − (center x, max y, min z))
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
STL corners
The corner points of an STL file's triangles.
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
glTF accessor values
The numbers of a glTF position or index accessor.
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
glTF node transforms
The matrix that places each glTF node's mesh.
M = T · R(q) · S, R from the quaternion (qx, qy, qz, qw)
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Convex hull footprint
The outline round a mesh item's points, used as its plan.
monotone chain; turn = (a − o) × (b − o), popped when ≤ 0
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Box of a body
The box a body fills: a box body itself, or the extent of a mesh body.
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Box item from width, depth and height
The rectangle plan and box body of an item given only by its sizes.
x from −w ÷ 2 to +w ÷ 2; y from −d to 0; label height = min(0.18 d, 150), reduced to fit 90% of w
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Sizes from attributes
Width, depth and height read from a block's attributes.
Library item geometry from blocks, meshes and tables libitem.js64-bit- CadCraft
- BimCraft
-
Millimeters per unit
The table of unit factors.
in 25.4; ft 304.8; yd 914.4; mi 1 609 344; mil 0.0254; µm 0.001
Lengths and units for Library items libitem.jsExact- CadCraft
- BimCraft
-
Length from text
A typed or stored length in millimeters.
with a unit: n × factor; feet and inches: (feet × 12 + inches + a ÷ b) × 25.4; bare number: n × mm per unit
Lengths and units for Library items libitem.js64-bit- CadCraft
- BimCraft
-
Drawing units
The millimeters per drawing unit of a DWG or DXF file.
Lengths and units for Library items libitem.jsExact- CadCraft
- BimCraft
-
Pipe size in eighths of an inch
A decimal inch size written as a fraction, such as 1 1/2".
eighths = round((n − ⌊n⌋) × 8)
Lengths and units for Library items libitem.js64-bit- CadCraft
- BimCraft
-
Size label on the preview
The overall width and depth printed on an item's preview picture.
millimeters: round(mm); inches: round(mm ÷ 25.4 × 8) eighths
Lengths and units for Library items libitem.js64-bit- CadCraft
- BimCraft
-
Millimeters to drawing units
The factor that puts an item's millimeters into the drawing's units.
k = 1 ÷ (mm per drawing unit), or 1 when the drawing has no units
Library item placed as a block libplace.js64-bit- CadCraft
-
Plan entities in drawing units
Each line, circle, arc, polyline, ellipse, text, point and hatch of the item as a drawing object.
length × k; angle in degrees × π ÷ 180, reduced to [0, 2π)
Library item placed as a block libplace.js64-bit- CadCraft
-
Size attributes
The width, depth, height and weight written as attributes on the block.
Library item placed as a block libplace.js64-bit- CadCraft
-
Count and quantity of each item
How many times each Library item is placed and the total of their quantities, for the credits and schedule.
placed = number of references; quantity = Σ parseFloat(quantity attribute), 1 when not above 0
Library item placed as a block libplace.js64-bit- CadCraft
-
Pattern in drawing units
The dash and gap lengths of a linetype for this drawing.
metric drawing: inch pattern × 25.4
Linetype dashes linetypes.js64-bit- CadCraft
-
Dashes along lines and arcs
The pieces of each line or arc that are drawn.
piece from fraction s ÷ length to (s + step) ÷ length; arc length = r × sweep
Linetype dashes linetypes.js64-bit- CadCraft
-
Warp plan for a picture or tile
How finely a map image is cut into patches so that it lands in the right place on screen.
tolerance = 0.25 ÷ zoom project units, rounded to a half power of 2
Map layers under the drawing maplayers.js32-bit, display only- CadCraft
- BimCraft
-
Drawing the patches
Each patch of a map image drawn on the canvas.
Map layers under the drawing maplayers.js32-bit, display only- CadCraft
- BimCraft
-
Local placement record
The scale, rotation and point pair that tie drawing coordinates to grid coordinates.
scale = m per drawing unit ÷ m per grid unit; from = (x, y); to = (e, n)
Drawing placed on a map grid maplayers.js64-bit- CadCraft
- BimCraft
-
Meters per drawing unit
The table that converts drawing units to the 3D model's meters.
inch 0.0254; foot 0.3048; yard 0.9144; mile 1609.344; no unit 0.001
3D solids, faces and units in a drawing model3d.jsExact- CadCraft
-
Outline of a closed 2D object
The ring of points a solid is extruded from, and its area.
circle: 48 points at radius r; arc: steps of at most 7.5°; area = ½ |Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)|
3D solids, faces and units in a drawing model3d.js64-bit- CadCraft
-
Extruded solid
A solid made by pushing a ring up or down by a height.
local ring = ring − (min x, min y); placed at (min x, min y, z₀)
3D solids, faces and units in a drawing model3d.js64-bit- CadCraft
-
Cylinder
A cylinder from a center, radius and height.
3D solids, faces and units in a drawing model3d.js64-bit- CadCraft
-
Volume of each solid
The volume listed for every closed solid.
volume = |V of the definition| × |det of the placement's 3 × 3 part|
3D solids, faces and units in a drawing model3d.js64-bit- CadCraft
-
Changing the drawing's units
Scales the 3D model so it stays the same size on the drawing when the units change.
ratio = m per new unit ÷ m per old unit; every vertex and placement offset × ratio
3D solids, faces and units in a drawing model3d.js64-bit- CadCraft
-
3D faces written to a file
The model's faces as 3D faces in drawing units for DWG and DXF.
file point = placed vertex in meters ÷ k, k = meters per drawing unit
3D solids, faces and units in a drawing model3d.js64-bit- CadCraft
-
3D faces inside blocks
Places the 3D faces a block holds once for every reference of that block.
(x′, y′) = M·(x, y); z′ = z
3D solids, faces and units in a drawing model3d.js64-bit- CadCraft
-
3D faces read from a file
A file's loose 3D faces brought into the model in meters.
corner in meters = file corner × k
3D solids, faces and units in a drawing model3d.js64-bit- CadCraft
-
Axes of an object's own coordinate system
The X, Y and Z axes of the plane an object was drawn on, from its extrusion direction.
Z = N ÷ |N|; X = (Wy × Z or Wz × Z) ÷ length; Y = Z × X
Objects on a tilted or flipped plane mapped to the plan ocs.js64-bit- CadCraft
-
Is the plane the drawing's own
Whether an extrusion direction is straight up, so that nothing needs mapping.
Objects on a tilted or flipped plane mapped to the plan ocs.js64-bit- CadCraft
-
Plane to plan matrix
The transform from an object's own (x, y) at its elevation to the plan.
M = [X.x, X.y, Y.x, Y.y, Z.x·elevation, Z.y·elevation]
Objects on a tilted or flipped plane mapped to the plan ocs.js64-bit- CadCraft
-
Mapped circle, arc or ellipse
The circle, arc or ellipse that has exactly the points of the original after the map.
t* = ½·atan2(2 u·v, |u|² − |v|²); U = u·cos t* + v·sin t*; V = −u·sin t* + v·cos t*; a = |U|, b = |V|
Objects on a tilted or flipped plane mapped to the plan ocs.js64-bit- CadCraft
-
Polyline arcs as points
A polyline's arc segments as points, for a map that does not keep shapes.
k = max(4, ⌈64 × |sweep| ÷ 2π⌉); point = c + r·(cos a, sin a)
Objects on a tilted or flipped plane mapped to the plan ocs.js64-bit- CadCraft
-
Mapping each kind of object
A drawing object in its own coordinate system put through the plane's matrix.
text: rotation = atan2(M·d); height × |M·d × M·up| ÷ |M·d|; block: scales and rotation read from the mapped axes
Objects on a tilted or flipped plane mapped to the plan ocs.js64-bit- CadCraft
-
Automatic constraints
Which ends are joined and which lines are made horizontal or vertical.
coincident when |a − b| ≤ distance; horizontal when |sin α| ≤ sin(tolerance); vertical when |cos α| ≤ sin(tolerance)
Automatic constraints and dimension conversion pcommands.js64-bit- CadCraft
-
Dimension to constraint
The constraint a plain dimension stands for, when its points sit on constrainable geometry.
tol = 1e-7 × max(1, largest |x| or |y|)
Automatic constraints and dimension conversion pcommands.js64-bit- CadCraft
-
Underlay shapes and text
The underlay's paths as plotted segments and fills, and its text.
B(t) = (1 − t)³·P₀ + 3(1 − t)²t·P₁ + 3(1 − t)t²·P₂ + t³·P₃, t = s ÷ 8; line width = max(0.05, w × √|det|); text height = h × √|det| ÷ FONT_EM
PDF underlay in a plot pdf-emit.js64-bit- CadCraft
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.