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 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
-
Drawing coordinates to screen position
Where a drawing point is on screen, in CSS pixels of the active pane.
sx = (x − cx)·zoom + w ÷ 2; sy = h ÷ 2 − (y − cy)·zoom (with a turn: the difference is rotated first)
2D drawing on screen view.js32-bit, display only- CadCraft
-
Origin of the cached paths
The point the cached drawing paths are stored relative to.
origin = middle of the extents of the visible objects; path point = point − origin
2D drawing on screen view.js32-bit, display only- CadCraft
-
Grid spacing
The spacing of the background grid: 1, 2 or 5 times a power of ten, at least 14 pixels apart.
target = 14 ÷ zoom; p = 10^⌊log₁₀ target⌋; step = first of p, 2p, 5p, 10p that is ≥ target; major = 5 × step
2D drawing on screen view.js32-bit, display only- CadCraft
-
Pixels per paper millimeter
How many CSS pixels one millimeter of the sheet takes, used to draw lineweights at their paper width.
√(T₀² + T₁²) ÷ (25.4 when the paper is in inches, else 1)
2D drawing on screen view.js32-bit, display only- CadCraft
-
Band of a wide polyline segment
The filled outline of one polyline segment that has a start and end width.
h(t) = (w₀ + (w₁ − w₀)·t) ÷ 2; left = p + n·h; right = p − n·h; arc: k = max(2, ⌈sweep ÷ 10°⌉) steps
Wide polylines, text masks and ellipses as drawn and plotted walk.js64-bit- CadCraft
-
Corner between two wide segments
The wedge that fills the outside gap where one wide segment meets the next.
cross = tₐ × t_b; s = ((P₂ − P₁) × t_b) ÷ cross; X = P₁ + s·tₐ; used when s ≥ 0 and |X − corner| ≤ 10 × max(hₐ, h_b)
Wide polylines, text masks and ellipses as drawn and plotted walk.js64-bit- CadCraft
-
Text background mask
The rectangle painted behind a text: its box grown by a margin and turned with the text.
m = max(0, scale − 1) × height; corner = (x, y) + R(rot) · (x₀ − m, y₀ − m) …
Wide polylines, text masks and ellipses as drawn and plotted walk.js64-bit- CadCraft
-
Ring direction
Turns a ring clockwise so that overlapping rings add up when filled.
a = Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ); a > 0 → reverse the points
Wide polylines, text masks and ellipses as drawn and plotted walk.js64-bit- CadCraft
-
Ellipse as line pieces
The line pieces an ellipse is drawn and plotted with.
Wide polylines, text masks and ellipses as drawn and plotted walk.js64-bit- CadCraft
-
Linetype scale of an object
The factor that sizes the dashes of an object's linetype.
scale = LTSCALE × object scale × plot style table scale (non-ISO linetypes only)
Wide polylines, text masks and ellipses as drawn and plotted walk.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
-
Clip polygon in drawing coordinates
The clip polygon of a reference moved from the block's coordinates into the drawing.
M = m · insert matrix; point = M · p
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
Clip read from a file
Turns the clip boundary stored in a DWG or DXF file into the polygon kept on the reference.
point = I · (T · p), with T the clip transform and I the inverse block transform (3 × 4 each)
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
Objects cut to the clip when binding
The objects of a block cut to the clip polygon: whole when inside, as line and arc pieces when crossing.
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
New clip boundary into block coordinates
Stores a boundary picked in the drawing as a polygon in the block's own coordinates.
d = m₀·m₃ − m₁·m₂; inv = adjugate ÷ d; stored point = inv · picked point
Clipping block references to a boundary xclip.js64-bit- CadCraft
-
Meters to drawing units
A 3D point in meters as a point in drawing units.
x = pₓ ÷ k; y = pᵧ ÷ k; z = p_z ÷ k
Points and heights picked in the 3D view ws3d-core.js64-bit- CadCraft
-
Point on a level plane
Where the ray under the pointer meets the plane at height z.
plane: n = (0, 0, 1), d = z × k; point = ray hit ÷ k
Points and heights picked in the 3D view ws3d-core.js64-bit- CadCraft
-
Height following the cursor
A height above a base outline, taken from where the pointer's ray passes nearest the vertical line through the outline's middle.
c = Σ ring points ÷ n; height = s ÷ k, with s the distance along the vertical line from (cₓ·k, cᵧ·k, z₀·k)
Points and heights picked in the 3D view ws3d-core.js64-bit- CadCraft
-
2D drawing as snap edges
The visible lines and arcs of the 2D drawing as edges on the ground, in meters, for the 3D snaps.
edge = (x·k, y·k, 0); arc: m = max(2, ⌈sweep ÷ 7.5°⌉) chords
Points and heights picked in the 3D view ws3d-core.js64-bit- CadCraft
-
Height shown beside the cursor
The text of the height tip while a height is being picked.
|n| < 1e-9 → 0; else n to 4 decimals, trailing zeros removed
Points and heights picked in the 3D view ws3d-core.js64-bit- CadCraft
-
Kept solids as screen meshes
The vertex positions and edge lines of the kept 3D solids as drawn on the 3D tab.
position = (P − corner) × k, stored as 32-bit
3D tab drawing of the 2D lines and kept solids ws3d.js32-bit, display only- CadCraft
-
2D lines as screen lines
The 2D drawing's line pieces as drawn on the ground of the 3D tab.
position = (x − min x, y − min y, 0), stored as 32-bit
3D tab drawing of the 2D lines and kept solids ws3d.js32-bit, display only- CadCraft
-
Unit vector
A direction scaled to length 1, or nothing when it has no length.
l = √(x² + y² + z²); l > 1e-300 → (x, y, z) ÷ l
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Plane
A point of a plane from its (u, v), and back.
P = O + U·u + V·v; u = (p − O)·U; v = (p − O)·V
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Cone and cylinder
A point of a cone or cylinder (circular or elliptical base) from its angle and its height along the axis, and back.
t = ± sin ÷ cos; q = 1 + h·t ÷ R; P = C + X·R·q·cos u + Y·R_m·q·sin u + N·h; u = atan2((d·Y) ÷ R_m, (d·X) ÷ R); apex at h = −R ÷ t
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Sphere
A point of a sphere from longitude and latitude, and back.
P = C + r·cos v·(X·cos u + Y·sin u) + Z·r·sin v; u = atan2(y, x); v = atan2(z, √(x² + y²))
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Torus
A point of a torus from its two angles, and back.
w = A + B·cos v; P = C + X·w·cos u + Y·w·sin u + N·B·sin v; u = atan2(y, x); v = atan2(z, √(x² + y²) − A)
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Spline surface and its inverse
A point of a B-spline surface from (u, v), its normal, and the (u, v) nearest to a given point.
first guess: nearest of 25 × 25 samples; then Gauss–Newton on |p − S(u, v)|² with partial derivatives by central differences of 1e-6 of the range
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Knot span
Which knot interval a parameter falls in.
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
De Boor evaluation
A point of a B-spline at a parameter, in homogeneous coordinates.
a = (t − Uᵢ) ÷ (Uᵢ₊ₚ₋ᵣ₊₁ − Uᵢ); d_j = (1 − a)·d_j₋₁ + a·d_j
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Spline curve point
A point of a rational B-spline curve.
P = (X, Y, Z) ÷ W from de Boor
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Spline surface point
A point of a rational B-spline surface.
de Boor along v on each of the p + 1 rows, then de Boor along u on the results
ACIS solids turned into triangles acis/geom.js64-bit- CadCraft
- ModelCraft
-
Model size and tolerances
The size of the whole solid and the tolerances every later test uses.
size = max(|hi − lo|, 2·rad, 1e-9); tol = max(10 × resabs, 1e-5 × size); weld = 1e-9 × size
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Circular and elliptical edges
The points along an edge that is part of a circle or an ellipse.
step = min(7.5°, 2·acos(1 − min(1, 0.0002·size ÷ R))); n = min(4096, ⌈|t₁ − t₀| ÷ max(step, 0.001)⌉)
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Spline edges
The points along an edge that follows a B-spline curve.
N = min(4000, max(64, 24 × spans)) samples; end parameters by nearest sample, then 60 steps of a three-way search; n = ⌈|t₁ − t₀| ÷ (b − a) × N ÷ 4⌉ pieces, 2 to 4096
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Merging vertices
Gives points that coincide one shared vertex, so a closed solid stays closed.
key = round(x ÷ weld), round(y ÷ weld), round(z ÷ weld)
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Does the surface fit its edges
Checks that every edge point of a face lies on the face's surface before the face is used.
|S(inv(p)) − p| ≤ tol for every loop point
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Which way the triangles face
Turns a face's triangles so they point the way the face's outward normal does.
n = (t₁ − t₀) × (t₂ − t₀); vote by the sign of n · normal at the triangle's center
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Flat faces
Triangles of a flat face with its holes.
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Outer loops and holes
Sorts the loops of a face into outlines and the holes inside them.
A = |Σ (uᵢ·vᵢ₊₁ − uᵢ₊₁·vᵢ)| ÷ 2; depth = number of larger loops that contain the middle of the loop's first edge
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Loop unwound on a curved surface
The (u, v) of a loop's points with the angles unwound along the loop, and how many times it goes round the surface.
du wrapped to ±half a turn and added up; windings = round(total ÷ period); pole when cos v · r ≤ tol (sphere) or the cone radius ≤ tol
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Step sizes on a curved face
How finely a curved face is divided.
angles: 7.5°; spline: range ÷ 16 each way; along a cone's axis: max(3 × 7.5° in radians × R, 1e-12)
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Extra points inside a curved face
The points added inside a curved face so that its triangles follow the surface.
one point per grid cell at (i + 0.5 + 0.3·jitter)·cell; kept when inside the face and at least 0.35 × the smaller cell side from every boundary edge
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
-
Fixed offset of a grid point
A repeatable offset between −0.5 and 0.5 for each grid cell.
s = sin(12.9898·i + 78.233·j) × 43758.5453; s − ⌊s⌋ − 0.5
ACIS solids turned into triangles acis/tess.js64-bit- CadCraft
- ModelCraft
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.