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
-
Spline (NURBS) as segments
The points that stand for a spline with control points.
de Boor on homogeneous points (x·w, y·w, w); 12 samples per knot span
Import of DXF and DWG drawings into the 3D model m3d/io.js64-bit- CadCraft
- ModelCraft
-
Spline stored with fit points only
The points that stand for a spline that carries fit points and no control points.
centripetal Catmull–Rom, 12 samples per span
Import of DXF and DWG drawings into the 3D model m3d/io.js64-bit- CadCraft
- ModelCraft
-
Bulge arcs in hatch boundaries
The points of a curved side of a hatch boundary given as a polyline bulge.
center = chord midpoint + ((1 ÷ b − b) ÷ 2) × (chord turned 90°) ÷ 2; sweep = 4 atan b
Import of DXF and DWG drawings into the 3D model m3d/io.js64-bit- CadCraft
- ModelCraft
-
Block insert transform
The transform that places a block, with its scale, rotation and array spacing.
M = T(x, y) · R(rot) · S(s_x, s_y) · T(−base); array offset = R(rot) · (col × d_c, row × d_r)
Import of DXF and DWG drawings into the 3D model m3d/io.js64-bit- CadCraft
- ModelCraft
-
Hatch holes
Which loops of a hatch are outlines and which are holes.
area = ½ |Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)|; a loop inside an odd number of larger loops is a hole
Import of DXF and DWG drawings into the 3D model m3d/io.js64-bit- CadCraft
- ModelCraft
-
3D face corners
The corners of 3D faces and solids, which keep their heights.
(x, y) placed by the block transform; all three × k
Import of DXF and DWG drawings into the 3D model m3d/io.js64-bit- CadCraft
- ModelCraft
-
Text line pitch
The distance between lines of imported multi-line text, which is drawn as edges.
pitch = height × 1.667 × spacing factor
Import of DXF and DWG drawings into the 3D model m3d/io.js64-bit- CadCraft
- ModelCraft
-
Edges of imported solids
How the edges of an imported solid are matched to decide which ones show.
key = round(x × 1e5), round(y × 1e5), round(z × 1e5)
Import of DXF and DWG drawings into the 3D model m3d/io.js64-bit- CadCraft
- ModelCraft
-
OBJ vertex
A vertex line of an OBJ file.
(x, y, z) → (x, −z, y)
Import of OBJ, glTF and Collada models m3d/io.js64-bit- CadCraft
- ModelCraft
-
glTF accessor values
The numbers of a glTF buffer, such as vertex positions.
Import of OBJ, glTF and Collada models m3d/io.js64-bit- CadCraft
- ModelCraft
-
glTF node transform
The matrix of a glTF node from its matrix, or from its translation, rotation and scale.
M = T · R(q) · S
Import of OBJ, glTF and Collada models m3d/io.js64-bit- CadCraft
- ModelCraft
-
glTF vertex in the model
A glTF vertex moved by its node transforms and turned to Z up.
p′ = M · p, then (x, y, z) → (x, −z, y)
Import of OBJ, glTF and Collada models m3d/io.js64-bit- CadCraft
- ModelCraft
-
Collada numbers
How lists of numbers in a Collada file are read.
Import of OBJ, glTF and Collada models m3d/io.js64-bit- CadCraft
- ModelCraft
-
Collada unit and up axis
The change from the file's unit and up axis to Z-up meters.
C = R_up · S(meter); node matrix → C · M · C⁻¹; point → C · p
Import of OBJ, glTF and Collada models m3d/io.js64-bit- CadCraft
- ModelCraft
-
Collada node transforms
The matrix of a Collada node from its matrix, translate, rotate and scale elements.
rotate: angle in radians = degrees × π ÷ 180
Import of OBJ, glTF and Collada models m3d/io.js64-bit- CadCraft
- ModelCraft
-
Collada vertex in the model
A Collada vertex turned to Z-up meters.
p′ = C · p
Import of OBJ, glTF and Collada models m3d/io.js64-bit- CadCraft
- ModelCraft
-
Arc of a glyph
The points of the round parts of letters.
n = max(2, ⌈|a₁ − a₀| ÷ 15⌉); p = (c_x + r_x cos a, c_y + r_y sin a)
Text from drawings as stroked edges m3d/strokefont.js64-bit- CadCraft
- ModelCraft
- PartCraft
-
Width of a string
The advance of a string in drawing units, used to align and wrap text.
width = (Σ (glyph width + 2) − 2) × h ÷ 9 × width factor
Text from drawings as stroked edges m3d/strokefont.js64-bit- CadCraft
- ModelCraft
- PartCraft
-
Strokes of a string
The polylines of a string at a given height, width factor and slant.
x = x₀ + p_x × s_x + p_y × s × tan(oblique); y = p_y × s; s = h ÷ 9
Text from drawings as stroked edges m3d/strokefont.js64-bit- CadCraft
- ModelCraft
- PartCraft
-
Day of the year
The day number of a date.
N = days before the month + day (+1 after February in a leap year)
Sun position for shadows m3d/sun.jsExact- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
-
Equation of time and declination
How far sun time runs ahead of clock time, and the sun's angle above the equator, for the date.
γ = 2π ÷ (365 or 366) × (N − 1 + (hour − 12) ÷ 24); eqtime = 229.18 × (0.000075 + 0.001868 cos γ − 0.032077 sin γ − 0.014615 cos 2γ − 0.040849 sin 2γ)
Sun position for shadows m3d/sun.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
-
Hour angle and altitude
The sun's height above the horizon.
tst = hour × 60 + eqtime + 4 × lon − 60 × tz; H = tst ÷ 4 − 180°; cos Z = sin φ sin δ + cos φ cos δ cos H; altitude = 90° − Z
Sun position for shadows m3d/sun.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
-
Azimuth
The sun's compass direction, in degrees clockwise from north.
azimuth = atan2(sin H, cos H sin φ − tan δ cos φ) + 180°, wrapped to 0…360
Sun position for shadows m3d/sun.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
-
Direction toward the sun
The unit vector shadows are cast from, in model axes (north is +Y, east is +X).
dir = (sin a cos alt, cos a cos alt, sin alt)
Sun position for shadows m3d/sun.js64-bit- CadCraft
- BimCraft
- ModelCraft
- CivilCraft
-
Unit vector
A vector scaled to length 1.
n = a ÷ |a|; [0, 0, 0] when |a| ≤ 1e-15
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Polygon normal
The unit normal of a polygon given by its corner points.
N = Σ (pᵢ − pᵢ₊₁) × (pᵢ + pᵢ₊₁) taken per axis, then normalized
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Polygon area in 3D
The area of a flat polygon in space.
area = |Σ (pᵢ − pᵢ₊₁) × (pᵢ + pᵢ₊₁)| ÷ 2
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Plane through a point
A plane as a unit normal and an offset, with the normal's sign made canonical.
n·p = d; first component of n with |n| > 1e-9 is made positive
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Same plane test
Whether two planes are the same plane.
|n₁·n₂| > 1 − 1e-9 and |d₁ × sign(n₁·n₂) − d₂| ≤ 1e-6
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Closest points of a line and a segment
The nearest points between a ray's line and an edge.
den = (d·d)(u·u) − (d·u)²; t = (B·E − C·D) ÷ den; s = (A·E − B·D) ÷ den, clamped to [0, 1]
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Closest points of two lines
The nearest points between two infinite lines, or nothing when they are parallel.
den = A·C − B²; parallel when |den| < 1e-14 × A × C
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Ray and plane
The point where a ray's line meets a plane.
t = (d_plane − n·o) ÷ (n·dir); p = o + t × dir
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Ray and triangle
The distance along a ray to a triangle, or nothing when it misses.
Möller–Trumbore: det = e₁·(d × e₂); u, v, t from three scalar triple products ÷ det
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Rotation about an axis through a point
The 4×4 matrix that turns geometry by an angle about an axis through a given point.
M = T(about) × R(axis, θ) × T(−about), R from Rodrigues' formula
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Transform a point
A point moved by a 4×4 matrix.
p′ = (M × [x, y, z, 1]) ÷ w
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
Inverse of a 4×4 matrix
The matrix that undoes a transform, used to move points into a group's own coordinates.
M⁻¹ = adj(M) ÷ det(M), with det from twelve 2×2 minors
3D vectors, planes and transforms m3d/vec.js64-bit- CadCraft
- BimCraft
- ModelCraft
- TakeoffCraft
- CivilCraft
-
One typed length to meters
Text such as 10'-6 1/2", 3/4", 320cm or a bare number, as meters.
m = sign × (feet × 0.3048 + (inches + num ÷ den) × 0.0254); m = sign × value × factor(suffix or model unit)
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Meters per unit
The factor that turns a bare number in the model's unit into meters.
in = 0.0254; ft = 0.3048; yd = 0.9144; mi = 1609.344; mil = 0.0254 ÷ 1000
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Arithmetic over typed lengths
A typed expression such as 12'6"+3/4" or 2*450mm as one length in meters.
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
The value box
What was typed as a length, a list of lengths, a point, an offset, a count or a plain number for angles and factors.
plain number = value in meters ÷ meters per unit (for arithmetic and bare fractions)
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Length readout
A length in meters as text in the model's unit.
ft-in: total = round(m ÷ 0.0254 × den) sixteenths (or the chosen fraction); others: toFixed with the unit's decimals
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Inches as a fraction
Inches written as a whole number and a reduced fraction.
sx = round(inches × den); whole = ⌊sx ÷ den⌋; fraction = (sx mod den) ÷ den, reduced by the greatest common divisor
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Area readout
An area in square meters as text in the model's unit.
ft²: a ÷ (0.3048 × 0.3048); in²: a ÷ (0.0254 × 0.0254); mm model: m² from 0.01 m², else mm²
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Volume readout
A volume in cubic meters as text in the model's unit.
ft³: v ÷ 0.3048³; in³: v ÷ 0.0254³; mm model: m³ from 0.01 m³, else mm³
Typed lengths and length readouts in 3D m3d/units.js64-bit- CadCraft
- ModelCraft
-
Two-point arc from its bulge
The radius, center and sweep of an arc through two points that stands off the chord by a given bulge.
R = (h² + (c ÷ 2)²) ÷ (2|h|); center = midpoint + side × sign(h) × (|h| − R); sweep = 4 × atan(2|h| ÷ c)
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Sweep of an arc drawn from its center
The angle from the arc's start direction to the pointer, counter-clockwise about the plane normal.
a = atan2((u × w)·n, u·w), plus 2π when a ≤ 0; snapped to k × π ÷ 12 when within 0.03 rad
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Rectangle width and height
The two sides of a rectangle from its first corner to the pointer, along the plane's two axes.
w = (q − p₀)·u; h = (q − p₀)·v
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Distance from a point to an outline segment
How far the pointer is from one side of the outline being offset, in the outline's plane.
t = clamp(((p − a)·(b − a)) ÷ |b − a|², 0, 1); distance = |p − a − t(b − a)|
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Offset distance and side
The signed distance an outline is offset by: the least distance to any side, positive into a face.
d = ± min over sides of distance(p, side); inside by an even-odd crossing count
3D drawing and editing tools m3d/tools.js64-bit- CadCraft
- ModelCraft
-
Point inside an outline
Whether the pointer lies inside a face's outline, which decides if an offset goes inward or outward.
count the sides whose ends straddle the point's height and cross to its right; inside when the count is odd
3D drawing and editing tools m3d/tools.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.