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
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
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.js64-bit- CadCraft
-
Zero-size test
Says whether a line has no length or a circle or arc no radius.
line: |p₂ − p₁| ≤ 1e-9; circle or arc: r ≤ 1e-9
Drawing audit: zero-size and duplicate objects problems-cadcraft.js64-bit- CadCraft
-
Duplicate test
A text key that two objects share only when they are the same shape on the same layer.
Drawing audit: zero-size and duplicate objects problems-cadcraft.jsExact- CadCraft
-
Writing a length
A length as text in one of the five formats.
engineering: r = round(|v| × 10^p) ÷ 10^p; feet = ⌊r ÷ 12 + 1e-12⌋; architectural: whole inches and a fraction of 1⁄2^p
Lengths as text: formats and typed lengths units.js64-bit- CadCraft
-
Whole part and fraction
Splits a value into a whole number and a reduced fraction of a power of two.
n = round(|v| × den); whole = ⌊n ÷ den⌋; numerator = n − whole × den
Lengths as text: formats and typed lengths units.js64-bit- CadCraft
-
Writing decimals
A number with up to prec decimals, trailing zeros dropped.
|v| < 0.5 × 10^−prec → 0; else v.toFixed(prec)
Lengths as text: formats and typed lengths units.js64-bit- CadCraft
-
Writing an area
An area as text: square drawing units, or square inches and square feet in the feet-and-inches formats.
sq ft = sq in ÷ 144
Lengths as text: formats and typed lengths units.js64-bit- CadCraft
-
Numbers and fractions typed
Reads 6, 6.5, 6-1/2, 6 1/2 or 1/2 as a number.
whole + numerator ÷ denominator
Lengths as text: formats and typed lengths units.js64-bit- CadCraft
-
One typed length
Reads a single length such as 12'6" or 6-1/2 into drawing units.
feet × 12 + inches, with the sign applied last
Lengths as text: formats and typed lengths units.js64-bit- CadCraft
-
Millimeters per drawing unit
The size of one drawing unit in millimeters, from the drawing's units.
inch 25.4; foot 304.8; yard 914.4; mile 1 609 344; micron 0.001
Lengths as text: formats and typed lengths units.jsExact- CadCraft
-
A length typed with a unit
Converts a number with a unit mark, such as 450mm or 6in, into drawing units.
mm, cm, m, in, ft: value × mm per typed unit ÷ mm per drawing unit; other marks: parseTo into the drawing's unit
Lengths as text: formats and typed lengths units.js64-bit- CadCraft
-
Writing an angle
An angle in degrees as the drawing's angle format writes it.
decimal: deg.toFixed(4)
Lengths as text: formats and typed lengths units.js64-bit- CadCraft
-
Length, area and perimeter of an object
The measures the panel shows for one object.
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Centroid of a closed polyline
The point a closed polyline is scaled about when its area is typed.
a = Σ (xᵢyⱼ − xⱼyᵢ); c = Σ (pᵢ + pⱼ)(xᵢyⱼ − xⱼyᵢ) ÷ 3a
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Scaling a polyline to a typed area
Resizes a closed polyline about its centroid so its area becomes the value typed.
k = √(A ÷ A₀); p′ = c + (p − c)·k
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Line: length and angle
Shows a line's length, angle and deltas, and moves its end point when length or angle is typed.
L = |p₂ − p₁|; new end = p₁ + L·(cos a, sin a)
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Circle: diameter, circumference and area
Shows a circle's diameter, circumference and area, and sets the radius when one of them is typed.
d = 2r; C = 2πr; A = πr²; r = d ÷ 2, C ÷ 2π, √(A ÷ π)
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Arc: sweep, length, chord and segment area
Shows an arc's angles, sweep, length, chord and segment area, and changes the arc when one is typed.
θ = (a₁ − a₀) mod 2π; length = rθ; chord = 2r·sin(θ ÷ 2); area = r²(θ − sin θ) ÷ 2
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Ellipse: axes and angles
Shows an ellipse's major and minor axis, ratio, axis angle and start and end angles, and changes them when typed.
major = |m|; minor = |m| × ratio; ratio = minor ÷ major
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Ellipse parameter and true angle
Converts between an ellipse's stored parameter and the angle seen from its center.
angle = atan2(ratio·sin t, cos t); t = atan2(sin a ÷ ratio, cos a)
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Do several objects share a value
Decides whether a field shows one value or 'varies' for a selection.
|a − b| ≤ 1e-9 × max(1, |a|, |b|)
Properties panel: measures and geometry edits propdefs.js64-bit- CadCraft
-
Text held by a number field
Chooses whether a field holds the formatted text (12'-6") or the plain number.
formatted text kept when |read(text) − value| ≤ 1e-9 × max(1, |value|)
Properties panel: measures and geometry edits props.js64-bit- CadCraft
-
Ray angles
The directions offered at every multiple of the angle step.
aᵢ = start + i × step × (π ÷ 180), i = 0 … round(360 ÷ step) − 1
Polar and object snap tracking tracking.js64-bit- CadCraft
-
Pointer projected onto a ray
The point of a ray nearest the pointer, and how far the pointer is from it.
t = (q − p)·u; point = p + u·t, u = (cos a, sin a)
Polar and object snap tracking tracking.js64-bit- CadCraft
-
Crossing of two tracking rays
The point where rays from two acquired points cross.
den = a × b; t = ((B − A) × b) ÷ den; point = A + a·t
Polar and object snap tracking tracking.js64-bit- CadCraft
-
User coordinates to world
A point or direction typed in the user coordinate system, in world coordinates.
x = u.x + pₓ·cos − p_y·sin; y = u.y + pₓ·sin + p_y·cos
User coordinate systems ucs.js64-bit- CadCraft
-
World coordinates to user
A world point in the user coordinate system, as shown in coordinates and prompts.
d = p − origin; x = dₓ·cos + d_y·sin; y = −dₓ·sin + d_y·cos
User coordinate systems ucs.js64-bit- CadCraft
-
Is a coordinate system the world
Normalizes a coordinate system and stores it as the world when it is the same.
world when |x| < 1e-12, |y| < 1e-12 and angle within 1e-12 of 0 or 2π
User coordinate systems ucs.js64-bit- CadCraft
-
Coordinate system from an origin and an X-axis point
The coordinate system whose X axis runs from one picked point through another.
angle = atan2(p_y − o_y, pₓ − oₓ)
User coordinate systems ucs.js64-bit- CadCraft
-
Coordinate system from a polyline segment
The coordinate system at the start of the polyline segment picked, with X along it.
angle = atan2 of (point at 0.001 of the segment − its start)
User coordinate systems ucs.js64-bit- CadCraft
-
Pointer position to drawing coordinates
The drawing point under a screen position, in the active pane.
u = (sx − w ÷ 2) ÷ zoom; v = (h ÷ 2 − sy) ÷ zoom; x = cx + cos(tw)·u − sin(tw)·v; y = cy + sin(tw)·u + cos(tw)·v
Picked points, object snaps and viewport views view.js64-bit- CadCraft
-
Object snap under the pointer
The best snap point (endpoint, midpoint, center, intersection and so on) within the aperture of the pointer.
r = px ÷ zoom; keep candidates with |c − p| ≤ r; lowest priority number wins, then the smallest distance
Picked points, object snaps and viewport views view.js64-bit- CadCraft
-
Viewport view after pan or zoom inside it
The center, scale and twist an entered sheet viewport shows on screen, returned for the caller to store in the viewport when they differ from the stored ones.
M = P⁻¹ · T; s = √(M₀² + M₁²); tw = atan2(M₁, M₀); center = M⁻¹ · (vp.x, vp.y)
Picked points, object snaps and viewport views view.js64-bit- CadCraft
-
View to matrix
The drawing-to-pixel matrix of a view for a pane of a given size.
[z·c, z·s, z·s, −z·c, w ÷ 2 − z·(c·cx + s·cy), h ÷ 2 + z·(−s·cx + c·cy)] with c = cos(tw), s = sin(tw), z = zoom
Picked points, object snaps and viewport views view.js64-bit- CadCraft
-
Matrix to view
Reads the center, zoom and turn back out of a drawing-to-pixel matrix.
zoom = √(A₀² + A₁²); tw = atan2(A₁, A₀); center = A⁻¹ · (w ÷ 2, h ÷ 2)
Picked points, object snaps and viewport views view.js64-bit- CadCraft
-
Inverse of a 2 × 3 matrix
The inverse of a drawing-to-pixel matrix.
det = m₀·m₃ − m₁·m₂; inverse = adjugate ÷ det
Picked points, object snaps and viewport views view.js64-bit- CadCraft
-
Angle brought into one turn
An angle reduced to the range −π to π.
r = atan2(sin a, cos a); |r| < 1e-12 → 0
Picked points, object snaps and viewport views view.js64-bit- CadCraft
-
Point in polygon
Whether a point lies inside the clip polygon.
count edges with (aᵧ > pᵧ) ≠ (bᵧ > pᵧ) and pₓ < (bₓ − aₓ)·(pᵧ − aᵧ) ÷ (bᵧ − aᵧ) + aₓ; odd → inside
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
Where a line crosses the clip edges
The positions along a line segment where it crosses the edges of the clip polygon.
den = d × e; t = ((p − a) × e) ÷ den; u = ((p − a) × d) ÷ den; kept when EPS < t < 1 − EPS and −EPS ≤ u ≤ 1 + EPS
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
Line cut to the clip
The pieces of a line that lie inside the clip polygon.
piece ends = a + (b − a)·t₀ and a + (b − a)·t₁; kept when the middle point is inside
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
Arc cut to the clip
The sub-arcs of an arc that lie inside the clip polygon.
A·s² + B·s + C = 0 on each clip edge; s = (−B ± √(B² − 4AC)) ÷ 2A; angle = atan2(y − cy, x − cx) − a₀
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
Fill cut to the clip
A filled ring cut to a convex clip polygon.
per clip edge: keep points with side ≥ −EPS; crossing = p + (q − p)·((a − p) × e) ÷ ((q − p) × e)
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
Is the clip polygon convex
Decides whether fills can be cut to this clip polygon.
z = (b − a) × (c − b) at every corner; all signs equal → convex
Clipping block references to a boundary xclip.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.