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
-
Transforming an object
A copy of a drawing object put through a move, rotation, scale or mirror.
point: M·p; arc: angles = atan2(M·end − M·center); radius, text height, block scale × s
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Cut parameters
Where along an object each cutting edge crosses it.
t = segment index + parameter of the intersection; t = round(t × 10⁹) ÷ 10⁹
Trim geom.js64-bit- CadCraft
-
Piece between two parameters
The part of a line, arc, open polyline or construction line between two parameters, as a new object.
line: p₁ + (p₂ − p₁)·t; arc: a0 + sweep·t; polyline arc piece: bulge = tan(atan(b)·(t_b − t_a))
Trim geom.js64-bit- CadCraft
-
Trim at a pick
The pieces that stay when the part of an object round the picked point is cut away.
circle: remaining arc from angle t_hi × 2π to t_lo × 2π
Trim geom.js64-bit- CadCraft
-
Splitting into pieces
An object divided at all its cutting edges into pieces that can be removed one by one.
Trim geom.js64-bit- CadCraft
-
Offset of a line, circle or arc
A copy of the object a set distance to one side.
line: p ± d·n, n = (−Δy, Δx) ÷ L; circle, arc: r ± d
Offset, extend, break and lengthen geom.js64-bit- CadCraft
-
Offset of a polyline
A polyline offset to one side, with its corners rebuilt.
Offset, extend, break and lengthen geom.js64-bit- CadCraft
-
Extend to a boundary
An object with the end nearest the pick moved out to the closest boundary it reaches.
Offset, extend, break and lengthen geom.js64-bit- CadCraft
-
Break between two points
An object with the part between two picked points removed, or split at one point.
Offset, extend, break and lengthen geom.js64-bit- CadCraft
-
Lengthen by an amount
An object made longer or shorter by a length, or an arc by an angle, at the end nearest the pick.
line: moved end = fixed end ± u·(L + δ); arc: new sweep = sweep + δ ÷ r; polyline arc end: bulge = ± tan(new sweep ÷ 4)
Offset, extend, break and lengthen geom.js64-bit- CadCraft
-
Fillet of two lines
The arc of a given radius tangent to two lines and the lines cut back to it.
half = acos(ua·ub) ÷ 2; t = r ÷ tan(half); center = corner + bisector × r ÷ sin(half)
Fillet and chamfer geom.js64-bit- CadCraft
-
Tangent points and center at a corner
The two tangent points and the center of a fillet at the corner of two straight pieces.
half = acos(ua·ub) ÷ 2; t = r ÷ tan(half); center = corner + bisector × r ÷ sin(half)
Fillet and chamfer geom.js64-bit- CadCraft
-
Fillet arc between two tangent points
The arc entity of the fillet, the short way round from one tangent point to the other.
Fillet and chamfer geom.js64-bit- CadCraft
-
Cutting an object back to the corner
Moves one end of a line, arc or polyline segment to the tangent or chamfer point.
arc end angle = atan2(T − center); polyline arc bulge = ± tan(sweep ÷ 4)
Fillet and chamfer geom.js64-bit- CadCraft
-
Fillet of two picked objects
The fillet arc and trimmed ends for two lines, a line and an arc or circle, two arcs, two segments of one polyline, or two parallel lines.
with an arc: center = intersection of the two pieces offset by r; parallel lines: half circle of radius gap ÷ 2
Fillet and chamfer geom.js64-bit- CadCraft
-
Chamfer distances
How far to cut back each side of a corner, from two distances or from a length and an angle.
angle method: θ = acos(ua·ub); da = len; db = len·sin α ÷ sin(θ + α)
Fillet and chamfer geom.js64-bit- CadCraft
-
Chamfer of two picked pieces
The chamfer line and trimmed ends for two straight pieces.
Fillet and chamfer geom.js64-bit- CadCraft
-
Removing old fillet arcs
Finds the fillet arcs a polyline already has and restores the sharp corners before a new radius is applied.
θ = 4·atan(b); fillet when direction in = chord − θ ÷ 2 and direction out = chord + θ ÷ 2
Fillet and chamfer geom.js64-bit- CadCraft
-
Every corner of a polyline
Fillets or chamfers each corner of a polyline where two straight segments meet.
sweep = π − acos(ua·ub); bulge = tan(sweep ÷ 4) × turn
Fillet and chamfer geom.js64-bit- CadCraft
-
Polygon area and perimeter
The signed area and the perimeter of a closed run of points.
area = ½ Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ); perimeter = Σ |pᵢ₊₁ − pᵢ|
Area, perimeter and length geom.js64-bit- CadCraft
-
Polyline area and length
The area enclosed by a polyline with arc segments, and its length.
area = ½ |Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ) + Σ ± r²(θ − sin θ)|; θ = 4·atan|b|; r = c ÷ (2·sin(θ ÷ 2)); arc length = r·θ
Area, perimeter and length geom.js64-bit- CadCraft
-
Circle area and circumference
The area and circumference of a circle.
area = π·r²; circumference = 2π·r
Area, perimeter and length geom.js64-bit- CadCraft
-
Hatch area and perimeter
The filled area of a hatch with holes, and the total length of its boundaries.
area = |Σ ± |ring area||, − for a ring inside an odd number of other rings; perimeter = Σ ring perimeters
Area, perimeter and length geom.js64-bit- CadCraft
-
Length of a line, arc, polyline or spline
The length used by the length and lengthen commands.
line: √(Δx² + Δy²); arc: r × ((a1 − a0) mod 2π); polyline: Σ segment lengths
Area, perimeter and length geom.js64-bit- CadCraft
-
Points along an ellipse
The points that stand in for an ellipse or elliptical arc.
n = max(8, ⌈steps × sweep ÷ 2π⌉); t = t0 + (t1 − t0)·i ÷ n; p = c + R(rot)·(a·cos t, a·ratio·sin t)
Ellipses and curves as short segments geom.js64-bit- CadCraft
-
Ellipse area and perimeter
The area and perimeter of an ellipse, or the area and length of an elliptical arc.
full: area = π·a·b; perimeter ≈ π(a + b)(1 + 3h ÷ (10 + √(4 − 3h))), h = ((a − b) ÷ (a + b))²; arc: 720 chords per turn
Ellipses and curves as short segments geom.js64-bit- CadCraft
-
A piece through a transform
A line or arc piece of a block put through the block reference's transform.
uniform: center M·c, radius r·s, start angle = atan2(M·start − M·c); otherwise n = max(8, ⌈48 × sweep ÷ 2π⌉) chords
Ellipses and curves as short segments geom.js64-bit- CadCraft
-
Outline of an object as points
The outline a revision cloud follows, with arcs and curves in short pieces.
Ellipses and curves as short segments geom.js64-bit- CadCraft
-
Even spacing along a path
Points spaced evenly along a run of points, about a given step apart.
n = max(1 or 3, round(L ÷ step)); target k = L·k ÷ n; point = linear interpolation on the segment that holds the target
Ellipses and curves as short segments geom.js64-bit- CadCraft
-
Revision cloud
A polyline of equal arcs along a path, bulging outward.
bulge = ± tan(2π ÷ 3 ÷ 4) = ± tan 30°; outward side from the sign of Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)
Ellipses and curves as short segments geom.js64-bit- CadCraft
-
Exploding a spline
Replaces a spline with a polyline along the curve.
Ellipses and curves as short segments geom.js64-bit- CadCraft
-
Joining objects
One line, arc, circle or polyline made from pieces that lie on one line, on one circle, or meet end to end.
T = 1e-9 × max(width, height, 1); pieces join when they agree within 1000 × T
Join and stretch geom.js64-bit- CadCraft
-
Bulge that keeps an arc's height
The new bulge of an arc whose chord changes length, so that its height stays the same.
b′ = b·c₀ ÷ c₁
Join and stretch geom.js64-bit- CadCraft
-
Stretching an object
An object with the points inside the stretch window moved and the rest left in place.
Join and stretch geom.js64-bit- CadCraft
-
Normal of a grid line
The unit direction a positive distance moves the grid line in: to the left of its start-to-end direction.
n = (−Δy, Δx) ÷ L
Moving a grid line with what hangs on it gridmove.js64-bit- CadCraft
-
What moves, and by how much
The new geometry of every object the grid line carries with it.
tol = max(0.0005 × L, 1e-6); reach = 0.15 × L; move = n × distance
Moving a grid line with what hangs on it gridmove.js64-bit- CadCraft
-
Solver tolerance
The size below which an equation counts as met.
tol = 1e-9 × max(1, width, height, |min x|, |max x|, |min y|, |max y|)
2D constraint solver gsolve.js64-bit- CadCraft
-
Constraint equations
The residual of each constraint: how far the current geometry is from meeting it.
coincident: P₀ − P₁; distance: |P₁ − P₀| − d; parallel: (u × v) ÷ (|u|·|v|); tangent: distance(center, line) − r; angle: atan2(u × v, u·v) − θ·π ÷ 180
2D constraint solver gsolve.js64-bit- CadCraft
-
Circle of a polyline arc segment
The center and radius of a polyline's arc segment as the solver sees it.
θ = 4·atan(b); r = |c ÷ (2·sin(θ ÷ 2))|; h = ± r·cos(θ ÷ 2); center = chord midpoint + normal × h
2D constraint solver gsolve.js64-bit- CadCraft
-
Derivatives
How each equation changes with each coordinate it depends on.
∂f/∂x ≈ (f(x + h) − f(x − h)) ÷ 2h, h = 1e-6 × max(1, |x|)
2D constraint solver gsolve.js64-bit- CadCraft
-
Cholesky solve
Solves the damped normal equations for one step.
A = L·Lᵀ; L·y = b; Lᵀ·z = y
2D constraint solver gsolve.js64-bit- CadCraft
-
Newton iteration
Repeats damped least-norm steps until every equation is met.
(J·Jᵀ + μ·max(scale, 1e-12)·I)·y = −r; dx = Jᵀ·y; x ← x + α·dx, α = 1, ½, ¼ …
2D constraint solver gsolve.js64-bit- CadCraft
-
Writing the solution back
The changed objects after a solve, and the remaining residual.
residual = √(Σ rᵢ²)
2D constraint solver gsolve.js64-bit- CadCraft
-
Radius sign and arc angles
Puts solved values back into an object in its stored form.
2D constraint solver gsolve.js64-bit- CadCraft
-
Degrees of freedom and redundant constraints
How many independent constraints there are, which ones add nothing, which conflict and which objects are fully fixed.
v = row ÷ |row|; v ← v − (v·b)·b for each kept row b, twice; redundant when |v| < 1e-7; degrees of freedom = variables − rank
2D constraint solver gsolve.js64-bit- CadCraft
-
Arcs as straight pieces
The points that stand in for an arc or circle in a hatch boundary.
n = max(4, ⌈|sweep| ÷ (2π ÷ 128)⌉); point = c + r·(cos a, sin a)
Hatch boundaries and pattern lines hatch.js64-bit- CadCraft
-
A closed object as a boundary
The boundary loop of a circle, a closed polyline or a full ellipse picked as an object.
Hatch boundaries and pattern lines hatch.js64-bit- CadCraft
-
Boundary tolerance
The distance within which boundary pieces count as touching.
tol = 1e-9 × max(width, height, 1)
Hatch boundaries and pattern lines hatch.js64-bit- CadCraft
-
Where two boundary pieces cross
The parameters at which two segments cross or touch, so each can be split there.
u = ((c − a) × q) ÷ (r × q); v = ((c − a) × r) ÷ (r × q)
Hatch boundaries and pattern lines hatch.js64-bit- CadCraft
-
Merging boundary corners
The corner points of the boundary, with points that nearly coincide made one.
snap = 1000 × tol; split point = start + (end − start)·t
Hatch boundaries and pattern lines hatch.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.