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

  • Continued and baseline dimensions

    The origins and line position of each dimension added by DIMCONTINUE or DIMBASELINE.

    baseline: loc = previous loc + dli × scale × side × (−sin rot, cos rot), dli defaults to 3.75

    Where dimensions are attached commands.js
    • CadCraft
    64-bit
  • Origin and X axis from two points

    The coordinate system with its origin at a picked point and its X axis toward a second point.

    origin = o; angle = atan2(pₓ − o) (ucs.js threePoint)

    User coordinate system set by command commands.js
    • CadCraft
    64-bit
  • Rotation about Z

    The coordinate system turned by a typed angle about its own origin.

    angle = current angle + a (a defaults to π ÷ 2)

    User coordinate system set by command commands.js
    • CadCraft
    64-bit
  • Quarter turn

    The coordinate system turned a quarter left or right, or set back to the world.

    angle = current angle ± π ÷ 2

    User coordinate system set by command commands.js
    • CadCraft
    64-bit
  • What UCS prints

    The origin and angle of the coordinate system as printed in the command history.

    angle shown = (angle mod 2π) × 180 ÷ π, at most 4 decimals

    User coordinate system set by command commands.js
    • CadCraft
    64-bit
  • Viewport from two corners

    The size and center of a new viewport, and what it shows.

    w = |Δx|; h = |Δy|; center = (a + b) ÷ 2

    Viewports on a sheet commands.js
    • CadCraft
    64-bit
  • Scale that fits a named view

    The viewport scale at which a saved view of the model fills the viewport.

    s = min(viewport w ÷ view w, viewport h ÷ view h)

    Viewports on a sheet commands.js
    • CadCraft
    64-bit
  • Measured value

    The length, radius, diameter or angle a dimension reports.

    linear = |(p₂ − p₁) · (cos r, sin r)|; aligned = |p₂ − p₁|; radius = |p₁ − c|; diameter = 2 × |p₁ − c|; angular = sweep

    Dimension measurement and geometry dims.js
    • CadCraft
    64-bit
  • Sector of an angular dimension

    The start angle, end angle and counterclockwise sweep an angular dimension measures.

    a₁ = atan2(p₁ − c); a₂ = atan2(p₂ − c); sweep = (end − start) mod 2π

    Dimension measurement and geometry dims.js
    • CadCraft
    64-bit
  • Ends of the dimension line

    Where the two extension lines meet the dimension line, square or at an obliquing angle.

    square: q = loc + u × ((p − loc) · u); oblique: q = p + d × ((loc − p) · n) ÷ (d · n)

    Dimension measurement and geometry dims.js
    • CadCraft
    64-bit
  • Angular dimension between two lines

    The vertex where two lines cross and a point on each leg bounding the sector that holds the text point.

    den = d₁ × d₂; t = ((l₂ − l₁) × d₂) ÷ den; c = l₁ + d₁ × t

    Dimension measurement and geometry dims.js
    • CadCraft
    64-bit
  • Linear and aligned dimension parts

    The extension lines, dimension line, arrowheads and text point of a linear or aligned dimension.

    extension line: from p + exo to q + exe; arrows inside when length ≥ 2 × asz; text at the middle, offset by gap

    Dimension measurement and geometry dims.js
    • CadCraft
    64-bit
  • Angular dimension parts

    The arc, extension lines, arrowheads and text point of an angular dimension.

    R = |loc − c|; arc from a₀ to a₁ at R; arrows outside when R × sweep < 2 × asz; text at c + (R + gap) at a₀ + sweep ÷ 2

    Dimension measurement and geometry dims.js
    • CadCraft
    64-bit
  • Radius and diameter dimension parts

    The center mark, leader or dimension line, arrowheads and text point of a radius or diameter dimension.

    r = |p₁ − c|; P = c + r × (cos u, sin u); Q = c − r × (cos u, sin u); center mark half-length = asz ÷ 2

    Dimension measurement and geometry dims.js
    • CadCraft
    64-bit
  • Closed arrowhead

    The three corners of the default filled arrowhead.

    base = tip − asz along the arrow; corners = base ± asz ÷ 6 across

    Dimension measurement and geometry dims.js
    • CadCraft
    64-bit
  • Text for a measurement

    The main text, alternate-unit text and tolerance text a dimension style writes for a measured value.

    m = round(v × |lfac|, rnd); alternate = round(m × altf, altrnd); limits: upper = base + tp, lower = base − tm

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Decimal number text

    Writes a value with a fixed number of decimal places and the style's zero suppression.

    d = clamp(round(dec), 0, 8); |v| < 0.5 × 10⁻ᵈ → 0; text = v to d places

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Round-off to a multiple

    Rounds a value to the nearest multiple of the style's round-off.

    r > 0: Math.round(v ÷ r) × r; else v

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Length text

    Writes a length as a decimal number or, for other unit formats, through the shared length formatter.

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Angle text

    Writes an angle in decimal degrees, degrees-minutes-seconds, grads or radians.

    degrees = radians ÷ (π ÷ 180); minutes = (degrees − ⌊degrees⌋) × 60; seconds = (minutes − ⌊minutes⌋) × 60; grads = degrees ÷ 0.9

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Millimeters in each text unit

    The size of the units a dimension can write its value in.

    mm = 1; cm = 10; m = 1000; km = 1 000 000

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    Exact
  • Measurement scale for a text unit

    Sets the scale that makes a dimension write its value in mm, cm, m or km.

    lfac = mmPerUnit ÷ mm in the unit

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Which text unit a style writes

    Recognizes a style's scale and suffix as mm, cm, m or km, as drawn, or custom.

    |lfac − mmPerUnit ÷ unit| ≤ 1e-9 × max(1, lfac); as drawn: |lfac − 1| < 1e-12

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Millimeters in one drawing unit

    The size of a drawing unit, or of a sheet's paper unit, in millimeters.

    paper in inches: 25.4; paper in mm: 1; model: mmPerDrawingUnit; unitless: 1 (assumed)

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Refit after the drawing units change

    Gives dimensions that write in mm to km a new scale when the drawing's unit changes.

    lfac′ = new mm per unit ÷ mm in the unit

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Arrowhead shapes

    The lines, circle or filled outline of each arrowhead style at a tip, direction and size.

    half-width = size ÷ 6; open 30°: tan(15°) × size; dot radius = size ÷ 4 (small: size ÷ 8), drawn with 16 sides; tick at 45°, half-length size ÷ 2

    Dimension text: units, rounding and tolerances dimstyle.js
    • CadCraft
    64-bit
  • Number rounded for comparison

    The text a number is compared by: its value on a grid of 0.0001.

    Math.round(v ÷ 0.0001) × 0.0001, written with at most 4 decimals

    Drawing compare drawing-compare.js
    • CadCraft
    64-bit
  • Center and size of an object

    The middle of an object's bounding box and the length of its diagonal, used to pair objects.

    cx = (minX + maxX) ÷ 2; cy = (minY + maxY) ÷ 2; d = √((maxX − minX)² + (maxY − minY)²)

    Drawing compare drawing-compare.js
    • CadCraft
    64-bit
  • Pairing by distance

    Pairs each leftover object with the nearest object of the other version that is close enough.

    d = |center_a − center_b|; candidate when d ≤ max(size_a, size_b) + 1e-9; nearest first

    Drawing compare drawing-compare.js
    • CadCraft
    64-bit
  • Moved or reshaped

    Says whether a changed object only moved: every x shifted by one amount and every y by another.

    |Δxᵢ − Δx₀| ≤ 1e-3 and |Δyᵢ − Δy₀| ≤ 1e-3 for every coordinate; other numbers equal on the 0.0001 grid

    Drawing compare drawing-compare.js
    • CadCraft
    64-bit
  • Lineweight in hundredths of a millimeter

    Converts a lineweight in millimeters to the whole number the file stores.

    Math.round(w × 100) for w ≥ 0; negative codes kept

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Spline: fit points or control points

    Decides whether a spline's fit points are written with it, by checking that they still give its control points.

    every |recomputed − stored| ≤ 1e-7 × max(1, max(|x| + |y|))

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Multi-line text anchor and oblique angle

    Moves baseline-anchored text to a top anchor one text height up, and writes the oblique angle as a format code.

    anchor = (x, y) + R(rot) × (0, h); code = \Q followed by degrees to 6 decimals

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Hatch boundary rings

    Writes a hatch's rings as closed polylines, or a 3 or 4 cornered solid fill as a SOLID.

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Hatch pattern lines for the file

    The pattern's line families in drawing units: angle in radians, base point and offset in world axes.

    k = scale ÷ (1 metric, 25.4 otherwise); base = R(turn) × (x, y) × k + origin; offset = (dx cos a − dy sin a, dx sin a + dy cos a)

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Dimension points and measurement

    The defining points, text point and measurement written for a dimension.

    measurement = dimMeasure; linear: defPoint = end of the dimension line on the second extension line; radial: near = c + r × (cos a, sin a), far = c − r × (cos a, sin a)

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Viewport view height

    The model height a sheet viewport shows, and its view center.

    view height = h ÷ s (s taken as 1 when not above 0)

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Sheet paper size and limits

    The paper size in millimeters, the sheet's limits and the sheet viewport's center.

    paper mm = w × 25.4 (inch sheets) or w; limits = (x₀, y₀) to (x₀ + w, y₀ + h); center = (x₀ + w ÷ 2, y₀ + h ÷ 2)

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Drawing extents

    The smallest and largest x and y of everything in model space, written to the file's header.

    min and max over the bounds of every object

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Closing point of a ring

    Drops a ring's last point when it repeats the first.

    |first − last| < 1e-12

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Construction line direction

    The unit direction written for an infinite line or ray.

    direction = (dx, dy) ÷ √(dx² + dy²)

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • User coordinate system axes

    The origin and the x and y axis vectors of a user coordinate system.

    x axis = (cos θ, sin θ); y axis = (−sin θ, cos θ)

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • Linetype pattern length

    The total length of one repeat of a linetype's dashes and gaps.

    length = Σ |elementᵢ|

    DWG save: objects to the file's model dwg-save.js
    • CadCraft
    64-bit
  • A group value by its code

    Turns one group's text into a real number, a whole number, a true or false, or text.

    codes 10–59, 110–149, 210–239, 460–469, 1010–1059: parseFloat; 60–99, 160–179, 270–289, 370–389, 400–409, 420–429, 440–459, 1060–1071: parseInt

    DXF reading into the shared drawing model dxf-model.js
    • CadCraft
    • BimCraft
    • TakeoffCraft
    • CivilCraft
    64-bit
  • Arc angles

    An arc's start and end angles in radians.

    angle = degrees × (π ÷ 180)

    DXF reading into the shared drawing model dxf-model.js
    • CadCraft
    • BimCraft
    • TakeoffCraft
    • CivilCraft
    64-bit
  • Multi-line text direction

    The direction vector of multi-line text, from the file's vector or from its rotation angle.

    x axis = group 11 when present; otherwise (cos(a), sin(a)), a = degrees × (π ÷ 180)

    DXF reading into the shared drawing model dxf-model.js
    • CadCraft
    • BimCraft
    • TakeoffCraft
    • CivilCraft
    64-bit
  • Hatch arc and ellipse edges

    The center, radius or axes, and start and end angles of the curved edges of a hatch boundary.

    angle = degrees × (π ÷ 180); missing end angle = 360 degrees

    DXF reading into the shared drawing model dxf-model.js
    • CadCraft
    • BimCraft
    • TakeoffCraft
    • CivilCraft
    64-bit
  • Pointer with the locked fields applied

    The point shown and used while fields are locked: a typed distance or angle from the base point, or a typed X or Y.

    polar: p = base + d × (cos a, sin a), a = typed degrees × π ÷ 180 or atan2 of the pointer; xy: (typed X or pointer x, typed Y or pointer y)

    Dynamic input: points from typed distance, angle, X and Y dynin.js
    • CadCraft
    64-bit
  • Field values while the pointer moves

    The distance and angle from the base point, or X and Y, that the fields show.

    d = √(Δx² + Δy²); a = atan2(Δy, Δx) × 180 ÷ π, brought into 0 to 360

    Dynamic input: points from typed distance, angle, X and Y dynin.js
    • CadCraft
    64-bit
  • Text sent on Enter

    The coordinate text the command line receives: a relative distance and angle, or an absolute X and Y.

    @d<a from the last point; otherwise #x,y with x = base_x + d × cos a, y = base_y + d × sin a

    Dynamic input: points from typed distance, angle, X and Y dynin.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.