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
-
Block size from its label
The width and height of a diagram block.
w = longest line × th × 0.62 + 3 × th; h = (lines × 1.3 + 1.7) × th; diamond: w × 1.5, h × 1.6; minimum width 8 × th (diamond 10 × th)
Diagram layout into drawing objects diagram.js64-bit- CadCraft
-
Symbol scale in a block
The factor that fits a symbol drawing into a box of six text heights.
k = 6 × th ÷ max(w, 1.4 × h)
Diagram layout into drawing objects diagram.js64-bit- CadCraft
-
Symbol geometry scaled and moved
Scales a symbol's lines, circles, arcs, polylines, hatches and text by k and moves them to the block.
x′ = x × k + dx; y′ = y × k + dy; r′ = r × k
Diagram layout into drawing objects diagram.js64-bit- CadCraft
-
Block coordinates
The x and y of every block in a layered diagram.
x = previous edge + w ÷ 2, gap 2.5 × th; y = Σ (layer height + 4 × th); then x → mean of neighbors' x, kept in order with the gap
Diagram layout into drawing objects diagram.js64-bit- CadCraft
-
Sequence diagram positions
The x of each lifeline and the y of each message row in a sequence diagram.
gap ≥ 2.5 × th and ≥ (label length × th × 0.8 × 0.62 + 2 × th) ÷ lifelines crossed; row = 3.4 × th; top = box height + 2.6 × th
Diagram layout into drawing objects diagram.js64-bit- CadCraft
-
Layout to drawing coordinates
Places the laid-out diagram at a point in the drawing, turning y from downward to upward.
X = x + px − minX; Y = y − (py − minY)
Diagram layout into drawing objects diagram.js64-bit- CadCraft
-
Arrowhead triangle
The three corners of a connector's filled arrowhead.
u = (to − from) ÷ |to − from|; corners: to, to − u × s ± n × 0.35 × s
Diagram layout into drawing objects diagram.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
-
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
-
Construction line direction
The unit direction of an infinite line or ray.
direction = (dx, dy) ÷ √(dx² + dy²)
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Extra sheet read back from a block
Rebuilds a sheet and its viewports from the block an R12 file keeps them in.
viewport center = ((x_min + x_max) ÷ 2, (y_min + y_max) ÷ 2); w = x_max − x_min; h = y_max − y_min
DXF reading: objects from the file's text dxf.js64-bit- CadCraft
-
Number text (R12)
The text every real number is written as in an R12 file.
|n| < 1e-12 → 0.0; otherwise n rounded to 15 significant digits
DXF writing: numbers as text dxf.js64-bit- CadCraft
-
Point (R12)
Writes a 2D point as three groups.
x → f(x); y → f(y); z → 0.0
DXF writing: numbers as text dxf.js64-bit- CadCraft
-
Arc (R12)
An arc's center, radius and its angles in degrees.
degrees = (a mod 2π) × 180 ÷ π
DXF writing: numbers as text dxf.js64-bit- CadCraft
-
Dimension (R12)
The defining points, text point and angles written for a dimension.
linear: point 10 = 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); angles in degrees
DXF writing: numbers as text dxf.js64-bit- CadCraft
-
Viewport view (R12)
A sheet viewport's twist, view height and view center.
view height = h ÷ s
DXF writing: numbers as text dxf.js64-bit- CadCraft
-
Ellipses and splines as polylines (R12)
Writes an ellipse or a spline as a polyline along the curve, because R12 has neither object.
DXF writing: numbers as 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.