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
-
Angle constraint: legs and sign
Which direction along each line the angle is measured between, and whether it turns counterclockwise.
parallel when |u × v| < 1e-9 × |u| × |v|; sign = sign of atan2(u′ × v′, u′ · v′)
Constraint values and signs gcons.js64-bit- CadCraft
-
Tangent circles: inside or outside
Decides whether two circles made tangent touch from inside or from outside.
internal when |c_b − c_a| < max(r_a, r_b) − 1e-12
Constraint values and signs gcons.js64-bit- CadCraft
-
Crossing point of two lines
Where two infinite lines meet, used as the corner of an angle constraint.
den = d₁ × d₂; t = ((l₂ − l₁) × d₂) ÷ den; x = l₁ + d₁ × t
Constraint values and signs gcons.js64-bit- CadCraft
-
Foot of a perpendicular
The point of a line nearest to a given point.
t = ((p − l₁) · u) ÷ (u · u); foot = l₁ + t × u
Constraint values and signs gcons.js64-bit- CadCraft
-
Mirror gap
How far a point is from being the mirror image of another across a line.
f = foot of a on the line; gap = 2f − a − b
Constraint values and signs gcons.js64-bit- CadCraft
-
Value rounded to 6 decimals
Rounds a constraint's value to a millionth of a unit for its label and its parameter text.
Math.round(v × 1e6) ÷ 1e6
Constraint values and signs gcons.js64-bit- CadCraft
-
Constraint value as a parameter
Creates the parameter for a dimensional constraint read from a file that lacks one.
expr = formatNumber(round6(value))
Constraint values and signs gcons.js64-bit- CadCraft
-
Label value
The number shown in a dimensional constraint's label.
text = formatNumber(round6(v)), with ° for angles
Constraint values and signs gcons.js64-bit- CadCraft
-
Did solving collapse an object
Refuses a solution that shrinks a line, a polyline segment or a radius to almost nothing.
collapsed when new < 1e-6 × old and old > 1e-9
Constraint values and signs gcons.js64-bit- CadCraft
-
Which fields an edit moved
Finds the coordinates an edit changed, so the solver holds them where the edit put them.
moved when |before − after| > 1e-12 × max(1, |before|)
Constraint values and signs gcons.js64-bit- CadCraft
-
Fixed values moved on paste
Shifts the stored position of a fix constraint by the paste offset.
x′ = x + dx; y′ = y + dy
Constraint values and signs gcons.js64-bit- CadCraft
-
8-byte base-16 real
Converts the stream format's excess-64 base-16 real (units, magnification, angle) to a number.
value = sign × (m ÷ 2⁵⁶) × 16^(e − 64), m = the 7 mantissa bytes as one integer
GDSII layout read and placement gds.js64-bit- CadCraft
-
Reference transform
The matrix that places one cell reference: reflect, magnify, rotate, move, and its product with the parent's matrix.
r = angle × π ÷ 180; M = [mag·cos r, mag·sin r, −f·mag·sin r, f·mag·cos r, x, y], f = −1 when reflected
GDSII layout read and placement gds.js64-bit- CadCraft
-
Flattened coordinates, array steps and path width
Places every element of every referenced cell and array and converts its points and width to user units.
array step = (corner − origin) ÷ count; point = (M × p) × userUnit; width = w × √(M₀² + M₁²) × userUnit
GDSII layout read and placement gds.js64-bit- CadCraft
-
GEODATA fields from the drawing's location
The design point, reference point, units and north vector written to the file.
rot = degrees × π ÷ 180; north = (round₉(sin rot), round₉(cos rot))
Drawing location written to DWG and DXF geodwg.js64-bit- CadCraft
-
Location from another program's GEODATA
Turns a file's GEODATA into the drawing's coordinate system, placement point and rotation.
rot = round₉(atan2(north.x, north.y) × 180 ÷ π)
Drawing location written to DWG and DXF geodwg.js64-bit- CadCraft
-
Fingerprint of the written location
Decides whether the GEODATA in a file is still the one CadCraft wrote or another program moved the location since.
Drawing location written to DWG and DXF geodwg.js64-bit- CadCraft
-
Arc of a polyline segment
The center, radius and angles of a polyline's arc segment from its two vertices and its bulge.
θ = 4·atan(b); r = |c ÷ (2·sin(θ ÷ 2))|; h = r·cos(θ ÷ 2); center = chord midpoint ± h along the chord's normal
Line and arc primitives geom.js64-bit- CadCraft
-
Angle on an arc
Whether an angle lies on the counter-clockwise sweep of an arc.
d = (a − a0) mod 2π; on the arc when d ≤ sweep + tol or d ≥ 2π − tol
Line and arc primitives geom.js64-bit- CadCraft
-
Arc angle range
Puts an arc's two stored angles in counter-clockwise order with the end after the start.
a0, a1 reduced to [0, 2π); a1 += 2π when a1 ≤ a0 + 1e-9
Line and arc primitives geom.js64-bit- CadCraft
-
Polyline segments
The straight and arc pieces of a polyline, one per pair of vertices.
Line and arc primitives geom.js64-bit- CadCraft
-
Point at a parameter
The point a fraction t of the way along a line or arc.
line: p₁ + (p₂ − p₁)·t; arc: c + r·(cos a, sin a), a = a0 + (a1 − a0)·t
Line and arc primitives geom.js64-bit- CadCraft
-
Nearest parameter
The parameter of the point on a line or arc closest to a given point.
line: t = (q − p₁)·(p₂ − p₁) ÷ |p₂ − p₁|²; arc: t = ((atan2(q − c) − a0) mod 2π) ÷ sweep
Line and arc primitives geom.js64-bit- CadCraft
-
Length of a piece
The length of a straight segment or an arc.
line: √(Δx² + Δy²); arc: r × (a1 − a0)
Line and arc primitives geom.js64-bit- CadCraft
-
Intersections on both pieces
The points where two pieces meet, limited to the pieces themselves unless one is to be treated as unbounded.
Line and arc primitives geom.js64-bit- CadCraft
-
Bounds of a piece
The smallest box round a line or arc, used for the drawing's extents.
arc: its two ends and each of the points at 0, π ÷ 2, π, 3π ÷ 2 that is on the sweep
Line and arc primitives geom.js64-bit- CadCraft
-
Tangent points from a point
The points on a circle where a line from a given point touches it.
a = atan2(p − c); b = acos(r ÷ d); touch points = c + r·(cos(a ± b), sin(a ± b))
Line and arc primitives geom.js64-bit- CadCraft
-
Lines tangent to two circles
The outer and inner lines that touch two circles, as pairs of touch points.
k = (r₁ − s·r₂) ÷ d, s = +1 outer, −1 inner; g = acos(k); n = (cos(base ± g), sin(base ± g)); points = c₁ + r₁·n and c₂ + s·r₂·n
Line and arc primitives geom.js64-bit- CadCraft
-
Object snap points
The end, middle, center, quadrant, perpendicular, tangent and nearest points of an object that a new point can be placed on.
middle of a line = (p₁ + p₂) ÷ 2; arc points = c + r·(cos a, sin a)
Line and arc primitives geom.js64-bit- CadCraft
-
Composing two transforms
The single transform that applies n first and then m.
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Mirror across a line
The transform that reflects across the line through two points.
a = atan2(q − p); M = [cos 2a, sin 2a, sin 2a, −cos 2a] about p
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Scale and rotation of a transform
The uniform scale factor, rotation and handedness of a matrix, or nothing when it shears or stretches.
sx = √(a² + b²); sy = √(c² + d²); rotation = atan2(b, a); mirrored when a·d − b·c < 0
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Inverse transform
The transform that undoes a given one.
det = a·d − b·c; inverse = [d, −b, −c, a, c·f − d·e, b·e − a·f] ÷ det
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Block reference matrix
The transform from a block's own coordinates to where a reference places it.
M = T(x, y) · R(rotation) · S(sx, sy) · T(−base)
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Viewport matrix
The transform from model coordinates to paper coordinates for a layout viewport, at its scale and twist.
no twist: [s, 0, 0, s, x − cx·s, y − cy·s]; twisted: c = s·cos tw, n = s·sin tw, [c, n, −n, c, x − (c·cx − n·cy), y − (n·cx + c·cy)]
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
Viewport view center
Converts a viewport's view center between the file's display coordinates and the model point shown at the viewport's center.
x = tx + cos tw·dx + sin tw·dy; y = ty − sin tw·dx + cos tw·dy
Move, rotate, scale and mirror geom.js64-bit- CadCraft
-
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
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.