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
-
Clean-up after an event
Merges corners that met, removes edges folded onto each other as ridges, splits a loop a corner has cut, and closes loops with no area left.
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-skeleton.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Shared part of two folded edges
The stretch two opposite edges on one line have in common, which becomes a ridge.
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-skeleton.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Face boundaries chained into polygons
Joins the boundary pieces of a face into closed loops.
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-skeleton.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Collinear points removed from a face
Drops points of a face polygon that lie on the line between their neighbors.
removed when |u × v| ÷ max(|u|, |v|) ≤ tolerance
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-skeleton.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Roof lines joined end to end
Joins the pieces of one ridge, hip or valley into a single line.
joined when ends meet within tolerance and cos θ ≥ 1 − 1e-9
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-skeleton.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Faces kept
Builds each face's plan polygon and drops slivers.
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-skeleton.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Polygon area
The signed plan area of a polygon.
A = ½ Σ (xᵢ yᵢ₊₁ − xᵢ₊₁ yᵢ)
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-skeleton.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Distance from a point to a segment
The shortest distance from a plan point to a segment.
t = clamp((p − a)·d ÷ |d|², 0, 1); distance = |p − a − d t|
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Eave line and edge speeds
Moves each wall line out to the eave and sets how fast and from what height each roof edge rises.
out = overhang − fascia thickness; speed = 1 ÷ tan(pitch); start = plate − out × tan(pitch)
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Slope and pitch of each face
The slope and the pitch in degrees stored on each roof face.
slope = 1 ÷ speed; pitch = atan(1 ÷ speed) in degrees
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Ridge, hip or valley
Decides what each roof line is and measures its length.
len = √(Δx² + Δy² + Δz²)
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Eave and rake edges
Finds the face edges that lie on the eave line, tells level eaves from sloped rakes, and measures them.
top height = face height + thickness ÷ cos(pitch)
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Soffit height
The level of the soffit under each pitched eave.
z_eave = plate − out × tan(pitch); z = min(z_eave, z_eave + thickness ÷ cos(pitch) − fascia)
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Roof area and line totals
The roof's sloped area, its plan area, and the total length of ridges, hips, valleys, eaves and rakes.
area = Σ |plan area of face| ÷ cos(pitch)
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Outline moved out by the overhangs
The polygon with each edge moved out by its own distance.
corner = p₀ + u_prev × ((p₁ − p₀) × u) ÷ (u_prev × u)
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Eave line crosses itself
Checks that the eave polygon does not cross itself and runs anticlockwise.
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Roof height over a point
The height of the roof's underside above a plan point.
Roof faces, ridges and areas from an outline addons/trusscraft/lib/bim/res-roofplan.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Edges split where they cross or overlap
Finds where two wall edges cross, touch or run along each other.
t = (c − a) × s ÷ (r × s); u = (c − a) × r ÷ (r × s)
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Points matched on a grid
Decides when two split points are the same point.
key = (round(x ÷ 0.001), round(y ÷ 0.001))
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Boundary pieces
Keeps the pieces that have a wall on one side and open space on the other.
test points = middle ± n × min(0.5, length ÷ 4)
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Next piece at a joint
Chooses which boundary piece a loop follows where several meet.
a = (angle back − angle of piece), brought into (0, 2π]
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Room area and perimeter
Tells rooms from islands and gives each room its net area and full perimeter.
area = loop area − Σ hole areas; perimeter = loop + Σ hole perimeters
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Polygon area
The signed area of a loop.
A = ½ Σ (xᵢ yᵢ₊₁ − xᵢ₊₁ yᵢ)
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Polygon perimeter
The length round a loop.
P = Σ √(Δx² + Δy²)
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Polygon centroid
The center of area of a loop.
C = Σ (a + b)(a × b) ÷ (3 Σ a × b)
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Label point inside a room
A point well inside a room for its label.
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Point inside a polygon
Tests whether a plan point lies inside a polygon.
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Repeated and collinear points removed
Tidies a loop before its area is taken.
collinear when |ab × bc| ≤ 1e-7 × (|ab| |bc| + 1e-12)
Rooms and building outline from walls addons/trusscraft/lib/bim/model-rooms.js64-bit- CadCraft
- BimCraft
- ModelCraft
- PartCraft
-
Velocity beyond a wall
The value used just outside the region so that the velocity at a wall equals the wall's own.
u_ghost = 2 × u_wall − u_inside
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Value at a cell face
The value carried across a cell face by the flow.
central ½(a + b) when |u| h ÷ ν ≤ 2, else the upwind value
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Time step
The largest stable time step for the current velocities.
dt = min(0.4 h ÷ u_max, 0.2 h² ÷ ν, 0.8 ν ÷ u_max²)
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Momentum step for u
The predicted x velocity at each face after one time step.
u* = u + dt (−convection + ν ∇²u + source)
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Pressure equation
Sets up the pressure equation that makes the velocity field divergence-free.
∇²p = (∇·u*) ÷ dt
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Pressure solve
Solves the pressure equation by conjugate gradient.
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Velocity correction
Removes the pressure gradient from the predicted velocities.
u = u* − dt (p_right − p_left) ÷ h
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Tracer transport
Moves a tracer with the flow and lets it diffuse, one time step.
limiter φ(r) = (r + |r|) ÷ (1 + |r|); C′ = C − dt (∇·flux) + dt × source
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Run to a steady state
Steps the flow until it stops changing or a limit is reached.
change = max |u′ − u| ÷ dt
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Velocity at cell centers
The velocity at the center of each cell.
u_c = ½(u_left + u_right); v_c = ½(v_bottom + v_top)
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Velocity at a point
The velocity at any point of the region.
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Stream function
The stream function at the cell corners.
ψ(i, j) = ψ(i, j − 1) + U(i, j − 1) × h_y
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
VTK export
Writes velocity, pressure and tracer fields as a legacy ASCII VTK file.
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Mixing time
The time at which a tracer's spread falls below a target.
CV = √(Σ (c − mean)² ÷ n) ÷ mean
2D flow solver (finite volume) cfd/fv.js64-bit- CadCraft
-
Lattice directions and weights
The nine directions of the lattice and the weight of each.
w = 4/9, 1/9 (×4), 1/36 (×4)
2D mixing solver (lattice Boltzmann) cfd/lbm.js64-bit- CadCraft
-
Mixer set-up
Creates the grid, the solid mask, the force field and the starting distributions.
2D mixing solver (lattice Boltzmann) cfd/lbm.js64-bit- CadCraft
-
Equilibrium distributions
The equilibrium the flow and the tracer relax toward.
f_eq = w ρ (1 + 3 c·u + 4.5 (c·u)² − 1.5 u²); g_eq = w C (1 + 3 c·u)
2D mixing solver (lattice Boltzmann) cfd/lbm.js64-bit- CadCraft
-
Collision step
Density, velocity and tracer value of each cell, and the relaxation of its distributions.
ρ = Σ f; u = (Σ f c + ½ F) ÷ ρ; f ← f − (f − f_eq) ÷ τ + source
2D mixing solver (lattice Boltzmann) cfd/lbm.js64-bit- CadCraft
-
Outlet condition
Sets the last column of a flow-through box from its neighbor.
f_out = f_eq(1, u_nb) + (f_nb − f_eq(ρ_nb, u_nb))
2D mixing solver (lattice Boltzmann) cfd/lbm.js64-bit- CadCraft
-
Velocity at a point
The velocity reported at a position in the grid.
2D mixing solver (lattice Boltzmann) cfd/lbm.js64-bit- CadCraft
-
Result fields
A copy of the velocity, speed, density or tracer field for reading or plotting.
speed = √(u_x² + u_y²)
2D mixing solver (lattice Boltzmann) cfd/lbm.js64-bit- CadCraft
-
Mixing time
The number of steps until the tracer is evenly spread.
deviation = max |C − mean|; reached when deviation ≤ level × starting deviation
2D mixing solver (lattice Boltzmann) cfd/lbm.js64-bit- CadCraft
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.