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
-
Pieces back from the boolean library
Reads a piece's corners from manifold-3d and returns them to world coordinates.
world = org + 32-bit local corner
Splitting a model into printable pieces print-split.js32-bit in part- ModelCraft
- PartCraft
-
Cutting by each plane
Splits every cell by the next plane and keeps the parts that have volume.
Splitting a model into printable pieces print-split.js32-bit in part- ModelCraft
- PartCraft
-
Outline of a cut through the model
The line segments where a plane crosses the model's triangles, in the plane's own two axes.
sᵢ = n·pᵢ − d; k = sᵢ ÷ (sᵢ − sⱼ); point = pᵢ + (pⱼ − pᵢ) × k
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Sampling a cut section
For a grid of points over the cut: inside the model or not, and the distance to the outline.
step = max(largest extent ÷ samples, 0.2); inside = odd number of outline crossings to the left; distance = √(min squared distance to an outline segment)
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Touching area of a joint
The area where two pieces meet on a cut.
area += samples in the region × step²
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Room a connector needs
The least distance from a connector's axis to any outside surface, and how deep it goes each side.
peg: d ÷ 2 + c + w; key: (W ÷ 2)·√2 + c + w; dovetail: w₁ ÷ 2 + c + w with w₁ = W + 2H·tan(angle); dowel, magnet: d ÷ 2 + c + w
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Round hole with its flats on the radius
Sizes a faceted hole so its flat sides, not its corners, are at the asked radius.
corner radius = r ÷ cos(π ÷ segments)
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Connector and hole solids
The peg, key, dovetail, dowel pin or magnet pocket and the matching hole, in the joint's own frame.
hole radius = r + c; hole depth = L + c; chamfer = min(0.5, r ÷ 3); dovetail half width at z: w₀ + (w₁ − w₀)·z ÷ H + growth
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Does a connector fit here
Checks along a connector's depth that it stays inside the model with a wall all round and clear of the other cuts.
at steps of 0.75 mm along the depth: inside, nearest outside surface ≥ lateral, distance to every other cut ≥ lateral + deepest hole
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Spreading connectors along a joint
Picks up to k connector spots spread along the long axis of the touching area.
θ = ½·atan2(2·Σuv, Σu² − Σv²) about the mean; samples sorted by their position along that axis and cut into k slices
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Length of a dovetail
How far a dovetail runs each way from its spot, and whether each end is open.
open end: (steps + ½) × step + wall + 1; stopped end: max(0, steps × step − lateral)
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Engraved joint number
The joint's number as a solid: each stroke of the stroke font widened to a rectangle, joined and extruded.
stroke width = max(0.6, 0.14 × h); rectangle = segment grown by half the width on all sides
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Corners back onto slanting cut planes
Moves each corner that lies within 2e-4 mm of a slanting cut plane, or of a connector or number depth parallel to it, exactly onto that plane.
s = n·p − d; if 0 < |s| < 2 × 10⁻⁴: p ← p − n·s
Splitting a model into printable pieces print-split.js32-bit in part- ModelCraft
- PartCraft
-
Building and measuring each piece
Adds the male connectors, cuts the holes and numbers, and returns each piece with its size, volume and print check.
piece = (cut part ∪ male parts) − holes − numbers; size = box of its corners; volume from the library
Splitting a model into printable pieces print-split.js32-bit in part- ModelCraft
- PartCraft
-
Laying a piece on the bed
Turns a piece in 90° steps so it fits the bed and moves it to stand on z = 0 at x, y ≥ 0.
new[k] = ±old[q(k)]; then new[k] −= min over the piece
Splitting a model into printable pieces print-split.js64-bit- ModelCraft
- PartCraft
-
Piece list on the assembly sheet
One line per piece with its size and volume, then the joints and the pins.
size shown = round(mm × 10) ÷ 10; volume shown = round(mm³ ÷ 1000 × 10) ÷ 10 cm³; pin length = dowel length − clearance
Splitting a model into printable pieces print-split.js32-bit in part- ModelCraft
- PartCraft
-
Normal of a slanting cut
The normal of a cut across one axis, turned by an angle about another axis.
n = axis·cos r + (about × axis)·sin r, r = degrees × π ÷ 180
Splitting a model into printable pieces print-split-ui.js64-bit- ModelCraft
- PartCraft
-
Cut places typed by the person
Turns the typed distances from the low end of the model into cut planes.
point = middle of the box, with axis coordinate lo + v; d = n·point
Splitting a model into printable pieces print-split-ui.js64-bit- ModelCraft
- PartCraft
-
Connector spot picked by hand
Where the ray under a click crosses the cut plane between two pieces.
t = (d − n·o) ÷ (n·dir); p = o + dir × t
Splitting a model into printable pieces print-split-ui.js64-bit- ModelCraft
- PartCraft
-
Welding corners
Joins corners that lie within the tolerance of each other and drops triangles that collapse.
join if |Δx| ≤ tol and |Δy| ≤ tol and |Δz| ≤ tol; drop if two corners are the same or |n|² ≤ (tol² × 0.01)²
Print check: weld, volume, area and intersections print3d.js64-bit- ModelCraft
- PartCraft
-
Volume, area, overhang and bed contact
Each shell's volume, the total surface area, the area that needs support and the area lying on the bed.
area = Σ |n| ÷ 2; V_shell = Σ a·(b × c) ÷ 6; overhang if n_z ÷ |n| < −cos((90 − angle)·π ÷ 180)
Print check: weld, volume, area and intersections print3d.js64-bit- ModelCraft
- PartCraft
-
A shell inside another shell
Decides whether an inside-out shell is a hollow inside another shell, which is correct, or a real fault.
ray from one corner along [0.000123, 0.000457, 1]; inside if it crosses the other shells an odd number of times
Print check: weld, volume, area and intersections print3d.js64-bit- ModelCraft
- PartCraft
-
Ray and triangle
The distance along a ray to a triangle, or −1 when it misses.
det = e₁·(d × e₂); u = s·(d × e₂) ÷ det; v = d·(s × e₁) ÷ det; t = e₂·(s × e₁) ÷ det
Print check: weld, volume, area and intersections print3d.js64-bit- ModelCraft
- PartCraft
-
Finding triangle pairs to test
Finds pairs of triangles whose boxes overlap and counts those that cross, within one shell and between shells.
eps = diagonal × 10⁻⁹; boxes grown by eps; pair tested with tolerance 10 × eps
Print check: weld, volume, area and intersections print3d.js64-bit- ModelCraft
- PartCraft
-
Do two triangles cross
Whether two triangles pass through each other, more than touching.
signed distances of each triangle's corners to the other's plane, set to 0 within eps; overlap of the two intervals on the planes' common line must exceed eps
Print check: weld, volume, area and intersections print3d.js64-bit- ModelCraft
- PartCraft
-
Triangles in the same plane
Whether two triangles in one plane overlap.
2D orientation tests on the projection that drops the normal's largest axis; crossing edges, or one centroid inside the other
Print check: weld, volume, area and intersections print3d.js64-bit- ModelCraft
- PartCraft
-
Total volume and bed fit
The volume reported for a mesh without problems, and the warnings for a tiny model or one larger than the bed.
V = Σ shell volumes (hollows are negative); fits if sizeₖ ≤ bedₖ + 10⁻⁹, as given or with x and y swapped
Print check: weld, volume, area and intersections print3d.js64-bit- ModelCraft
- PartCraft
-
Binary STL
Writes each triangle's unit normal and three corners.
normal = n ÷ |n| from the winding; every number written with setFloat32
STL and 3MF files for the printer print3d.js32-bit in part- ModelCraft
- PartCraft
-
A coordinate as 3MF text
Formats one coordinate for the 3MF file.
0 if |v| < 10⁻¹²; else v rounded to 10 significant digits
STL and 3MF files for the printer print3d.js64-bit- ModelCraft
- PartCraft
-
3MF vertex list
Writes every corner of the mesh as a vertex element.
STL and 3MF files for the printer print3d.js64-bit- ModelCraft
- PartCraft
-
Render buffers of a definition
The triangles of a definition's shown faces as position, normal and texture-coordinate buffers.
Scene handed to the renderer render-mc.js32-bit, display only- ModelCraft
-
Height from a baked displacement map
The displacement height at a texture coordinate.
bilinear blend of the four texels round (u, v), wrapping at the edges, read at texel centers
Scene handed to the renderer render-mc.js32-bit, display only- ModelCraft
-
Displaced mesh point
Moves a mesh point along its averaged normal by the material's height times its scale, for the render.
p′ = p + n̂ × height(u, v) × scale
Scene handed to the renderer render-mc.js32-bit, display only- ModelCraft
-
Flat area per color
The total area of level, upward faces of each color, largest first.
s = ∛|m₀·(m₅·m₁₀ − m₆·m₉)|; area = Σ face area × s²; shown = round(area × 100) ÷ 100
Areas of flat upward faces by color render-mc.js64-bit- ModelCraft
-
Sunrise, sunset and solar noon
The clock hours of sunrise, sunset and solar noon and the sun's highest altitude on a day.
hᵢ = min(0.05·i, 23.99), i = 0 … 480; rise = first hᵢ with altitude > 0 after one ≤ 0; noon = hᵢ of the highest altitude
Time of day, date and exposure from plain words scene-say.js64-bit- ModelCraft
-
Clock hour for a named time
The hour that stands for dawn, morning, noon, afternoon, golden hour, dusk or night on a given day.
dawn = rise + 0.3; morning = rise + 0.45·(noon − rise); afternoon = noon + 0.55·(set − noon); dusk = set − 0.1; night = set + 2; hour = round to 0.01
Time of day, date and exposure from plain words scene-say.js64-bit- ModelCraft
-
The look for the choices made
Combines time, date or season and weather into the sun's date and hour and the render's exposure.
month, day = round(given); exposure = round((weather + time of day) × 100) ÷ 100
Time of day, date and exposure from plain words scene-say.js64-bit- ModelCraft
-
Places things can stand on
Top-level placements and large flat faces with their box, top height, height and area.
placement area = Δx × Δy of its box; face area from the model kernel; every number rounded to 0.001
Placing scene trees and people scene-entourage.js64-bit- ModelCraft
-
Point inside a face outline
Whether a plan point lies inside a polygon.
count edges with (y_a > y) ≠ (y_b > y) and x < (x_b − x_a)·(y − y_a) ÷ (y_b − y_a) + x_a; inside if odd
Placing scene trees and people scene-entourage.js64-bit- ModelCraft
-
The ground a request names
The region to scatter over, the height things stand at, and the boxes to keep clear.
on a placement: its box in plan, z = top of the box; on a face: its outline, z = first point's z; avoid boxes with top > z + 0.3 and bottom < z + 2.5
Placing scene trees and people scene-entourage.js64-bit- ModelCraft
-
Planting trees
Places a number of trees over the region, each with a random turn and a size within 10% of the library's.
minimum distance = max(0.5, 0.9 × crown width); yaw = rand × 2π; scale = 0.9 + 0.2 × rand
Placing scene trees and people scene-entourage.js64-bit- ModelCraft
-
Placing people
Places figures over the region; along a line they face along it, half each way.
heading = atan2(Δy, Δx) of the line; yaw = heading + π ÷ 2 (+ π for half of them) + (rand − ½) × 0.3; scale = 0.97 + 0.06 × rand
Placing scene trees and people scene-entourage.js64-bit- ModelCraft
-
Scattering points with a minimum spacing
Seeded points inside a rectangle or along a line, none closer than the minimum distance to another.
rectangle: x = x₀ + margin + rand × w, y likewise; line: p = a + (b − a) × i ÷ (count − 1) + normal × jitter; kept x, y = round to 0.01
Placing scene trees and people scene-say.js64-bit- ModelCraft
-
Placement matrix
The 4×4 matrix for a turn about the vertical axis, a uniform scale and a position.
c = cos(yaw)·scale; s = sin(yaw)·scale; columns [c, s, 0], [−s, c, 0], [0, 0, scale], [x, y, z]
Placing scene trees and people scene-say.js64-bit- ModelCraft
-
Arc and circle as straight segments
The ground segments for one traced line, arc or circle.
aₖ = a₀ + sweep × k ÷ n; pₖ = [cx + r·cos aₖ, cy + r·sin aₖ, 0]
Traced sketch into model edges sketch-photo-mc.js64-bit- ModelCraft
-
Picked points in millimeters
The picked model points as the surfaces library receives them.
v_mm = round(v × 1000 × 10⁶) ÷ 10⁶
Points picked for surfaces surfaces-mc.js64-bit- ModelCraft
-
Letter outlines from strokes
The outline of the text: each stroke segment as a rectangle of the pen's width, each stroke point as a disc.
r = height × weight ÷ 2; rectangle corners = a ∓ r·n̂, b ∓ r·n̂; disc corner = c + r·[cos(i·π ÷ 6), sin(i·π ÷ 6)]; line k at y − 1.6·k·height
3D text text3d.js64-bit- ModelCraft
-
Letters as faces or solids
The component the app places: flat faces, or a closed solid from z = 0 to the depth.
g6(v) = round(v × 10⁶) ÷ 10⁶ on every coordinate
3D text text3d.js32-bit in part- ModelCraft
-
Did another program change the points
Decides whether a definition's native USD points still match the model's own.
changed if any fround(own coordinate) ≠ file coordinate, or the counts differ
USD save, open and import usd-modelcraft.jsExact- ModelCraft
-
Mesh from the native points
Rebuilds a definition that was changed elsewhere from the file's native points and faces.
USD save, open and import usd-modelcraft.js64-bit- 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.