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
-
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
-
One typed length to meters
Text such as 10'-6 1/2", 3/4", 320cm or a bare number, as meters.
m = sign × (feet × 0.3048 + (inches + num ÷ den) × 0.0254); m = sign × value × factor(suffix or model unit)
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Meters per unit
The factor that turns a bare number in the model's unit into meters.
in = 0.0254; ft = 0.3048; yd = 0.9144; mi = 1609.344; mil = 0.0254 ÷ 1000
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Arithmetic over typed lengths
A typed expression such as 12'6"+3/4" or 2*450mm as one length in meters.
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
The value box
What was typed as a length, a list of lengths, a point, an offset, a count or a plain number for angles and factors.
plain number = value in meters ÷ meters per unit (for arithmetic and bare fractions)
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Length readout
A length in meters as text in the model's unit.
ft-in: total = round(m ÷ 0.0254 × den) sixteenths (or the chosen fraction); others: toFixed with the unit's decimals
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Inches as a fraction
Inches written as a whole number and a reduced fraction.
sx = round(inches × den); whole = ⌊sx ÷ den⌋; fraction = (sx mod den) ÷ den, reduced by the greatest common divisor
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Area readout
An area in square meters as text in the model's unit.
ft²: a ÷ (0.3048 × 0.3048); in²: a ÷ (0.0254 × 0.0254); mm model: m² from 0.01 m², else mm²
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Volume readout
A volume in cubic meters as text in the model's unit.
ft³: v ÷ 0.3048³; in³: v ÷ 0.0254³; mm model: m³ from 0.01 m³, else mm³
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Two-point arc from its bulge
The radius, center and sweep of an arc through two points that stands off the chord by a given bulge.
R = (h² + (c ÷ 2)²) ÷ (2|h|); center = midpoint + side × sign(h) × (|h| − R); sweep = 4 × atan(2|h| ÷ c)
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Sweep of an arc drawn from its center
The angle from the arc's start direction to the pointer, counter-clockwise about the plane normal.
a = atan2((u × w)·n, u·w), plus 2π when a ≤ 0; snapped to k × π ÷ 12 when within 0.03 rad
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Rectangle width and height
The two sides of a rectangle from its first corner to the pointer, along the plane's two axes.
w = (q − p₀)·u; h = (q − p₀)·v
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Distance from a point to an outline segment
How far the pointer is from one side of the outline being offset, in the outline's plane.
t = clamp(((p − a)·(b − a)) ÷ |b − a|², 0, 1); distance = |p − a − t(b − a)|
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Offset distance and side
The signed distance an outline is offset by: the least distance to any side, positive into a face.
d = ± min over sides of distance(p, side); inside by an even-odd crossing count
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Point inside an outline
Whether the pointer lies inside a face's outline, which decides if an offset goes inward or outward.
count the sides whose ends straddle the point's height and cross to its right; inside when the count is odd
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Push/pull distance
The distance a face is pushed, in the open group's own scale, and the distance reported back.
kernel distance = d × k; reported d = returned distance ÷ k; k = |normal taken into the group's axes|
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Move and copy
The translation applied to the selection, in the open group's own coordinates.
local delta = M⁻¹ × delta (direction only); transform = T(local delta)
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Rows and rings of copies
The transform of each copy when a copy is repeated (3x) or divided (/3).
copy k: T(k × delta) or R(k × angle); divided: k ÷ n of the delta or angle
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Rotation angle
The angle the selection is turned by, from the reference direction to the pointer.
a = atan2((ref × v)·n, ref·v); snapped to k × π ÷ 12 when within 2.5°
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Uniform scale factor
The factor the selection is scaled by about a fixed point, from a reference point to the pointer.
f = max(0.001, ((p − base)·u) ÷ (u·u)), u = ref − base
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Stretch by a grip
The matrix that scales the selection by separate factors along the group's three axes about an anchor.
M = T(a) × diag(fx, fy, fz) × T(−a)
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Guide line offset from an edge
The perpendicular offset of a new guide line from the edge or guide it was measured from.
w = w₀ − dir × (w₀·dir), w₀ = pointer − start
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Guide direction at an angle
The direction of a guide line at a given angle from the protractor's zero direction.
d = normalize(u × cos a + (n × u) × sin a)
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Dimension line offset
Where the dimension line sits: the pointer's offset square to the measured line.
off = q − ab × (q·ab), q = pointer on the plane − first point, ab = unit direction of the measured line
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Terrain brush weights
How much each terrain point under the round brush is raised or lowered.
w = 0.5 × (1 + cos(π × d ÷ R)) for d < R; new z = z + w × Δz
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Selection bounding box
The box around the selection in world coordinates; its middle is the center for turning and scaling from the keyboard.
min and max per axis over the transformed points; center = (min + max) × 0.5
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Frame of a placed component
The three axis directions a component gets when it is laid on a face.
z = face normal toward the eye; x = red axis less its part along z (or blue × z); y = z × x
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Mesh buffers for the graphics card
The vertex positions, normals and colors of a definition's faces as the arrays the graphics card draws.
3D view drawing m3d/view3d.js32-bit, display only- CadCraft
- ModelCraft
-
Box of a placement as drawn
The world-space box of one placed definition, used to frame the view and place the lights.
3D view drawing m3d/view3d.js32-bit, display only- CadCraft
- ModelCraft
-
Overlay line clipped to the near plane
A 3D line cut at the camera's near plane and projected to screen points for the 2D overlay.
cut at depth 1.01 × near: a′ = a + (b − a) × (near′ − da) ÷ (db − da)
3D view drawing m3d/view3d.js32-bit, display only- CadCraft
- ModelCraft
-
Line fit
The best straight line through a run of center-line pixels, and how far the worst pixel lies from it.
θ = ½ × atan2(2·Sxy, Sxx − Syy); ends = feet of the first and last points on the line through the centroid
Tracing a scan into lines and arcs raster/trace.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Circle fit
The best circle through a run of center-line pixels, its sweep and the angles of an arc.
Kåsa: solve the 2 × 2 system for the center about the centroid, r = √(uc² + vc² + (Suu + Svv) ÷ n); then Gauss-Newton on d − r
Tracing a scan into lines and arcs raster/trace.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Corner detection
Where a chain of pixels turns sharply, so it can be cut there before fitting.
turn = |atan2(r − q) − atan2(q − p)| over ± w steps; corner when turn ≥ 0.6 rad and largest nearby
Tracing a scan into lines and arcs raster/trace.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Splitting a chain into lines and arcs
Fits a line, else an arc, else splits the chain at the point farthest from its chord, and joins neighbors that fit as one.
distance to chord = |(P − A) × (B − A)| ÷ |B − A|
Tracing a scan into lines and arcs raster/trace.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Joining collinear lines
Merges two lines that lie on the same straight line and nearly touch.
Tracing a scan into lines and arcs raster/trace.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Squaring level and plumb lines
Makes nearly horizontal and vertical lines exactly so, and gives lines of one wall the same coordinate.
y = (y₁ + y₂) ÷ 2; shared coordinate = Σ(coordinate × length) ÷ Σ length
Tracing a scan into lines and arcs raster/trace.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Closing corners
Moves a line end to the point where its line meets a nearby line.
s = ((B₁ − E) × v) ÷ (u × v); new end = E + s·u
Tracing a scan into lines and arcs raster/trace.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Lines and arcs in image coordinates
The traced lines and arcs with the window offset added and the arc end points worked out.
start = (cx + r·cos a₀, cy + r·sin a₀); end = (cx + r·cos a₁, cy + r·sin a₁)
Tracing a scan into lines and arcs raster/trace.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Crossing of two traced lines
The point where two traced line segments cross.
d = (a₂ − a₁) × (b₂ − b₁); t = ((b₁ − a₁) × (b₂ − b₁)) ÷ d; point = a₁ + t·(a₂ − a₁)
Tracing a scan into lines and arcs raster/snap.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Snap points of a trace
The ends, middles, arc centers, corners and crossings offered for snapping.
middle = (p₁ + p₂) ÷ 2; arc middle at angle (a₀ + a₁) ÷ 2; corner = mean of the ends within 3 px
Tracing a scan into lines and arcs raster/snap.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Black-and-white level (Otsu)
The grey level that best separates ink from paper for the whole sheet.
maximize w_B × w_F × (m_B − m_F)² over the 256 levels
Scan clean-up and JPEG decoding raster/image.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Local threshold (Sauvola)
Decides ink or paper for each pixel from the mean and spread of the pixels around it.
ink when v ≤ mean × (1 + k × (sd ÷ 128 − 1)); sd = √(Σv² ÷ n − mean²)
Scan clean-up and JPEG decoding raster/image.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Sheet skew angle
The angle by which the long lines of a scanned sheet are rotated.
score(angle) = Σ rows² + Σ columns² of the ink projected at that angle; best angle on a 0.25° then 0.02° grid
Scan clean-up and JPEG decoding raster/image.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Rotating the image
Turns a grey image by an angle about its middle.
source = c + R(angle) × (pixel − c); value = bilinear mix of the 4 nearest source pixels
Scan clean-up and JPEG decoding raster/image.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
JPEG inverse cosine transform
Turns the stored frequency coefficients of an 8 × 8 block back into pixel values.
pixel = round(Σ_u Σ_v C(x,u)·C(y,v)·coef(u,v) + 128), clamped to 0–255
Scan clean-up and JPEG decoding raster/jpeg.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
JPEG color conversion
Converts the decoded luminance and color-difference values to red, green and blue.
R = Y + 1.402·Cr; G = Y − 0.344136·Cb − 0.714136·Cr; B = Y + 1.772·Cb
Scan clean-up and JPEG decoding raster/jpeg.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
- PartCraft
-
Matrix product
Combines two transforms into one.
o[c][r] = Σₖ a[k][r] × b[c][k]
USD transforms and placement usd/geom.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Matrix inverse
The transform that undoes another.
inverse = cofactor matrix ÷ determinant
USD transforms and placement usd/geom.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Transforming a point
Applies a transform to a point.
p′ = (M × [x, y, z, 1]) ÷ w
USD transforms and placement usd/geom.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- PartCraft
-
Rotation about an axis
The matrix of a rotation by an angle in degrees about X, Y or Z.
a = deg × π ÷ 180; entries cos a, ± sin a
USD transforms and placement usd/geom.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
- DetailCraft
- 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.