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
-
Merging near-equal positions
Sorts edge positions and merges those that are within a tolerance of each other.
Automatic dimensions autodim.js64-bit- CadCraft
-
Level and plumb edges, circles and points
Collects the positions to dimension from the chosen objects and the size of the box round them.
diagonal = √(w² + h²); plumb when |Δx| ≤ tol; level when |Δy| ≤ tol
Automatic dimensions autodim.js64-bit- CadCraft
-
Is the dimension already there
A key that is equal for two dimensions of one kind with the same end points.
key = kind : round(x₁ ÷ g), round(y₁ ÷ g), round(x₂ ÷ g), round(y₂ ÷ g), g = 20 × tol
Automatic dimensions autodim.js64-bit- CadCraft
-
Chains and overall dimensions
The dimensions strung between neighboring edge positions along each chosen side, and one overall dimension outside them.
minLen = max(0.003 × diagonal, 10 × tol); chain line at box edge ∓ 6 × text height; overall line 5 × text height further out
Automatic dimensions autodim.js64-bit- CadCraft
-
Opening widths
The width of a gap between collinear lines on one layer, taken as a door or window opening.
w = next.lo − this.hi; kept when minLen ≤ w ≤ 0.35 × diagonal and w ≤ 0.8 × the longer neighbor
Automatic dimensions autodim.js64-bit- CadCraft
-
Hole diameters
One diameter dimension for each size of circle.
p₁ = center + r·(cos 45°, sin 45°); text at center + (r + 3 × text height)·(cos 45°, sin 45°)
Automatic dimensions autodim.js64-bit- CadCraft
-
Longitude and latitude to web Mercator
The web Mercator x and y in meters for a longitude and latitude in degrees.
x = R·λ·π ÷ 180; y = R·ln(tan(π ÷ 4 + φ·π ÷ 360)), R = 6378137
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Web Mercator to longitude and latitude
The longitude and latitude in degrees for a web Mercator x and y in meters.
λ = x ÷ R × 180 ÷ π; φ = (2·atan(e^(y ÷ R)) − π ÷ 2) × 180 ÷ π
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Standard tile grid
The origin and the resolution of each zoom level of the usual 256-pixel web Mercator tiles.
origin = (−πR, πR); res(z) = 2πR ÷ 256 ÷ 2^z, z = 0…22
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Tile that holds a place
The tile column and row at a zoom level for a longitude and latitude.
col = ⌊(x + πR) ÷ (res × 256)⌋; row = ⌊(πR − y) ÷ (res × 256)⌋
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Tiles covering a box
The tiles of a grid that cover a box, each with its bounds in the grid's units.
bounds = [ox + c·tw, oy − (r + 1)·th, ox + (c + 1)·tw, oy − r·th], tw = res × tile width
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Meters per unit of a coordinate system
The length in meters of one degree, foot, US survey foot or meter, for turning a WMTS scale into a resolution.
degree: 2π × 6378137 ÷ 360; foot: 0.3048; US survey foot: 1200 ÷ 3937; otherwise 1
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Tile grid of a WMTS tile matrix set
The resolution and top-left corner of each level of a WMTS tile matrix set.
res = scale denominator × 0.00028 ÷ meters per unit
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
World file to a pixel-corner transform
The transform from pixel corners to coordinates for a picture, from the six numbers of its world file.
x₀ = C − A ÷ 2 − B ÷ 2; y₀ = F − D ÷ 2 − E ÷ 2
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Pixel to coordinates
The coordinates of a pixel position in a picture's own system.
x = g₀ + u·g₁ + v·g₂; y = g₃ + u·g₄ + v·g₅
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Numbers in a map request
How the corners of the requested box are written into a WMS or map-server export address.
|v| ≥ 10,000: v.toFixed(3); otherwise v.toPrecision(12)
Map layers: web Mercator, tile grids and world files basemap.js64-bit- CadCraft
- BimCraft
- CivilCraft
-
Affine through three points
The affine transform that carries three source points onto three destination points.
det = (u₁ − u₀)(v₂ − v₀) − (u₂ − u₀)(v₁ − v₀); a = ((x₁ − x₀)(v₂ − v₀) − (x₂ − x₀)(v₁ − v₀)) ÷ det
Map pictures warped onto the plan basemap.js32-bit, display only- CadCraft
- BimCraft
- CivilCraft
-
Cells of a warped picture
The cells a picture is cut into so that each can be drawn with one affine transform.
split while max |affine(p) − exact(p)| > tol over the fourth corner, the middle and the four edge midpoints
Map pictures warped onto the plan basemap.js32-bit, display only- CadCraft
- BimCraft
- CivilCraft
-
Tile level for the screen
Which level of a tile grid is drawn at the current zoom.
the coarsest level with res ≤ 1.5 × screen resolution
Map pictures warped onto the plan basemap.js32-bit, display only- CadCraft
- BimCraft
- CivilCraft
-
Rounding of reported numbers
Rounds a number before it is handed to an assistant or a script.
num(v) = round(v × 10⁹) ÷ 10⁹; rnd6(v) = num(round(v × 10⁶) ÷ 10⁶)
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Extents, paper and viewport sizes
The drawing's extents and each sheet's paper and viewport sizes in the drawing's description.
Values given to assistants and scripts agents.js64-bit- CadCraft
-
An object's fields, length and area
One object as plain values, with its length and area where it has them.
length = Σ primLength(primitive); area = entityArea(object).area
Values given to assistants and scripts agents.js64-bit- CadCraft
-
An object's state for change checks
A flat set of an object's values that is compared later to see whether the object changed.
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Text height against the allowed list
Whether a text's height is one of the heights a standards check allows.
|h − e.h| ≤ 10⁻⁶ × max(1, h)
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Plot scale from text
The scale number for text such as 1:100, an architectural scale label, or fit.
a:b → n = b ÷ a
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Sheet a plot prints
The sheet and its size for a plot asked for by an assistant: a layout, the extents, or a window of the model.
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Size and units of the SVG plot
The SVG file's size in millimeters and the number of file units per millimeter.
file units = mm × 10; width = sheet width in mm, rounded to 9 decimals
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Coordinates in the SVG plot
How points, widths and matrix entries are transformed and written into the SVG file.
(x′, y′) = M · (x, y, 1); text = round(v × 1000) ÷ 1000; width scale = √|det M|
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Arcs in the SVG plot
An arc written as a run of straight chords.
n = max(2, ⌈|sweep| ÷ 2°⌉); pᵢ = center + r·(cos, sin)(a₀ + sweep·i ÷ n)
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Text in the SVG plot
The matrix, position and size written for a piece of text.
transform = matrix(a b c d e f), each entry rounded to 3 decimals
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Insertion point of a block placed by an assistant
The command-line input that places a block at a given point, scale and rotation.
Values given to assistants and scripts agents.js64-bit- CadCraft
-
Ortho: the point along the nearer axis
The point a click stands for when ortho is on and there is a base point.
u = c·Δx + s·Δy; v = −s·Δx + c·Δy; point = base + u·(c, s) if |u| ≥ |v|, else base + v·(−s, c)
Cursor point and status readouts cadcraft.js64-bit- CadCraft
-
Coordinates, distance and angle in the status line
The cursor's coordinates and, during a command, the distance and angle from the base point.
Δ = √(Δx² + Δy²); angle = atan2(Δy, Δx) − UCS angle, normalized to 0…360°
Cursor point and status readouts cadcraft.js64-bit- CadCraft
-
Length text in the model and on a sheet
A length written for the status line, the tracking labels and the cursor box.
Cursor point and status readouts cadcraft.js64-bit- CadCraft
-
Distance and angle beside the cursor
The live distance or angle shown in the box by the cursor while a command waits for one.
d = √(Δx² + Δy²); angle = atan2(Δy, Δx), normalized to 0…360°
Cursor point and status readouts cadcraft.js64-bit- CadCraft
-
Size of the plot area on paper
The width and height of the chosen area at the chosen scale, shown in the Plot dialog.
w = (maxX − minX) × s, shown as round(w × 10) ÷ 10
Cursor point and status readouts cadcraft.js64-bit- CadCraft
-
Number typed in Quick select
The number a property is compared with in the Quick select dialog.
Cursor point and status readouts cadcraft.js64-bit- CadCraft
-
Turn sense of an angle constraint
Whether the angle between two constrained lines is measured counter-clockwise or clockwise after a mirror or a trim.
sign = +1 if atan2(u × v, u · v) ≥ 0, else −1
Constraints kept through mirror and trim ckeep.js64-bit- CadCraft
-
Which piece holds the original's ends
The piece of a trimmed line or arc that still has the original's start, and the one that still has its end.
start piece: t₀ ≤ 10⁻⁹; end piece: t₁ ≥ 1 − 10⁻⁹
Constraints kept through mirror and trim ckeep.js64-bit- CadCraft
-
Numbers in prompts and messages
A number written for a prompt's default or a message in the command history.
|n| < 10⁻¹⁰ → 0; otherwise n.toFixed(4) without trailing zeros
Typed points, distances and angles commands.js64-bit- CadCraft
-
Typed distance, number and angle
The value a prompt takes when a distance, a number or an angle is typed.
angle = degrees × π ÷ 180 (+ UCS angle for an absolute angle)
Typed points, distances and angles commands.js64-bit- CadCraft
-
Distance or angle shown by two clicks
The distance or the angle a prompt takes when it is shown by picking two points.
d = √(Δx² + Δy²); angle = atan2(Δy, Δx)
Typed points, distances and angles commands.js64-bit- CadCraft
-
Typed point
The point for typed coordinates: absolute, relative to the last point, polar, or a distance along the cursor direction.
x,y → UCS to world; @x,y → last + R(ucs)·(x, y); d<a → from + d·(cos, sin)(a·π ÷ 180 + UCS angle); d → base + d·(cos, sin)(atan2(cursor − base))
Typed points, distances and angles commands.js64-bit- CadCraft
-
Calculation on the command line
The result CAL prints for an expression such as 12'6"+3/4" or 2*450mm.
raw = value.toPrecision(12)
Typed points, distances and angles commands.js64-bit- CadCraft
-
Circle through three points
The center and radius of the circle through three picked points.
d = 2·(aₓ(b_y − c_y) + bₓ(c_y − a_y) + cₓ(a_y − b_y)); centerₓ = (|a|²(b_y − c_y) + |b|²(c_y − a_y) + |c|²(a_y − b_y)) ÷ d; r = |a − center|
Shapes made by the draw commands commands.js64-bit- CadCraft
-
Arc through three points
The center, radius and end angles of the arc from a start point through a second point to an end point.
center, r from circle3; counter-clockwise when (m − s) × (e − s) > 0; a₀ = atan2(s − center), a₁ = atan2(e − center)
Shapes made by the draw commands commands.js64-bit- CadCraft
-
Arc segment of a polyline
The bulge of a polyline's arc segment that leaves the last point along the previous segment's direction and ends at the picked point.
φ = angle(p → q) − tangent at p, wrapped to −π…π; bulge = tan(φ ÷ 2)
Shapes made by the draw commands commands.js64-bit- CadCraft
-
Circle from the two ends of a diameter
The center and radius of a circle given by two opposite points on it.
center = (a + b) ÷ 2; r = |b − a| ÷ 2
Shapes made by the draw commands commands.js64-bit- CadCraft
-
Arc from center, start and end
The radius and end angles of an arc given its center, its start point and a point toward its end.
r = |start − center|; a₀ = atan2(start − center); a₁ = atan2(end − center)
Shapes made by the draw commands commands.js64-bit- CadCraft
-
Rectangle from two corners
The closed four-corner polyline between two picked corners.
Shapes made by the draw commands commands.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.