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
-
Room coordinates to viewport coordinates
A point of the room in the viewport's axes and millimeters.
k = 25.4 (inch job) or 1; (x, y, z) → (x·k, z·k, −y·k)
Cabinets as 3D viewport bodies addons/cabinetcraft/lib/bodies3d.js32-bit, display only- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Board corners in the blank's own frame
Turns a board's corners from the cabinet frame into the frame of its blank, and takes the blank's length and width.
x′ = (p − o)·uₓ; y′ = (p − o)·u_y; L = max x′; W = max y′
Corner cabinet drilling positions addons/cabinetcraft/lib/cornerdrill.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Arm boards and triangle of a corner cabinet
The outlines of the bottom and top boards for each corner form, from the cabinet's width, depth and panel thickness.
Corner cabinet drilling positions addons/cabinetcraft/lib/cornerdrill.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
System hole grid along a side
The positions of the system holes along a side panel.
x = sysStart, sysStart + pitch, … while x ≤ len − sysStart
Corner cabinet drilling positions addons/cabinetcraft/lib/cornerdrill.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Hinge plate holes
Places the two plate holes of each hinge on the system grid of the side panel.
center = reveal ÷ 2 + hinge spot; first hole = grid hole nearest (center − pitch ÷ 2); second = first + pitch
Corner cabinet drilling positions addons/cabinetcraft/lib/cornerdrill.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Fixing holes along a joint
Places the dowel or cam holes on the edge two boards share, in each board's own frame.
P = p + (q − p) ÷ len × u, u = sysStart and len − sysStart, or len ÷ 2
Corner cabinet drilling positions addons/cabinetcraft/lib/cornerdrill.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Edge holes kept on the blank
Moves an edge hole back onto the blank when the cut part is a little smaller than the drawn board.
x = min(max(x, 0), part length); y = min(max(y, 0), part width)
Corner cabinet drilling positions addons/cabinetcraft/lib/cornerdrill.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Corners of a rectangle, L or U room
The corner list of a room from its width, depth and notch.
U notch start a = (W − notch w) ÷ 2
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Right-angled outline made safe
Checks a typed outline with right angles, drops repeated and collinear corners, makes it counter-clockwise and moves it to (0, 0).
2A = Σ (xᵢ yᵢ₊₁ − xᵢ₊₁ yᵢ); reject when |2A| < 1
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Do two edges cross
Decides whether two outline edges properly cross.
o(p, q, r) = (q − p) × (r − p); cross when the signs differ on both segments
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Arc walls as chords
Writes each arc wall out as short chords so the room can be tested as a polygon.
step = 2 × acos(max(0, 1 − 0.5 ÷ r)); n = ⌈|sweep| ÷ step⌉, between 4 and 400
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Free outline with slanted and arc walls
Checks an outline of any angle with arc edges and returns its corners, arcs and overall width and depth.
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Wall frames, lengths and corner turns
For each wall: its length, direction, the frame cabinets are placed in, its angle and the turn at each corner.
chord = √(Δx² + Δy²); u = Δ ÷ chord; n = (−u_y, uₓ); angle = atan2(u_y, uₓ) × 180 ÷ π
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Point inside the room
Tests whether a point is inside the outline; the boundary counts as inside.
on edge when |cross| < 1e-4 × max(1, edge length); else even-odd count of edges crossed by a ray
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Cabinet footprint inside the room
Decides whether a polygon lies inside the room.
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Distance from a point to a wall segment
The shortest distance from a point to a segment.
t = clamp((p − a)·(b − a) ÷ |b − a|², 0, 1); d = |p − (a + t (b − a))|
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Clearance from a footprint to the nearest wall
The smallest distance between a footprint and any wall, 0 when they touch or cross.
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Door and window positions along a wall
Clamps each opening's width, offset, height and sill to its wall and the room height.
inch default = mm default × (1 ÷ 25.4); at ≤ chord − w
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Floor strip in front of an opening
The four corners of the strip of floor in front of a door or window, in room coordinates.
P(s, o) = origin + u × s + n × o
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Typed corner coordinates
Reads x,y pairs typed by a person.
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Outline from edge lengths and turns
Corners of a right-angled outline from the length of each edge and a left or right turn at each corner.
pᵢ₊₁ = pᵢ + dir × lengthᵢ; dir turns by ±90°
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Outline from typed walls
Corners and arcs of an outline from typed wall lengths, directions and arc radii.
next = p + len × (cos θ, sin θ); arc chord = 2 r sin(|sweep| ÷ 2)
Room outline, walls and openings addons/cabinetcraft/lib/room.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Room outline from a host model, cleaned
Drops repeated and in-line points from a room outline given by the host app and makes it counter-clockwise.
drop b when |ab| < 1 or |(b − a) × (c − b)| < 1e-3 × max(1, |ab| × |bc|)
Room outline, walls and openings addons/cabinetcraft/lib/fromroom.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Host room moved to (0, 0) and rounded
Shifts the host's outline so its lower-left corner is the origin and converts it to the job unit.
mm job: round(v × 10) ÷ 10; inch job: round(v ÷ 25.4 × 16) ÷ 16
Room outline, walls and openings addons/cabinetcraft/lib/fromroom.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Host doors and windows onto the nearest wall
Puts each door or window of the host model on the room wall nearest its middle, with its offset along that wall.
s = (p − a)·u; off = |(p − a) × u|; at = clamp(s − w ÷ 2, 0, len − w)
Room outline, walls and openings addons/cabinetcraft/lib/fromroom.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Room point back in the host's axes
Converts a point in the room's own axes to millimeters in the host model.
X = ox + x × k, k = 25.4 for an inch job, else 1
Room outline, walls and openings addons/cabinetcraft/lib/fromroom.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Island frames
The origin and axes of each island's front row and back row.
u = (cos a, sin a), a = rot × π ÷ 180; back row origin = o + u × len
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Layout tolerance and largest automatic filler
The two limits the layout compares against.
tol = 0.01; maxFiller = conv(75, unit)
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
End-face swing of a cabinet on a bay
How far the end face of a straight cabinet on a curved bay swings toward the neighboring run.
tilt = d × sin(atan2(w ÷ 2, √(r² − w² ÷ 4)))
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Is a corner a right angle
Decides whether a corner cabinet fits a room corner.
square when |turn − 90| < 0.01 degrees
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Where the later run stops at a corner
How far short of a room corner a run stops so it clears the run on the other wall.
stop = flat + tilt(A) + tilt(B) + flat² ÷ (2r); flat = other run's depth at 90°
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Wedge filler triangle at an angled corner
The three corners of the triangular void left where two runs meet at an angle that is not 90 degrees.
tri = [corner, corner ± u × leg1, corner + n × depth]
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Automatic filler width
The width of the filler that closes the gap between the last cabinet and the end of the span.
rest = end − start − used; filler = rest when tol < rest ≤ maxFiller
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Position of each cell along its run
The distance from the start of the wall to each cabinet, filler and end panel.
xᵢ₊₁ = xᵢ + wᵢ; stored xᵢ rounded to 6 decimals
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
First cabinet on a curve moved clear of the previous run
On a curved wall that starts at a room corner, how far the first cabinet is moved along so it does not overlap the previous run's last cabinet.
bisection on [0, 600 mm], 40 halvings; clash when overlap > 1e-6
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Straight countertop length and width
The length and width of a countertop over a straight run of base cabinets.
length = x₁ − x₀ + overhang at each open end; width = depth + front overhang + seat
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Countertop on a curved wall
The outline and area of a one-piece countertop that follows cabinets stepped along a curved wall.
area = |Σ (xᵢ yᵢ₊₁ − xᵢ₊₁ yᵢ)| ÷ 2
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Corner cabinet countertop
The outline and area of the countertop over a corner cabinet.
area = shoelace of the outline; length = width = √area
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Extent of a cell along its wall
The stretch of wall each cell covers, used to test it against doors and windows.
curved wall: min and max of (corner − a)·u; straight: [x, x + w]
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
End panel height
The height of an end panel beside a cabinet.
height = cabinet height − kick height
Cabinet run layout and countertops addons/cabinetcraft/lib/project.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Wall frame to room coordinates
Turns a distance along a wall and a distance out from it into a room point.
p = o + u × s + n × o′
Cabinet run layout and countertops addons/cabinetcraft/lib/footprint.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Floor footprint of each cell
The polygon each cabinet and end panel covers on the floor, its bounding box and its height range.
Cabinet run layout and countertops addons/cabinetcraft/lib/footprint.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
How far two footprints overlap
The penetration depth of two convex polygons, 0 when they are apart or only touch.
for each edge normal n: overlap = min(a₁, b₁) − max(a₀, b₀) of the projections; result = smallest overlap
Cabinet run layout and countertops addons/cabinetcraft/lib/footprint.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Gap between two rectangles
The distance between two axis-aligned rectangles.
gap = √(dx² + dy²), dx and dy the clear distances on each axis, 0 when they overlap on it
Cabinet run layout and countertops addons/cabinetcraft/lib/footprint.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Gap between two sets of convex polygons
The smallest distance between two footprints made of convex pieces, 0 when they touch or overlap.
Cabinet run layout and countertops addons/cabinetcraft/lib/footprint.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
One cabinet in plan
The cabinet seen from above in its own frame, with its fronts, number and width label.
W = w × k; D = d × k; label = round(w × 100) ÷ 100
Cabinet plan, elevation, section and 3D boxes addons/cabinetcraft/lib/draw.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Front view of a run
Each cabinet's box, plinth and fronts along the run, x along the wall and y up from the floor.
X = x × k; front at (X + f.x × k, base + f.y × k)
Cabinet plan, elevation, section and 3D boxes addons/cabinetcraft/lib/draw.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Frame of a run from two wall points
The origin, angle and length of a run picked by two points on a wall and a point in the room.
len = √(Δx² + Δy²); left = (room − a) × u; ang = atan2(u_y, uₓ)
Cabinet plan, elevation, section and 3D boxes addons/cabinetcraft/lib/draw.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Point in a run's frame
The distance along a run and out from the wall of a point.
s = Δx cos a + Δy sin a; off = −Δx sin a + Δy cos a
Cabinet plan, elevation, section and 3D boxes addons/cabinetcraft/lib/draw.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
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.