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

  • Volume of each solid

    The volume listed for every closed solid.

    volume = |V of the definition| × |det of the placement's 3 × 3 part|

    3D solids, faces and units in a drawing model3d.js
    • CadCraft
    64-bit
  • Changing the drawing's units

    Scales the 3D model so it stays the same size on the drawing when the units change.

    ratio = m per new unit ÷ m per old unit; every vertex and placement offset × ratio

    3D solids, faces and units in a drawing model3d.js
    • CadCraft
    64-bit
  • 3D faces written to a file

    The model's faces as 3D faces in drawing units for DWG and DXF.

    file point = placed vertex in meters ÷ k, k = meters per drawing unit

    3D solids, faces and units in a drawing model3d.js
    • CadCraft
    64-bit
  • 3D faces inside blocks

    Places the 3D faces a block holds once for every reference of that block.

    (x′, y′) = M·(x, y); z′ = z

    3D solids, faces and units in a drawing model3d.js
    • CadCraft
    64-bit
  • 3D faces read from a file

    A file's loose 3D faces brought into the model in meters.

    corner in meters = file corner × k

    3D solids, faces and units in a drawing model3d.js
    • CadCraft
    64-bit
  • Axes of an object's own coordinate system

    The X, Y and Z axes of the plane an object was drawn on, from its extrusion direction.

    Z = N ÷ |N|; X = (Wy × Z or Wz × Z) ÷ length; Y = Z × X

    Objects on a tilted or flipped plane mapped to the plan ocs.js
    • CadCraft
    64-bit
  • Is the plane the drawing's own

    Whether an extrusion direction is straight up, so that nothing needs mapping.

    Objects on a tilted or flipped plane mapped to the plan ocs.js
    • CadCraft
    64-bit
  • Plane to plan matrix

    The transform from an object's own (x, y) at its elevation to the plan.

    M = [X.x, X.y, Y.x, Y.y, Z.x·elevation, Z.y·elevation]

    Objects on a tilted or flipped plane mapped to the plan ocs.js
    • CadCraft
    64-bit
  • Mapped circle, arc or ellipse

    The circle, arc or ellipse that has exactly the points of the original after the map.

    t* = ½·atan2(2 u·v, |u|² − |v|²); U = u·cos t* + v·sin t*; V = −u·sin t* + v·cos t*; a = |U|, b = |V|

    Objects on a tilted or flipped plane mapped to the plan ocs.js
    • CadCraft
    64-bit
  • Polyline arcs as points

    A polyline's arc segments as points, for a map that does not keep shapes.

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

    Objects on a tilted or flipped plane mapped to the plan ocs.js
    • CadCraft
    64-bit
  • Mapping each kind of object

    A drawing object in its own coordinate system put through the plane's matrix.

    text: rotation = atan2(M·d); height × |M·d × M·up| ÷ |M·d|; block: scales and rotation read from the mapped axes

    Objects on a tilted or flipped plane mapped to the plan ocs.js
    • CadCraft
    64-bit
  • Automatic constraints

    Which ends are joined and which lines are made horizontal or vertical.

    coincident when |a − b| ≤ distance; horizontal when |sin α| ≤ sin(tolerance); vertical when |cos α| ≤ sin(tolerance)

    Automatic constraints and dimension conversion pcommands.js
    • CadCraft
    64-bit
  • Dimension to constraint

    The constraint a plain dimension stands for, when its points sit on constrainable geometry.

    tol = 1e-7 × max(1, largest |x| or |y|)

    Automatic constraints and dimension conversion pcommands.js
    • CadCraft
    64-bit
  • Underlay shapes and text

    The underlay's paths as plotted segments and fills, and its text.

    B(t) = (1 − t)³·P₀ + 3(1 − t)²t·P₁ + 3(1 − t)t²·P₂ + t³·P₃, t = s ÷ 8; line width = max(0.05, w × √|det|); text height = h × √|det| ÷ FONT_EM

    PDF underlay in a plot pdf-emit.js
    • CadCraft
    64-bit
  • Page box and rotation matrix

    The matrix from PDF user space to the page as displayed: origin at the lower-left corner, y up, the page's rotation applied.

    0°: [1 0 0 1 −x₀ −y₀]; 90°: [0 −1 1 0 −y₀ W + x₀]; 180°: [−1 0 0 −1 W + x₀ H + y₀]; 270°: [0 1 −1 0 H + y₀ −x₀]

    PDF page vectors and snapping to them pdf-vector.js
    • CadCraft
    • BimCraft
    64-bit
  • Matrix product

    Combines the current matrix with one the page's content applies.

    [a b c d e f] = m · k for 2 × 3 affine matrices

    PDF page vectors and snapping to them pdf-vector.js
    • CadCraft
    • BimCraft
    64-bit
  • Path points

    Each move, line and curve point of a path, taken through the current matrix into displayed-page points.

    x′ = a·x + c·y + e; y′ = b·x + d·y + f; quadratic to cubic: c₁ = p + ⅔(q − p), c₂ = x + ⅔(q − x)

    PDF page vectors and snapping to them pdf-vector.js
    • CadCraft
    • BimCraft
    32-bit in part
  • Text position, height and angle

    Where each run of text starts, how tall it is, its angle and its width, in displayed-page points.

    height = |M·(t₂, t₃)|; angle = atan2 of M·(t₀, t₁); width = |w| × |(m₀, m₁)|

    PDF page vectors and snapping to them pdf-vector.js
    • CadCraft
    • BimCraft
    64-bit
  • Flattening curves to segments

    Turns every line and curve of the page into straight segments for snapping.

    B(t) = u³p₀ + 3u²t·c₁ + 3u·t²·c₂ + t³p₃, u = 1 − t, t = 1⁄8 … 8⁄8

    PDF page vectors and snapping to them pdf-vector.js
    • CadCraft
    • BimCraft
    32-bit in part
  • Nearest point on a segment

    The point of a segment closest to the pointer.

    t = ((p − a)·(b − a)) ÷ |b − a|², held to [0, 1]; q = a + t(b − a)

    PDF page vectors and snapping to them pdf-snap.js
    • CadCraft
    • BimCraft
    32-bit in part
  • Crossing of two segments

    The point where two segments of the page cross, or nothing when they are parallel, apart, or only meet end to end.

    den = r × s; u = ((c − a) × s) ÷ den; v = ((c − a) × r) ÷ den; point = a + u·r

    PDF page vectors and snapping to them pdf-snap.js
    • CadCraft
    • BimCraft
    32-bit in part
  • Choosing the snap point

    Picks the end, crossing, middle or nearest point within the snap distance of the pointer.

    midpoint = (a + b) ÷ 2; candidate kept when |candidate − p| ≤ tol

    PDF page vectors and snapping to them pdf-snap.js
    • CadCraft
    • BimCraft
    32-bit in part
  • Drawing units per PDF point

    The scale that makes a PDF page its true size in the drawing's units.

    1 pt = 1⁄72 in; inches: 1 ÷ 72; feet: (1 ÷ 72) ÷ 12; millimeters: 25.4 ÷ 72; meters: 0.0254 ÷ 72

    PDF underlay placement and PDF import pdfmodel.js
    • CadCraft
    64-bit
  • Underlay scale and rotation for saving

    The insertion point, x and y scale and rotation of an underlay as a DWG stores them.

    sx = |(m₀, m₁)|; sy = |(m₂, m₃)| × sign(det); rotation = atan2(m₁, m₀)

    PDF underlay placement and PDF import pdfmodel.js
    • CadCraft
    64-bit
  • Underlay read from a file

    Builds the underlay block and its placing reference from a file's PDF underlay record.

    PDF underlay placement and PDF import pdfmodel.js
    • CadCraft
    64-bit
  • Scale typed when attaching

    The scale an attached page gets: its true size, or the number typed.

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    64-bit
  • Inverse of a placement

    Takes clip points picked in the drawing back into the page's own points.

    det = a·d − b·c; inverse = [d −b −c a (c·f − d·e) (b·e − a·f)] ÷ det

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    64-bit
  • Is this curve a circular arc

    Decides whether one cubic curve of the page is an arc of a circle, and if so gives its center, radius and angles.

    circle through B(0), B(½), B(1); arc when | |B(t) − c| − r | ≤ 0.002·r at t = 0.25, 0.75, 0.1, 0.9

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    32-bit in part
  • Circle through three points

    Center and radius of the circle through three points.

    d = 2(aₓ(b_y − c_y) + bₓ(c_y − a_y) + cₓ(a_y − b_y)); center from |a|², |b|², |c|² ÷ d

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    64-bit
  • Outline points of an imported shape

    The vertices of each imported path in drawing coordinates, with curves replaced by straight pieces.

    B(t) at t = 0.1 … 1.0, then (x, y) → placement matrix

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    32-bit in part
  • Stroke width kept on imported objects

    The line width stored on each imported line, arc and polyline.

    lw = round(width × scale × 100) ÷ 100

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    64-bit
  • Arcs and circles from curves

    Turns a path made only of circular curves into a circle or an arc object.

    same circle when |rᵢ − r₀| < 1e-3·r₀ and |cᵢ − c₀| < 1e-3·r₀; circle when Σ sweep = 2π within 1e-3

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    32-bit in part
  • Imported text

    Position, height and angle of each imported text.

    h = PDF height × scale ÷ FONT_EM; angle = (PDF angle + placement rotation) mod 2π

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    64-bit
  • Scale from two points and a real distance

    Rescales an imported page so that two picked points are a stated distance apart.

    f = real ÷ |p₂ − p₁|

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    64-bit
  • Scaling an object about a point

    Moves and resizes one imported object by the factor f about the insertion point.

    x′ = aₓ + (x − aₓ)·f; r′ = r·f; h′ = h·f

    PDF underlay placement and PDF import pdfunder.js
    • CadCraft
    64-bit
  • Picture corners

    The four corners of a picture in its block's coordinates.

    W = u × w; H = v × h; corners = p, p + W, p + W + H, p + H

    Pictures: size, placement and clip pictures.js
    • CadCraft
    64-bit
  • Picture placement and clip for saving

    The insertion point, pixel vectors and clip boundary a DWG image record holds.

    det = u × v; a = (d × v) ÷ det; b = (u × d) ÷ det; pixel = (a − 0.5, h − 0.5 − b)

    Pictures: size, placement and clip pictures.js
    • CadCraft
    64-bit
  • Pixel size of a picture in a PDF

    How many pixels a PNG keeps when a plot caps its resolution.

    w₂ = round(maxDpi × mm ÷ 25.4), at least 1

    Pictures: size, placement and clip pictures.js
    • CadCraft
    64-bit
  • Pixel size when attaching

    The size of one pixel in drawing units from the width typed for the picture.

    px = W ÷ pixel width

    Pictures: size, placement and clip pictures-cmd.js
    • CadCraft
    64-bit
  • Inverse of a placement

    Takes clip points picked in the drawing back into the picture block's coordinates.

    det = a·d − b·c; inverse = [d −b −c a (c·f − d·e) (b·e − a·f)] ÷ det

    Pictures: size, placement and clip pictures-cmd.js
    • CadCraft
    64-bit
  • Rescaling a pasted area by two points

    Resizes a pasted picture so two picked points are a stated distance apart.

    f = wanted ÷ |b − a|; sx′ = sx·f; sy′ = sy·f

    Pictures: size, placement and clip pictures-cmd.js
    • CadCraft
    64-bit
  • Finding the paper

    The four corners of the sheet of paper in the photo.

    corner = (pixel + 0.5) × k on a copy reduced by the whole factor k; fill = bright pixels inside ÷ outline area

    Sketch photo to drawing photosketch.js
    • CadCraft
    64-bit
  • Perspective matrix from four corners

    The 3 × 3 matrix that takes the straight sheet's corners to the corners found in the photo.

    8 equations in h₁ … h₈ with h₉ = 1, solved by Gauss–Jordan elimination

    Sketch photo to drawing photosketch.js
    • CadCraft
    64-bit
  • Applying the perspective matrix

    Where a point of the straight sheet lies in the photo.

    w = h₇x + h₈y + h₉; x′ = (h₁x + h₂y + h₃) ÷ w; y′ = (h₄x + h₅y + h₆) ÷ w

    Sketch photo to drawing photosketch.js
    • CadCraft
    64-bit
  • Sheet proportions

    The long-to-short side ratio of the straightened sheet.

    w = mean of top and bottom; h = mean of left and right; ratio = max ÷ min

    Sketch photo to drawing photosketch.js
    • CadCraft
    64-bit
  • Drawing units per pixel

    The size of one pixel of the straightened sheet in drawing units.

    units per px = long side (mm) ÷ long side (px) × scale ÷ mm per unit

    Sketch photo to drawing photosketch.js
    • CadCraft
    64-bit
  • Traced arcs and circles

    Turns each traced arc into a circle or an arc object in drawing units.

    r = r(px) × units per px; arc through start, middle and end

    Sketch photo to drawing photosketch.js
    • CadCraft
    64-bit
  • Layout sheet in millimeters

    The matrix that takes a layout and its viewports to millimeters on the sheet.

    toMm = [k 0 0 k −x₀k −y₀k], k = mm per paper unit; view matrix = toMm · viewport matrix

    Plotting: sheet scale, PDF, SVG and PNG output plot.js
    • CadCraft
    64-bit
  • Model plot scale and placement

    The scale and offset that put a window of the model on a paper size, fitted or at 1:n.

    fit: s = min((W − 10) ÷ w, (H − 10) ÷ h); offset = (W ÷ 2 − cₓs, H ÷ 2 − c_y·s)

    Plotting: sheet scale, PDF, SVG and PNG output plot.js
    • CadCraft
    64-bit
  • Millimeters to points in the page

    The factor that lets the rest of the PDF page be written in millimeters.

    72 ÷ 25.4 = 2.834645669 (9 decimals)

    Plotting: sheet scale, PDF, SVG and PNG output plot.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.