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
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
Dimension from its defining points
Rebuilds a file's dimension as an editable dimension when its points give the measurement the file states.
accept when |measured − file| ≤ 1e-6 × max(1, file); diameter center = (defPoint + chord point) ÷ 2
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Hatch boundary to polygon rings
Turns a hatch's boundary paths (polylines with bulges, lines, arcs, ellipses, splines) into rings of points.
arc: n = max(4, ⌈32 × sweep ÷ 2π⌉) chords; ellipse: n = max(8, ⌈48 × sweep ÷ 2π⌉); p = c + r × (cos a, sin a)
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Bulge arc to points
The points along a polyline arc segment given by its two ends and its bulge.
θ = 4 × atan(b); r = c ÷ (2 × sin(θ ÷ 2)); center = midpoint + normal × r × cos(θ ÷ 2); n = max(2, ⌈16 × |θ| ÷ π⌉)
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Spline edge to points
Points along a spline edge of a hatch boundary.
n = min(400, max(16, 8 × control points)); de Boor: d_j = (1 − a) × d_{j−1} + a × d_j, a = (u − k_i) ÷ (k_{i+p−r+1} − k_i); point = (x, y) ÷ w
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Picture and wipeout frame
The corners of an image's frame or clip boundary in drawing coordinates.
W(q) = p + (q_x + 0.5) × u + (h − 0.5 − q_y) × v
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Block array positions
The insertion point of each copy of a block placed as a rows-by-columns array.
(x, y) = insert + R(rot) × (k × column spacing, r × row spacing)
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Viewport scale
The scale of a sheet viewport and the model point at its center.
s = viewport height ÷ view height (1 when the view height is not above 0)
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Hatch pattern lines
The file's own pattern lines: angle in degrees, base point, and offset along and across each line.
angle° = angle × 180 ÷ π; dx = o_x cos a + o_y sin a; dy = −o_x sin a + o_y cos a
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Lineweight in millimeters
Converts a lineweight from hundredths of a millimeter to millimeters.
mm = v ÷ 100 for v ≥ 0; −2 and −3 kept as codes
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Multi-line text rotation and oblique angle
The rotation of multi-line text from its direction vector, and its oblique angle from the text's format code.
rot = atan2(xAxis_y, xAxis_x); oblique = degrees in the \Q code × π ÷ 180
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Construction line direction
The unit direction of an infinite line or ray.
n = √(d_x² + d_y²); direction = (d_x ÷ n, d_y ÷ n)
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Dimension style numbers
Reads a dimension style's variables and brings the decimal places and flags into range.
scale ≤ 0 → 1; dec, adec, tad, zin → clamp(round(value), 0, 8)
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
Which viewport is the sheet
Picks the viewport that stands for the sheet itself: at scale 1 and covering every other viewport.
|s − 1| ≤ 1e-6; covers: |o_x − v_x| + o_w ÷ 2 ≤ v_w ÷ 2 + 1e-6 × max(1, v_w, v_h)
DWG import: objects from the file's model dwg-import.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
Transparency to the file's word
Converts a transparency percentage to the opacity byte the file stores.
alpha = Math.round(255 × (1 − clamp(tr, 0, 90) ÷ 100)); word = 0x02000000 + alpha
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
Opacity byte to transparency
Converts the file's opacity byte back to a transparency percentage.
p = Math.round((1 − alpha ÷ 255) × 100); p ≤ 0 → none; capped at 90
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
Transparency from a file value
Reads a transparency word or record: by block, by layer or an opacity byte.
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
Dimension lineweight to hundredths
Converts a dimension line or extension line weight in millimeters to the file's whole number.
Math.round(v × 100) for v ≥ 0; −1, −2, −3 kept as codes
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
Style value to a dimension variable
Converts one dimension style setting to the value its variable holds in the file.
real: the number (0 when not finite); int: Math.round; bool: 1 or 0; lineweight: lw100; separator: 44 or 46
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
Dimension variable to a style value
Converts one variable read from a file to the dimension style setting.
real: parseFloat; int: Math.round(parseFloat); lineweight: x ÷ 100 for 0 ≤ x ≤ 211
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
Tolerance mode and text gap
Works out the tolerance mode (symmetric, deviation, limits, basic) and the text gap from the file's variables.
symmetric when |tp − tm| < 1e-12; gap < 0 → basic and gap = −gap
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
Dimension style as file variables
Every variable of a dimension style, by name, for a DIMSTYLE record.
basic tolerance: DIMGAP = −|gap|
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
Hatch pattern origin as text
Writes a hatch's pattern origin into the file as two numbers in a text field.
text = CCHORG: followed by x, a comma and y
Properties in DWG and DXF: transparency, lineweights, dimension variables dwg-props.js64-bit- CadCraft
-
A number from a group value
Reads one real number from the file's text, or a default when the group is absent.
value = parseFloat(text)
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Arc angles
An arc's center, radius and start and end angles.
a = (degrees × π ÷ 180) mod 2π
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Hatch boundary to polygon rings
Turns a hatch's boundary paths (polylines with bulges, lines and arcs) into rings of points.
arc edge: steps = max(4, ⌈32 × (a₁ − a₀) ÷ 2π⌉); p = c + r × (cos a, sin a)
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Bulge arc to points
The points along a bulged segment of a hatch boundary polyline.
θ = 4 × atan(b); r = |c ÷ (2 × sin(θ ÷ 2))|; center = midpoint + normal × r × cos(θ ÷ 2); steps = max(2, ⌈16 × |θ| ÷ π⌉)
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Hatch pattern scale, angle and lines
A pattern hatch's scale, angle and its own pattern lines.
pattern angle = (degrees × π ÷ 180) mod 2π; dx = o_x cos a + o_y sin a; dy = −o_x sin a + o_y cos a, a = line angle × π ÷ 180
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Block array positions
The insertion point of each copy of a block placed as a rows-by-columns array.
p = T(insert) × R(rot) × (c × column spacing, r × row spacing)
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Dimension defining points
The points a dimension measures from, by dimension type.
linear: p₁ = 13, p₂ = 14, line point = 10, angle = group 50 × π ÷ 180; diameter center = (point 15 + point 10) ÷ 2; four-point angular: vertex from the two lines
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Can the dimension be measured
Checks that a dimension's points are finite and far enough apart to measure.
|a − b| > 1e-12
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Viewport scale, center and twist
A sheet viewport's scale, the model point at its center and its view twist.
s = viewport height ÷ view height; twist = degrees × π ÷ 180 (or radians from R12 data)
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Layer lineweight
A layer's lineweight in millimeters.
mm = n ÷ 100 for 0 ≤ n ≤ 211; otherwise default
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Object lineweight and linetype scale
An object's own lineweight in millimeters and its linetype scale.
lw = n ÷ 100; linetype scale kept when |s − 1| > 1e-12
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Sheet size from the plot settings
A sheet's size in its own unit when the layout gives no limits, from the paper size in millimeters.
size = paper mm ÷ 25.4 (inch sheets) or ÷ 1; width and height swapped when the plot rotation code is odd
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Dimension style numbers
Brings a dimension style's scale, unit format and decimal places into range.
scale ≤ 0 → 1; dec, adec, tad, zin → max(0, round(value)); dec ≤ 8
DXF reading: objects from the file's text dxf.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.