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
-
Segment crossing test
Whether two segments cross or touch.
cross when the orientation signs differ on both segments; touch when an orientation is 0 and the point lies in the other's box
Board geometry and clearances geom.js Every app64-bit -
Segment to segment distance
The distance between two track center lines or edges.
0 when they cross; else the least of four point-to-segment distances
Board geometry and clearances geom.js Every app64-bit -
Point in polygon
Whether a point lies inside a zone, a pad or the board outline.
even-odd rule along a ray in +x
Board geometry and clearances geom.js Every app64-bit -
Polygon area
The signed area of a closed polygon.
A = ½ Σ (xᵢ yᵢ₊₁ − xᵢ₊₁ yᵢ)
Board geometry and clearances geom.js Every app64-bit -
Polygon to polygon distance
The distance between two closed shapes.
0 when one first vertex is inside the other; else the least edge-to-edge distance
Board geometry and clearances geom.js Every app64-bit -
Gap between copper shapes
The edge-to-edge clearance between two tracks, pads or zones.
gap = max(0, center-line distance − r₁ − r₂)
Board geometry and clearances geom.js Every app64-bit -
Rotation of a point
A pad or outline point turned by an angle in degrees.
(x cos θ − y sin θ, x sin θ + y cos θ), θ = degrees × π ÷ 180
Board geometry and clearances geom.js Every app64-bit -
Pad position on the board
Where a footprint pad sits on the board, with its shape for the clearance check.
world = part position + R(part rotation) × (±x, y)
Board geometry and clearances board.js Every app64-bit -
Coordinate and aperture format
How a position and an aperture size are written in a Gerber file.
X, Y = round(mm × 10⁶); size = 6 decimals
Gerber and drill file numbers gerber.js Every app64-bit -
Pad as a flash or a region
A pad, or its grown copy for the solder mask, in the file.
axis-aligned: aperture (w + 2 × grow) by (h + 2 × grow); else a 4-corner region rotated by the pad angle
Gerber and drill file numbers gerber.js Every app64-bit -
Drill sizes and positions
The tool table and hole positions of the drill files.
tool size = 3 decimals; X, Y = 4 decimals of a millimeter
Gerber and drill file numbers gerber.js Every app64-bit -
Board size in the job file
The board's width and height stated in the job file.
size = extent of the outline, 4 decimals
Gerber and drill file numbers gerber.js Every app64-bit -
Coordinate scale when reading
The factor that turns the file's integers into coordinates.
scale = 10^(−decimals of X)
Gerber and drill file numbers gerber.js Every app64-bit -
Coordinates when reading
Each X and Y of a Gerber file as a number.
x = integer × scale
Gerber and drill file numbers gerber.js Every app64-bit -
Drill file when reading
Tool diameters and hole positions read back from a drill file.
decimal text to the nearest 64-bit number
Gerber and drill file numbers gerber.js Every app64-bit -
Real number when reading
An 8-byte GDSII real as a number.
value = sign × (mantissa ÷ 2⁵⁶) × 16^(exponent − 64)
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Real number when writing
A number as an 8-byte GDSII real.
mantissa = round(v × 2⁵⁶) after scaling v into [1/16, 1) by powers of 16
GDSII layout: reals, flattening, areas and checks gds.js Every appExact -
Database unit
User units per database unit and meters per database unit, read from the file.
two 8-byte reals from the UNITS record
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Integers written to the stream
Coordinates, widths, layers and array counts as the file stores them.
coordinates and widths: 32-bit signed; layers and counts: 16-bit signed
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Placement transform
A referenced cell's points reflected, magnified, rotated and moved.
(x, y) → mag × (x, ±y), rotated by the angle in degrees, then translated
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Nested placements
The combined transform of a cell placed inside a placed cell.
mag = mag_parent × mag_child; angle = angle_parent ± angle_child; reflection toggles
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Array placement
The position of each copy in a rows-by-columns array.
position(i, j) = origin + i × (c − o) ÷ cols + j × (r − o) ÷ rows
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Path outline
A path with a width turned into a polygon.
offset = ± half width along the corner bisector ÷ max(0.2, cos of the half angle)
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Database units to user units
Flattened coordinates in the file's user unit, usually micrometers.
x_user = x_db × userPerDb
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Shapes and area per layer
How many shapes each layer has and their total area.
area = Σ |shoelace area|
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Width, spacing and area checks
Shapes that are narrower, closer or smaller than a rule allows.
area < minArea − 1e-12; 0 < distance < minSpace − 1e-12; facing-edge width < minWidth − 1e-12
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Narrowest width of a shape
The smallest distance between two edges that face each other across the inside.
distance from one edge's line to the other, for antiparallel edges that overlap
GDSII layout: reals, flattening, areas and checks gds.js Every app64-bit -
Half-perimeter wire length
The estimate of total connection length reported before and after placement.
Σ over nets of (x_max − x_min) + (y_max − y_min)
Board placement and routing place.js Every app64-bit -
Overlap and outline penalties
The cost added when courtyards overlap or reach outside the board.
cost = 50 × (overlap area + area outside the margin)
Board placement and routing place.js Every app64-bit -
Annealing schedule
How the search cools from large moves to small ones.
T₀ = max(1, 0.15 (W + H)); T_end = 0.002 (W + H); T ← T × (T_end ÷ T₀)^(1 ÷ iterations)
Board placement and routing place.js Every app64-bit -
Final part positions
The positions stored on the board when placement ends.
x, y = round(value × 1000) ÷ 1000
Board placement and routing place.js Every app64-bit -
Routing grid
The grid of points tracks may pass through.
pitch = (track width + clearance) ÷ 2 by default; x = ox + i × pitch
Board placement and routing route.js Every app64-bit -
Obstacle map
Which grid points a track or a via of another net may not use.
blocked when distance to copper < clearance + track width ÷ 2 + 0.25 × pitch
Board placement and routing route.js Every app64-bit -
Path search
The cheapest path on the grid from a pad to the copper already routed for its net.
step cost 1, diagonal 1.4142, against the layer's direction × 1.4, via 14 per layer
Board placement and routing route.js Every app64-bit -
Track points
The corner points of a routed track.
drop a point when |(b − a) × (c − b)| ≤ 1e-9
Board placement and routing route.js Every app64-bit -
Wrap into an integer type
A number brought into the range of SINT, INT, DINT and the other integer types.
v mod 2ⁿ, moved into the signed range
Controller standard functions and integer types std.js Every appExact -
On-delay timer
The elapsed time and output of a TON block.
ET = min(now − t₀, PT); Q = ET ≥ PT
Controller standard functions and integer types std.js Every app64-bit -
Up counter
The count and output of a CTU block.
CV ← CV + 1 on a rising edge while CV < 32767; Q = CV ≥ PV
Controller standard functions and integer types std.js Every appExact -
Round to nearest, ties to even
The rounding used when a real is converted to an integer.
nearest whole number; a tie goes to the even neighbor
Controller standard functions and integer types std.js Every appExact -
Arithmetic functions
ABS, SQRT, LN, LOG, EXP, the trigonometric functions, MIN, MAX, LIMIT, TRUNC, SHL and SHR.
SQRT, LN, LOG, EXP, SIN and the rest from Math; SHL: x × 2ⁿ; SHR: ⌊x ÷ 2ⁿ⌋; TRUNC toward zero
Controller standard functions and integer types std.js Every app64-bit -
Type conversions
REAL_TO_INT, INT_TO_REAL, BOOL_TO_INT, TIME_TO_REAL and the other A_TO_B functions.
to an integer type: round to nearest (ties to even), then wrap; to a real type: unchanged
Controller standard functions and integer types std.js Every app64-bit -
Probability of a basic event
The probability of an event from a fixed value, a failure rate and time, a test interval, or repair data.
failed by t: 1 − e^(−λt); tested every τ: 1 − (1 − e^(−λτ)) ÷ (λτ), or λτ ÷ 2 below 1e-9; repairable: MTTR ÷ (MTTF + MTTR)
Fault trees and reliability block diagrams logic.js Every app64-bit -
At least k of n events
The probability that k or more of a set of independent events occur.
the distribution of the count, built one event at a time, summed from k up
Fault trees and reliability block diagrams logic.js Every app64-bit -
AND, OR and voting gates
The probability of a gate from its inputs when no event is repeated.
AND: Π pᵢ; OR: 1 − Π (1 − pᵢ)
Fault trees and reliability block diagrams logic.js Every app64-bit -
Top event with repeated events
The probability of the top event when the same event appears in several places.
P = p_x × P(tree | x occurs) + (1 − p_x) × P(tree | x does not)
Fault trees and reliability block diagrams logic.js Every app64-bit -
Cut set probabilities and bounds
The probability of each minimal cut set and two bounds on the top event.
rare event: min(1, Σ P(cut set)); upper bound: 1 − Π (1 − P(cut set))
Fault trees and reliability block diagrams logic.js Every app64-bit -
Importance measures
How much each event matters to the top event.
Birnbaum = P(top | p = 1) − P(top | p = 0); Fussell–Vesely = (P − P₀) ÷ P; RAW = P₁ ÷ P; RRW = P ÷ P₀
Fault trees and reliability block diagrams logic.js Every app64-bit -
Reliability of a component
The chance a block still works at the mission time.
R = e^(−λt); Weibull: R = e^(−(t ÷ η)^β)
Fault trees and reliability block diagrams logic.js Every app64-bit -
Block diagram reliability
The reliability of series, parallel and k-of-n arrangements.
series = OR of failures; parallel = AND; reliability = 1 − P(failure)
Fault trees and reliability block diagrams logic.js Every app64-bit -
Mean time to failure
The mean life of a system that is not repaired.
MTTF = ∫ R(t) dt by Simpson's rule, 4000 steps, to the time R ≤ 1e-9
Fault trees and reliability block diagrams logic.js Every app64-bit
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.