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.

  • 6,917 calculations in 1,248 source files
  • 143 exact
  • 6,286 in 64-bit
  • 335 with a 32-bit step
  • Last reviewed

Calculations

  • Fillet of two picked objects

    The fillet arc and trimmed ends for two lines, a line and an arc or circle, two arcs, two segments of one polyline, or two parallel lines.

    with an arc: center = intersection of the two pieces offset by r; parallel lines: half circle of radius gap ÷ 2

    Fillet and chamfer geom.js
    • CadCraft
    64-bit
  • Chamfer distances

    How far to cut back each side of a corner, from two distances or from a length and an angle.

    angle method: θ = acos(ua·ub); da = len; db = len·sin α ÷ sin(θ + α)

    Fillet and chamfer geom.js
    • CadCraft
    64-bit
  • Chamfer of two picked pieces

    The chamfer line and trimmed ends for two straight pieces.

    Fillet and chamfer geom.js
    • CadCraft
    64-bit
  • Removing old fillet arcs

    Finds the fillet arcs a polyline already has and restores the sharp corners before a new radius is applied.

    θ = 4·atan(b); fillet when direction in = chord − θ ÷ 2 and direction out = chord + θ ÷ 2

    Fillet and chamfer geom.js
    • CadCraft
    64-bit
  • Every corner of a polyline

    Fillets or chamfers each corner of a polyline where two straight segments meet.

    sweep = π − acos(ua·ub); bulge = tan(sweep ÷ 4) × turn

    Fillet and chamfer geom.js
    • CadCraft
    64-bit
  • Polygon area and perimeter

    The signed area and the perimeter of a closed run of points.

    area = ½ Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ); perimeter = Σ |pᵢ₊₁ − pᵢ|

    Area, perimeter and length geom.js
    • CadCraft
    64-bit
  • Polyline area and length

    The area enclosed by a polyline with arc segments, and its length.

    area = ½ |Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ) + Σ ± r²(θ − sin θ)|; θ = 4·atan|b|; r = c ÷ (2·sin(θ ÷ 2)); arc length = r·θ

    Area, perimeter and length geom.js
    • CadCraft
    64-bit
  • Circle area and circumference

    The area and circumference of a circle.

    area = π·r²; circumference = 2π·r

    Area, perimeter and length geom.js
    • CadCraft
    64-bit
  • Hatch area and perimeter

    The filled area of a hatch with holes, and the total length of its boundaries.

    area = |Σ ± |ring area||, − for a ring inside an odd number of other rings; perimeter = Σ ring perimeters

    Area, perimeter and length geom.js
    • CadCraft
    64-bit
  • Length of a line, arc, polyline or spline

    The length used by the length and lengthen commands.

    line: √(Δx² + Δy²); arc: r × ((a1 − a0) mod 2π); polyline: Σ segment lengths

    Area, perimeter and length geom.js
    • CadCraft
    64-bit
  • Points along an ellipse

    The points that stand in for an ellipse or elliptical arc.

    n = max(8, ⌈steps × sweep ÷ 2π⌉); t = t0 + (t1 − t0)·i ÷ n; p = c + R(rot)·(a·cos t, a·ratio·sin t)

    Ellipses and curves as short segments geom.js
    • CadCraft
    64-bit
  • Ellipse area and perimeter

    The area and perimeter of an ellipse, or the area and length of an elliptical arc.

    full: area = π·a·b; perimeter ≈ π(a + b)(1 + 3h ÷ (10 + √(4 − 3h))), h = ((a − b) ÷ (a + b))²; arc: 720 chords per turn

    Ellipses and curves as short segments geom.js
    • CadCraft
    64-bit
  • A piece through a transform

    A line or arc piece of a block put through the block reference's transform.

    uniform: center M·c, radius r·s, start angle = atan2(M·start − M·c); otherwise n = max(8, ⌈48 × sweep ÷ 2π⌉) chords

    Ellipses and curves as short segments geom.js
    • CadCraft
    64-bit
  • Outline of an object as points

    The outline a revision cloud follows, with arcs and curves in short pieces.

    Ellipses and curves as short segments geom.js
    • CadCraft
    64-bit
  • Even spacing along a path

    Points spaced evenly along a run of points, about a given step apart.

    n = max(1 or 3, round(L ÷ step)); target k = L·k ÷ n; point = linear interpolation on the segment that holds the target

    Ellipses and curves as short segments geom.js
    • CadCraft
    64-bit
  • Revision cloud

    A polyline of equal arcs along a path, bulging outward.

    bulge = ± tan(2π ÷ 3 ÷ 4) = ± tan 30°; outward side from the sign of Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)

    Ellipses and curves as short segments geom.js
    • CadCraft
    64-bit
  • Exploding a spline

    Replaces a spline with a polyline along the curve.

    Ellipses and curves as short segments geom.js
    • CadCraft
    64-bit
  • Joining objects

    One line, arc, circle or polyline made from pieces that lie on one line, on one circle, or meet end to end.

    T = 1e-9 × max(width, height, 1); pieces join when they agree within 1000 × T

    Join and stretch geom.js
    • CadCraft
    64-bit
  • Bulge that keeps an arc's height

    The new bulge of an arc whose chord changes length, so that its height stays the same.

    b′ = b·c₀ ÷ c₁

    Join and stretch geom.js
    • CadCraft
    64-bit
  • Stretching an object

    An object with the points inside the stretch window moved and the rest left in place.

    Join and stretch geom.js
    • CadCraft
    64-bit
  • Normal of a grid line

    The unit direction a positive distance moves the grid line in: to the left of its start-to-end direction.

    n = (−Δy, Δx) ÷ L

    Moving a grid line with what hangs on it gridmove.js
    • CadCraft
    64-bit
  • What moves, and by how much

    The new geometry of every object the grid line carries with it.

    tol = max(0.0005 × L, 1e-6); reach = 0.15 × L; move = n × distance

    Moving a grid line with what hangs on it gridmove.js
    • CadCraft
    64-bit
  • Solver tolerance

    The size below which an equation counts as met.

    tol = 1e-9 × max(1, width, height, |min x|, |max x|, |min y|, |max y|)

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Constraint equations

    The residual of each constraint: how far the current geometry is from meeting it.

    coincident: P₀ − P₁; distance: |P₁ − P₀| − d; parallel: (u × v) ÷ (|u|·|v|); tangent: distance(center, line) − r; angle: atan2(u × v, u·v) − θ·π ÷ 180

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Circle of a polyline arc segment

    The center and radius of a polyline's arc segment as the solver sees it.

    θ = 4·atan(b); r = |c ÷ (2·sin(θ ÷ 2))|; h = ± r·cos(θ ÷ 2); center = chord midpoint + normal × h

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Derivatives

    How each equation changes with each coordinate it depends on.

    ∂f/∂x ≈ (f(x + h) − f(x − h)) ÷ 2h, h = 1e-6 × max(1, |x|)

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Cholesky solve

    Solves the damped normal equations for one step.

    A = L·Lᵀ; L·y = b; Lᵀ·z = y

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Newton iteration

    Repeats damped least-norm steps until every equation is met.

    (J·Jᵀ + μ·max(scale, 1e-12)·I)·y = −r; dx = Jᵀ·y; x ← x + α·dx, α = 1, ½, ¼ …

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Writing the solution back

    The changed objects after a solve, and the remaining residual.

    residual = √(Σ rᵢ²)

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Radius sign and arc angles

    Puts solved values back into an object in its stored form.

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Degrees of freedom and redundant constraints

    How many independent constraints there are, which ones add nothing, which conflict and which objects are fully fixed.

    v = row ÷ |row|; v ← v − (v·b)·b for each kept row b, twice; redundant when |v| < 1e-7; degrees of freedom = variables − rank

    2D constraint solver gsolve.js
    • CadCraft
    64-bit
  • Arcs as straight pieces

    The points that stand in for an arc or circle in a hatch boundary.

    n = max(4, ⌈|sweep| ÷ (2π ÷ 128)⌉); point = c + r·(cos a, sin a)

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • A closed object as a boundary

    The boundary loop of a circle, a closed polyline or a full ellipse picked as an object.

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • Boundary tolerance

    The distance within which boundary pieces count as touching.

    tol = 1e-9 × max(width, height, 1)

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • Where two boundary pieces cross

    The parameters at which two segments cross or touch, so each can be split there.

    u = ((c − a) × q) ÷ (r × q); v = ((c − a) × r) ÷ (r × q)

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • Merging boundary corners

    The corner points of the boundary, with points that nearly coincide made one.

    snap = 1000 × tol; split point = start + (end − start)·t

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • Faces and their areas

    Every closed region the boundary pieces make, with the signed area used to choose among them.

    area = ½ Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • Point inside a face

    Whether the picked point, or an island, lies inside a face.

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • Pattern scale and angle

    The pattern's line families at the hatch's scale, angle and origin.

    k = scale ÷ (1 metric, 25.4 inch); origin = R(angle)·(x, y)·k; spacing and dashes × k

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • Pattern lines clipped to the boundary

    The dashes of every pattern line that fall inside the hatch.

    line k origin = O + k·(dx·u + dy·n); crossing: t = d₁ ÷ (d₁ − d₂) along an edge

    Hatch boundaries and pattern lines hatch.js
    • CadCraft
    64-bit
  • Chaining pieces into paths

    Joins line and arc pieces that follow one another into open or closed paths.

    arc → bulge = tan((a1 − a0) ÷ 4); full circle → two half arcs with bulge 1

    Drawing to laser paths laser-cad.js
    • CadCraft
    64-bit
  • A path through a block transform

    A path placed by its block reference, keeping arcs where the transform allows.

    Drawing to laser paths laser-cad.js
    • CadCraft
    64-bit
  • Drawing units to millimeters

    The one scale factor that puts the drawing into millimeters.

    k = millimeters per drawing unit, or 1 when the drawing has no units

    Drawing to laser paths laser-cad.js
    • CadCraft
    64-bit
  • Picture placement

    Where a picture lies on the laser bed and how large it is.

    w = u_x × picture width; h = v_y × picture height, u and v the picture's axes through the transform

    Drawing to laser paths laser-cad.js
    • CadCraft
    64-bit
  • Landing and text start

    Where the landing ends and where the text starts.

    end = last + dir·(landing length, 0); text = end + dir·(gap, 0)

    Multileader geometry leader.js
    • CadCraft
    64-bit
  • Leader line, arrowhead and text

    The polyline, the solid arrowhead and the text a multileader is drawn and exploded as.

    u = (tip − next) ÷ |tip − next|; base = tip − u·a; corners = base ± (−u_y, u_x)·a ÷ 6; text top = landing y + h ÷ 2

    Multileader geometry leader.js
    • CadCraft
    64-bit
  • 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.js
    • CadCraft
    • ModelCraft
    • MarkupCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    64-bit
  • Adding and subtracting

    Sums and differences of lengths, left to right.

    Arithmetic on typed lengths lencalc.js
    • CadCraft
    • ModelCraft
    • MarkupCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    64-bit
  • Multiplying and dividing

    Products and quotients of a length and plain numbers, left to right.

    Arithmetic on typed lengths lencalc.js
    • CadCraft
    • ModelCraft
    • MarkupCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    64-bit
  • The answer

    The final value and whether it is a length or a plain number.

    Arithmetic on typed lengths lencalc.js
    • CadCraft
    • ModelCraft
    • MarkupCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    64-bit

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.