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

  • Joining loose ends

    Pulls each loose end onto the nearest corner of another stroke or of the drawing.

    nearest corner with distance ≤ tol; tol = 6 % of the sketch's box diagonal unless given

    Pen sketch cleanup sketch.js
    • CadCraft
    • MarkupCraft
    64-bit
  • Point on a spline

    The curve's point at a parameter.

    de Boor: dⱼ = (1 − a)·dⱼ₋₁ + a·dⱼ, a = (u − kᵢ) ÷ (kᵢ₊ₚ₋ᵣ₊₁ − kᵢ); point = (Σ w·P) ÷ Σ w

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    64-bit
  • Clamped knots

    The knot list for a spline that starts and ends on its first and last control points.

    p + 1 zeros, 1 … n − p − 1, p + 1 values of n − p

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    Exact
  • Spline through fit points

    Builds the spline that passes through the points picked.

    two points: control points at 0, ⅓, ⅔ and 1 of the segment; more: clamped cubic with chord-length parameters

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    64-bit
  • Spline from control points

    Builds a spline with a given control polygon, clamped or closed.

    closed: control points wrapped by the degree, knots 0, 1, 2, …

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    64-bit
  • A spline as points

    The curve as a list of points for drawing and for anything that works from points.

    pieces per span = max(4·max(1, p − 1), ⌈√(polygon length ÷ tol)⌉), within a budget of 4000

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    64-bit
  • A spline as a polyline

    Points for converting a spline to a polyline, a set number of segments per knot span.

    u = a + (b − a) × i ÷ n, n = 1 … 99 (10 unless given)

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    64-bit
  • Adding a control point

    The same curve with one more control point at a parameter.

    Qᵢ = (1 − a)·Pᵢ₋₁ + a·Pᵢ, a = (u − kᵢ) ÷ (kᵢ₊ₚ − kᵢ), in weighted form

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    64-bit
  • Reversing a spline

    The same curve run the other way.

    knot′ = (first + last) − knot, in reverse order

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    64-bit
  • Control-point spline to fit points

    Samples points on a spline and builds a fit-point spline through them.

    n points evenly spaced in the parameter (12 unless given, at least 3)

    Splines: curve points, fitting and editing spline.js
    • CadCraft
    64-bit
  • Parameter nearest a picked point

    Where along the curve a new control point is added.

    nearest of 401 samples evenly spaced in the parameter

    Splines: curve points, fitting and editing spline-cmd.js
    • CadCraft
    64-bit
  • Arc as a polyline segment

    Turns an arc into a two-point polyline with a bulge.

    ends = c + r(cos a, sin a); bulge = tan((a₁ − a₀) ÷ 4)

    Splines: curve points, fitting and editing spline-cmd.js
    • CadCraft
    64-bit
  • Curve-fitted polyline

    A polyline redrawn as a smooth curve through or along its vertices, kept as many short segments.

    8 segments per knot span unless given

    Splines: curve points, fitting and editing spline-cmd.js
    • CadCraft
    64-bit
  • Mass per meter of a section

    The kilograms per meter shown for a steel section.

    kg/m = published mass, else area (mm²) × 1e-6 × 7850

    Standard sections: member solids, mass and parts list stdlib.js
    • CadCraft
    64-bit
  • Member solid

    The faces of a straight member along two points, or of a column of a given height.

    outline (mm) ÷ 1000; L = |b − a| × k; point = eₓ·u + e_y·(v + lift) + e_z·s

    Standard sections: member solids, mass and parts list stdlib.js
    • CadCraft
    64-bit
  • Parts list quantities

    Groups placed parts and adds up how many there are of each.

    qty = Σ CC-QTY (1 when absent)

    Standard sections: member solids, mass and parts list stdlib.js
    • CadCraft
    64-bit
  • Total mass in the parts list

    The mass column of the parts list and its CSV.

    mass = round(mass each × qty × 100) ÷ 100

    Standard sections: member solids, mass and parts list stdlib.js
    • CadCraft
    64-bit
  • A level written as text

    Reads a level such as 104.37, +104,37 or EL 104.37 from a text.

    value = Number(whole digits . decimal digits) × sign

    Survey levels from text and the survey check survey.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Levels into project units

    A level point's x, y and z in project units.

    x·k, y·k, z·k

    Survey levels from text and the survey check survey.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Extent and distance from the origin

    How far the data spans and how far it lies from zero, in meters.

    span = |(maxX − minX, maxY − minY)| × m per unit; far = max |coordinate| × m per unit

    Survey levels from text and the survey check survey.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Median

    The middle value of a list of levels.

    odd count: the middle value; even: mean of the two middle values

    Survey levels from text and the survey check survey.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Level outliers

    Counts levels that are far from the rest, and levels of exactly 0 that look like missing heights.

    MAD = median(|z − median|) × 1.4826; limit = max(6 × MAD, 5 m); outlier when |z − median| > limit

    Survey levels from text and the survey check survey.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Duplicate points

    Counts points that sit on top of another point, with the same or a different level.

    cell = 1 mm; key = (round(x ÷ cell), round(y ÷ cell)); same level when |Δz| ≤ cell

    Survey levels from text and the survey check survey.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Drawing units to meters

    A coordinate or length as the text the macro passes, in meters.

    m = round₁₂(round₉(v) × mm per unit ÷ 1000)

    Sketch exchange macro and import swsketch.js
    • CadCraft
    64-bit
  • Numbers written into the macro

    A number as text in the macro.

    v.toPrecision(15)

    Sketch exchange macro and import swsketch.js
    • CadCraft
    64-bit
  • Millimeters per drawing unit

    The size of the drawing's unit in millimeters.

    inch 25.4; foot 304.8; yard 914.4; mil 0.0254; microinch 0.0000254

    Sketch exchange macro and import swsketch.js
    • CadCraft
    Exact
  • Arc ends on export

    The start and end points of an arc, which the macro needs beside its center.

    start = c + r(cos a₀, sin a₀); end = c + r(cos a₁, sin a₁)

    Sketch exchange macro and import swsketch.js
    • CadCraft
    64-bit
  • Center of a polyline arc segment

    The center of the arc between two polyline vertices with a bulge.

    θ = 4·atan(b); r = |chord ÷ (2·sin(θ ÷ 2))|; center = middle ± r·cos(θ ÷ 2) across the chord

    Sketch exchange macro and import swsketch.js
    • CadCraft
    64-bit
  • Dimension values on export

    The value given to each dimension in the macro.

    angle: degrees × π ÷ 180; length: M(value)

    Sketch exchange macro and import swsketch.js
    • CadCraft
    64-bit
  • Arcs on import

    Builds an arc from the center, start and end points of an imported sketch.

    r = |start − center|; a₀ = atan2(start − center); a₁ = atan2(end − center), each in [0, 2π)

    Sketch exchange macro and import swsketch.js
    • CadCraft
    64-bit
  • Dimension values on import

    The value each imported dimension gets, and the parameter that drives it.

    parameter = round(value × 1e9) ÷ 1e9

    Sketch exchange macro and import swsketch.js
    • CadCraft
    64-bit
  • The line or circle under a pick

    Reads the picked object as an endless line with a unit direction, or as a full circle.

    direction = (p₂ − p₁) ÷ |p₂ − p₁|

    Circles tangent to two or three objects tancircle.js
    • CadCraft
    64-bit
  • Objects offset by the radius

    A line moved to both sides by r, and a circle grown and shrunk by r.

    line: p ± n·r; circle: R + r and |R − r|

    Circles tangent to two or three objects tancircle.js
    • CadCraft
    64-bit
  • Where two offset objects cross

    The crossing points of two lines, a line and a circle, or two circles.

    line–circle: t = −B ± √(B² − C), C = |f|² − r²; circles: l = (r₁² − r₂² + d²) ÷ 2d, h = √(r₁² − l²)

    Circles tangent to two or three objects tancircle.js
    • CadCraft
    64-bit
  • Is a circle tangent to an object

    Checks a candidate circle against a line or a circle.

    line: | |distance to line| − r | ≤ tol; circle: |d − (R + r)| ≤ tol or |d − |R − r|| ≤ tol

    Circles tangent to two or three objects tancircle.js
    • CadCraft
    64-bit
  • Tangent, tangent, radius

    The circle of radius r tangent to two picked objects, nearest the picks.

    center = crossing of a offset by r and b offset by r; tol = 1e-7 × max(1, size of a, b and r)

    Circles tangent to two or three objects tancircle.js
    • CadCraft
    64-bit
  • Newton solve for three tangents

    Solves the three tangency equations for a circle's center and radius from one starting guess.

    F(x, y, r) = 0; J by forward differences with h = 1e-7 × max(1, |x|, |y|, |r|); step = −J⁻¹F by Cramer's rule

    Circles tangent to two or three objects tancircle.js
    • CadCraft
    64-bit
  • Tangent, tangent, tangent

    The circle tangent to three picked objects, nearest the picks.

    8 sign choices × 18 starting guesses round the picks; kept when tangent to all three within 10 × tol

    Circles tangent to two or three objects tancircle.js
    • CadCraft
    64-bit
  • Touch point and choice by the picks

    Where a circle touches an object, and which candidate circle touches nearest the picked points.

    line: foot of the center on the line; circle: point of o on the line of centers

    Circles tangent to two or three objects tancircle.js
    • CadCraft
    64-bit
  • Height unit factor

    The factor that turns a file's heights into the project's unit.

    factor = meters per file unit ÷ meters per project unit

    Elevation grids into survey points and a grid surface terrain.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Cell center in the file's coordinates

    The x and y of a raster cell's center.

    x = g₀ + (col + 0.5)·g₁ + (row + 0.5)·g₂; y = g₃ + (col + 0.5)·g₄ + (row + 0.5)·g₅

    Elevation grids into survey points and a grid surface terrain.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Cells inside a box

    The range of columns and rows whose centers can fall inside a picked box.

    (col, row) = G⁻¹·(x − g₀, y − g₃) − 0.5; c₀ = ⌈min − 1e-9⌉, c₁ = ⌊max + 1e-9⌋ + 1

    Elevation grids into survey points and a grid surface terrain.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • A box through a coordinate conversion

    The box round a rectangle after its outline is converted to another coordinate system.

    17 points along each side, converted, then minimum and maximum

    Elevation grids into survey points and a grid surface terrain.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Survey points from a grid

    One survey point per grid node that has a height.

    (x, y) = conversion(cell center); z = file height × unit factor

    Elevation grids into survey points and a grid surface terrain.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Grid surface

    A triangulated surface from the grid: two triangles per cell.

    cell corners a (SW), b (SE), c (NE), d (NW): triangles a–b–c and a–c–d

    Elevation grids into survey points and a grid surface terrain.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • 1-2-5 step

    Rounds a step up to 1, 2 or 5 times a power of ten.

    p = 10^⌊log₁₀ x⌋; m = x ÷ p; 1, 2, 5 or 10 × p

    Elevation grids into survey points and a grid surface terrain.js
    • CadCraft
    • BimCraft
    • CivilCraft
    64-bit
  • Band of a wide polyline segment

    The filled outline of one polyline segment that has a start and end width.

    h(t) = (w₀ + (w₁ − w₀)·t) ÷ 2; left = p + n·h; right = p − n·h; arc: k = max(2, ⌈sweep ÷ 10°⌉) steps

    Wide polylines, text masks and ellipses as drawn and plotted walk.js
    • CadCraft
    64-bit
  • Corner between two wide segments

    The wedge that fills the outside gap where one wide segment meets the next.

    cross = tₐ × t_b; s = ((P₂ − P₁) × t_b) ÷ cross; X = P₁ + s·tₐ; used when s ≥ 0 and |X − corner| ≤ 10 × max(hₐ, h_b)

    Wide polylines, text masks and ellipses as drawn and plotted walk.js
    • CadCraft
    64-bit
  • Text background mask

    The rectangle painted behind a text: its box grown by a margin and turned with the text.

    m = max(0, scale − 1) × height; corner = (x, y) + R(rot) · (x₀ − m, y₀ − m) …

    Wide polylines, text masks and ellipses as drawn and plotted walk.js
    • CadCraft
    64-bit
  • Ring direction

    Turns a ring clockwise so that overlapping rings add up when filled.

    a = Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ); a > 0 → reverse the points

    Wide polylines, text masks and ellipses as drawn and plotted walk.js
    • CadCraft
    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.