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
-
Solve for a parameter
The value of the named parameter for which the expression equals the target.
secant: c = b − f(b) × (b − a) ÷ (f(b) − f(a)); accept when |f| ≤ 1e-9 × max(1, |target|, |x₀|)
Solving an expression for one parameter expr.js64-bit- CadCraft
- BimCraft
- PartCraft
-
Rounding of the answer
Replaces the answer by its 13-digit rounding when the two are practically equal.
r = x to 13 significant digits; use r when |r − x| ≤ 1e-12 × max(1, |x|)
Solving an expression for one parameter expr.js64-bit- CadCraft
- BimCraft
- PartCraft
-
View frames
The right, up and toward-the-viewer directions of the seven standard views.
iso: u = (1, 1, 0) ÷ √2; v = (−1, 1, 2) ÷ √6; w = (1, −1, 1) ÷ √3
Flat views of 3D solids flatview.js64-bit- CadCraft
-
Edges and triangles in the view's frame
Every vertex of the model as (right, up, depth) in the view, and which soft edges are outlines from this side.
q = (p · u, p · v, p · w); soft edge kept when its two faces face opposite ways
Flat views of 3D solids flatview.js64-bit- CadCraft
-
Working tolerance
The tolerance every later step uses, from the size of the projected model.
diag = √(Δu² + Δv²); tol = diag × 1e-6
Flat views of 3D solids flatview.js64-bit- CadCraft
-
Is a point hidden
Says whether a point of an edge lies behind some triangle of the model.
l₁, l₂ from signed areas ÷ triangle area; l₃ = 1 − l₁ − l₂; hidden when all ≥ 1e-9 and l₁ z_a + l₂ z_b + l₃ z_c > depth + tol
Flat views of 3D solids flatview.js64-bit- CadCraft
-
Visible and hidden runs of an edge
Splits an edge into stretches that are visible and stretches that are hidden.
n = clamp(⌈L ÷ (diag ÷ 300)⌉, 1, 400) samples; each change bisected until (hi − lo) × L ≤ tol
Flat views of 3D solids flatview.js64-bit- CadCraft
-
Merging pieces on one line
Groups segments that lie on the same line and joins their overlapping spans.
key = round(atan2(dy, dx) × 1e6) and round(offset ÷ (20 × tol)); spans joined when the gap ≤ tol
Flat views of 3D solids flatview.js64-bit- CadCraft
-
Merged lines back to segments
Writes each merged span as a segment, and removes from hidden lines what a visible line covers.
point = offset × (−dy, dx) + t × (dx, dy)
Flat views of 3D solids flatview.js64-bit- CadCraft
-
Scale from text
Reads a scale typed as 1:50, 2:1, 1/20 or 0.5.
a:b → a ÷ b; accepted when 0 < scale < 1e6
Flat views of 3D solids flatview.js64-bit- CadCraft
-
Paper units per meter and automatic scale
How many drawing or paper units one meter of the model is, and the largest standard scale that fits the sheet.
inch sheet: 1 ÷ 0.0254; mm sheet: 1000; model: 1 ÷ meters per unit; fit: size × units per meter × scale ≤ 0.45 × paper size
Flat views of 3D solids flatview.js64-bit- CadCraft
-
View lines in drawing units
The 2D lines of the view, centered on the block's base point and scaled.
x = (u − u_center) × f; y = (v − v_center) × f; f = units per meter × scale
Flat views of 3D solids flatview.js64-bit- CadCraft
-
What a dimensional constraint measures
The current horizontal, vertical or direct distance, radius, diameter or angle of the constrained geometry.
hdist = s × (x₁ − x₀); dist = |p₁ − p₀| or s × signed distance from the line; diameter = 2r; angle = s × atan2(u × v, u · v) × 180 ÷ π; arc angle = (a₁ − a₀) mod 2π in degrees
Constraint values and signs gcons.js64-bit- CadCraft
-
Signed distance from a line
How far a point or a circle's center lies from an infinite line, positive on the left of its direction.
d = (u_x × (p_y − l_y) − u_y × (p_x − l_x)) ÷ |u|
Constraint values and signs gcons.js64-bit- CadCraft
-
Angle constraint: legs and sign
Which direction along each line the angle is measured between, and whether it turns counterclockwise.
parallel when |u × v| < 1e-9 × |u| × |v|; sign = sign of atan2(u′ × v′, u′ · v′)
Constraint values and signs gcons.js64-bit- CadCraft
-
Tangent circles: inside or outside
Decides whether two circles made tangent touch from inside or from outside.
internal when |c_b − c_a| < max(r_a, r_b) − 1e-12
Constraint values and signs gcons.js64-bit- CadCraft
-
Crossing point of two lines
Where two infinite lines meet, used as the corner of an angle constraint.
den = d₁ × d₂; t = ((l₂ − l₁) × d₂) ÷ den; x = l₁ + d₁ × t
Constraint values and signs gcons.js64-bit- CadCraft
-
Foot of a perpendicular
The point of a line nearest to a given point.
t = ((p − l₁) · u) ÷ (u · u); foot = l₁ + t × u
Constraint values and signs gcons.js64-bit- CadCraft
-
Mirror gap
How far a point is from being the mirror image of another across a line.
f = foot of a on the line; gap = 2f − a − b
Constraint values and signs gcons.js64-bit- CadCraft
-
Value rounded to 6 decimals
Rounds a constraint's value to a millionth of a unit for its label and its parameter text.
Math.round(v × 1e6) ÷ 1e6
Constraint values and signs gcons.js64-bit- CadCraft
-
Constraint value as a parameter
Creates the parameter for a dimensional constraint read from a file that lacks one.
expr = formatNumber(round6(value))
Constraint values and signs gcons.js64-bit- CadCraft
-
Label value
The number shown in a dimensional constraint's label.
text = formatNumber(round6(v)), with ° for angles
Constraint values and signs gcons.js64-bit- CadCraft
-
Did solving collapse an object
Refuses a solution that shrinks a line, a polyline segment or a radius to almost nothing.
collapsed when new < 1e-6 × old and old > 1e-9
Constraint values and signs gcons.js64-bit- CadCraft
-
Which fields an edit moved
Finds the coordinates an edit changed, so the solver holds them where the edit put them.
moved when |before − after| > 1e-12 × max(1, |before|)
Constraint values and signs gcons.js64-bit- CadCraft
-
Fixed values moved on paste
Shifts the stored position of a fix constraint by the paste offset.
x′ = x + dx; y′ = y + dy
Constraint values and signs gcons.js64-bit- CadCraft
-
8-byte base-16 real
Converts the stream format's excess-64 base-16 real (units, magnification, angle) to a number.
value = sign × (m ÷ 2⁵⁶) × 16^(e − 64), m = the 7 mantissa bytes as one integer
GDSII layout read and placement gds.js64-bit- CadCraft
-
Reference transform
The matrix that places one cell reference: reflect, magnify, rotate, move, and its product with the parent's matrix.
r = angle × π ÷ 180; M = [mag·cos r, mag·sin r, −f·mag·sin r, f·mag·cos r, x, y], f = −1 when reflected
GDSII layout read and placement gds.js64-bit- CadCraft
-
Flattened coordinates, array steps and path width
Places every element of every referenced cell and array and converts its points and width to user units.
array step = (corner − origin) ÷ count; point = (M × p) × userUnit; width = w × √(M₀² + M₁²) × userUnit
GDSII layout read and placement gds.js64-bit- CadCraft
-
GEODATA fields from the drawing's location
The design point, reference point, units and north vector written to the file.
rot = degrees × π ÷ 180; north = (round₉(sin rot), round₉(cos rot))
Drawing location written to DWG and DXF geodwg.js64-bit- CadCraft
-
Location from another program's GEODATA
Turns a file's GEODATA into the drawing's coordinate system, placement point and rotation.
rot = round₉(atan2(north.x, north.y) × 180 ÷ π)
Drawing location written to DWG and DXF geodwg.js64-bit- CadCraft
-
Fingerprint of the written location
Decides whether the GEODATA in a file is still the one CadCraft wrote or another program moved the location since.
Drawing location written to DWG and DXF geodwg.js64-bit- CadCraft
-
Arc of a polyline segment
The center, radius and angles of a polyline's arc segment from its two vertices and its bulge.
θ = 4·atan(b); r = |c ÷ (2·sin(θ ÷ 2))|; h = r·cos(θ ÷ 2); center = chord midpoint ± h along the chord's normal
Line and arc primitives geom.js64-bit- CadCraft
-
Angle on an arc
Whether an angle lies on the counter-clockwise sweep of an arc.
d = (a − a0) mod 2π; on the arc when d ≤ sweep + tol or d ≥ 2π − tol
Line and arc primitives geom.js64-bit- CadCraft
-
Arc angle range
Puts an arc's two stored angles in counter-clockwise order with the end after the start.
a0, a1 reduced to [0, 2π); a1 += 2π when a1 ≤ a0 + 1e-9
Line and arc primitives geom.js64-bit- CadCraft
-
Polyline segments
The straight and arc pieces of a polyline, one per pair of vertices.
Line and arc primitives geom.js64-bit- CadCraft
-
Point at a parameter
The point a fraction t of the way along a line or arc.
line: p₁ + (p₂ − p₁)·t; arc: c + r·(cos a, sin a), a = a0 + (a1 − a0)·t
Line and arc primitives geom.js64-bit- CadCraft
-
Nearest parameter
The parameter of the point on a line or arc closest to a given point.
line: t = (q − p₁)·(p₂ − p₁) ÷ |p₂ − p₁|²; arc: t = ((atan2(q − c) − a0) mod 2π) ÷ sweep
Line and arc primitives geom.js64-bit- CadCraft
-
Length of a piece
The length of a straight segment or an arc.
line: √(Δx² + Δy²); arc: r × (a1 − a0)
Line and arc primitives geom.js64-bit- CadCraft
-
Intersections on both pieces
The points where two pieces meet, limited to the pieces themselves unless one is to be treated as unbounded.
Line and arc primitives geom.js64-bit- CadCraft
-
Bounds of a piece
The smallest box round a line or arc, used for the drawing's extents.
arc: its two ends and each of the points at 0, π ÷ 2, π, 3π ÷ 2 that is on the sweep
Line and arc primitives geom.js64-bit- CadCraft
-
Tangent points from a point
The points on a circle where a line from a given point touches it.
a = atan2(p − c); b = acos(r ÷ d); touch points = c + r·(cos(a ± b), sin(a ± b))
Line and arc primitives geom.js64-bit- CadCraft
-
Lines tangent to two circles
The outer and inner lines that touch two circles, as pairs of touch points.
k = (r₁ − s·r₂) ÷ d, s = +1 outer, −1 inner; g = acos(k); n = (cos(base ± g), sin(base ± g)); points = c₁ + r₁·n and c₂ + s·r₂·n
Line and arc primitives geom.js64-bit- CadCraft
-
Object snap points
The end, middle, center, quadrant, perpendicular, tangent and nearest points of an object that a new point can be placed on.
middle of a line = (p₁ + p₂) ÷ 2; arc points = c + r·(cos a, sin a)
Line and arc primitives geom.js64-bit- CadCraft
-
Composing two transforms
The single transform that applies n first and then m.
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Mirror across a line
The transform that reflects across the line through two points.
a = atan2(q − p); M = [cos 2a, sin 2a, sin 2a, −cos 2a] about p
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Scale and rotation of a transform
The uniform scale factor, rotation and handedness of a matrix, or nothing when it shears or stretches.
sx = √(a² + b²); sy = √(c² + d²); rotation = atan2(b, a); mirrored when a·d − b·c < 0
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Inverse transform
The transform that undoes a given one.
det = a·d − b·c; inverse = [d, −b, −c, a, c·f − d·e, b·e − a·f] ÷ det
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Block reference matrix
The transform from a block's own coordinates to where a reference places it.
M = T(x, y) · R(rotation) · S(sx, sy) · T(−base)
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Viewport matrix
The transform from model coordinates to paper coordinates for a layout viewport, at its scale and twist.
no twist: [s, 0, 0, s, x − cx·s, y − cy·s]; twisted: c = s·cos tw, n = s·sin tw, [c, n, −n, c, x − (c·cx − n·cy), y − (n·cx + c·cy)]
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Viewport view center
Converts a viewport's view center between the file's display coordinates and the model point shown at the viewport's center.
x = tx + cos tw·dx + sin tw·dy; y = ty − sin tw·dx + cos tw·dy
Move, rotate, scale and mirror geom.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.