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
-
Ports of an item
Where an item's in, out and vehicle ports are in its own frame, with their headings.
Material flow layout geometry addons/flow/lib/catalog.js64-bit- ModelCraft
-
Parameter limits
Clamps each numeric parameter to its minimum and maximum and rounds whole-number parameters.
n = min(max, max(min, v)); whole numbers: round(n)
Material flow layout geometry addons/flow/lib/catalog.js64-bit- ModelCraft
-
Reading a layout
Checks the positions, rotation, fleet and run settings of a saved layout.
x, y, z: kept if finite and |v| < 1e6, else 0; rot = ((rot mod 360) + 360) mod 360
Material flow layout geometry addons/flow/lib/layout.js64-bit- ModelCraft
-
Local point to world
Turns a point in an item's own frame by the item's rotation and moves it to the item's position.
x′ = x cos r − y sin r + item x; y′ = x sin r + y cos r + item y; heading = ((h mod 360) + 540) mod 360 − 180
Material flow layout geometry addons/flow/lib/layout.js64-bit- ModelCraft
-
Placing an item on a port
The position and rotation that put one of an item's ports on a given point with a given heading.
rot = ((H − port heading) mod 360 + 360) mod 360; position = P − rotated port offset
Material flow layout geometry addons/flow/lib/layout.js64-bit- ModelCraft
-
Which ports are joined
Finds the out and in ports that touch, and merges vehicle path ends into nodes.
joined when |Δx|, |Δy|, |Δz| ≤ 0.01 m and |Δheading| ≤ 1°; path ends merge when each |Δ| ≤ 0.05 m
Material flow layout geometry addons/flow/lib/layout.js64-bit- ModelCraft
-
Snap an item to the nearest free port
Moves an item so one of its free ports sits on the nearest matching free port within a radius.
d = √(Δx² + Δy² + Δz²); nearest pair with d ≤ radius (0.5 m by default)
Material flow layout geometry addons/flow/lib/layout.js64-bit- ModelCraft
-
Lengths and times handed to the simulation
Turns each conveyor into its length, speed and gap, and breakdown times from hours and minutes into seconds.
zone length = zones × zone length; mtbf (s) = hours × 3600; mttr (s) = minutes × 60
Material flow layout geometry addons/flow/lib/layout.js64-bit- ModelCraft
-
Where a load is drawn on a belt
The distance along a belt at which a load is drawn at a given time.
accumulating: s = min(v × t + c, S); stopping belt: s = D(t) − D at entry; drawn at max(0, s) + L ÷ 2
Material flow drawing and playback addons/flow/lib/playback.js32-bit, display only- ModelCraft
-
Where a vehicle is drawn
A vehicle's point on its path segment at a given time.
f = (t − t₀) ÷ (t₁ − t₀); point = path at f × length
Material flow drawing and playback addons/flow/lib/playback.js32-bit, display only- ModelCraft
-
Belt strips
The boxes drawn for a conveyor between points sampled along its path.
pieces = max(4, ceil(|angle| ÷ 10)) for a curve, else 1; length = √(run² + Δz²); turn = atan2(Δy, Δx)
Material flow drawing and playback addons/flow/view.js32-bit, display only- ModelCraft
-
Loads and vehicles as instanced boxes
Sets the position, turn and size of each load and vehicle box for one frame.
Material flow drawing and playback addons/flow/view.js32-bit, display only- ModelCraft
-
Shortest turn between two directions
The quaternion that turns one unit vector onto another.
q = (u × v, 1 + u · v), made unit
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
Two-bone reach
Where the elbow and the end of a two-bone chain go so the end reaches a target.
cos A = (L₁² + d² − L₂²) ÷ (2 L₁ d); sin A = √(1 − cos² A); elbow = a + dir × L₁ cos A + n × L₁ sin A
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
Chain of three or more bones (FABRIK)
Joint positions of a longer chain whose tip reaches for a target.
backward sweep from the target, forward sweep from the root, each joint kept its segment length from its neighbor
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
Point along a path by length
The point and direction a given fraction of the way along a polyline.
s = k × Σ segment lengths; walk the segments subtracting each length until s falls inside one
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
Point an axis at a direction
A matrix whose chosen axis points along a direction, with its up axis leaning to world +Z.
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
Blend by influence
Mixes two matrices by a factor from 0 to 1: place and size linearly, the turn along the shortest arc.
t = t_a + (t_b − t_a) k; s = s_a + (s_b − s_a) k; q = slerp(q_a, q_b, k)
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
IK on a rig
Builds the chain for an IK constraint, solves it and swings each bone so it runs to the next joint.
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
World matrix back to a local pose
Works a bone's local matrix back from a wanted world matrix through its parent.
local = (parent world × parent rest⁻¹ × rest)⁻¹ × wanted world
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
Constraints on placements
Applies look-at, copy, limit, child-of and follow-path constraints to placements in world coordinates and returns their new local matrices.
new local = blend(local, parent world⁻¹ × constrained world, influence)
Inverse kinematics and constraints anim/constraints.js64-bit- ModelCraft
-
World matrix of a placement
The product of the matrices of a placement and everything it sits in.
W = M₁ × M₂ × … × M_own
Inverse kinematics and constraints anim/cns-model.js64-bit- ModelCraft
-
A curve object's line in world coordinates
The polyline a follow-path constraint runs along.
Inverse kinematics and constraints anim/cns-model.js64-bit- ModelCraft
-
Canvas position to time and value
The time and value under a canvas point.
t = t₀ + (x − pad) ÷ (w − 2 pad) × (t₁ − t₀); v = v₀ + (h − pad − y) ÷ (h − 2 pad) × (v₁ − v₀)
Keys dragged in the graph editor anim/graph.js64-bit- ModelCraft
-
A key dragged to a new time and value
Moves a key in time and sets one number of its value.
time = max(0, round(t × 1000) ÷ 1000); value = v
Keys dragged in the graph editor anim/graph.js64-bit- ModelCraft
-
A handle dragged
The handle's new offset from its key in time and value.
Δt = t − key time (≤ 0 for the left handle, ≥ 0 for the right); Δv = v − key value
Keys dragged in the graph editor anim/graph.js64-bit- ModelCraft
-
A body from a placement
The center, half sizes and turn of the box or sphere that stands for a placement.
scale = lengths of the matrix columns; half = max(1e-4, half box × scale); sphere radius = largest half
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Rotation matrix to quaternion
The unit quaternion of a rotation given by its three axes.
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Placement matrix from a body state
The placement's world matrix for a simulated position and turn.
axes = q applied to X, Y, Z, times the placement's scale; origin = body center − rotated, scaled center offset
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Mass and inertia
The inverse mass and inverse moments of inertia of a box or a sphere.
sphere: I = 0.4 m r²; box: I_x = m (b² + c²) ÷ 12, and likewise for y and z
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Depth of a point inside a box
How far a point is inside a box and the outward normal of the nearest face.
local = q⁻¹ (p − center); depth = min over axes of (half + margin − |local|) − margin
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Positional correction
Pushes two bodies apart along a normal by a given distance, sharing it by their mass and inertia.
w = Σ (1 ÷ m + (r × n) · I⁻¹ (r × n)); λ = c ÷ w; x += n λ ÷ m; q += ½ (Δω, 0) q, made unit
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Step size and frame count
How many frames are recorded and how long one substep is.
frames = max(1, round((to − from) × fps) + 1); h = 1 ÷ fps ÷ substeps
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Integration of one substep
Advances each moving body's speed, position and turn by one substep under gravity.
v += g h; x += v h; q += ½ h (ω, 0) q, made unit
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Contacts and static friction
Pushes each touching point out of the surface and holds it still where friction can.
μ = √(μ_a μ_b); held when slide < μ |λ| × 1.5 + 1e-9
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Velocities from positions
Works each body's speed and spin back from how far it moved in the substep.
v = (x − x_prev) ÷ h; ω = 2 ÷ h × vector part of (q × q_prev⁻¹)
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Dynamic friction and bounce
Slows sliding at each contact and sets the speed a body leaves a surface with.
friction impulse = min(μ |λ| ÷ h, sliding speed ÷ inverse mass); leaving speed = −e × min(incoming normal speed, 0); e = 0 when |incoming| < 2 |g · n| h
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
Settled test
Says whether every body has come to rest at the end of the run.
settled when every |v| < 0.02 and every |ω| < 0.05
Rigid body simulation anim/physics.js64-bit- ModelCraft
-
4×4 matrix product
The product of two column-major 4×4 matrices.
Bone frames and pose matrices anim/rig.js64-bit- ModelCraft
-
4×4 matrix inverse
The inverse of a 4×4 matrix by cofactors.
M⁻¹ = adjugate(M) ÷ det(M)
Bone frames and pose matrices anim/rig.js64-bit- ModelCraft
-
A bone's rest frame
The matrix from a bone's own frame to the mesh: Y from head to tail, Z as near the mesh's +Z as it can be, turned by the roll.
y = (tail − head) made unit; z = (up − y (up · y)) made unit; x = y × z; roll turns x and z about y
Bone frames and pose matrices anim/rig.js64-bit- ModelCraft
-
Posed bone and skin matrices
Each bone's posed frame and the matrix that moves rest points to the pose.
W = W_parent × R_parent⁻¹ × R × local; skin = W × R⁻¹
Bone frames and pose matrices anim/rig.js64-bit- ModelCraft
-
Skin matrices as dual quaternions
Each bone's turn and move as a unit dual quaternion, for dual-quaternion skinning.
dual part = ½ × (t, 0) × q
Bone frames and pose matrices anim/rig.js64-bit- ModelCraft
-
A bone's pose from a drag
The location or rotation a bone gets when it is dragged in the view.
turn: angle swept round the bone's head on screen, about the view axis carried into the bone's frame; move: pixels × pixel size, along the camera's right and up, carried into the bone's frame
Bone frames and pose matrices anim/rig-view.js64-bit- ModelCraft
-
The four strongest bones per vertex
Keeps each vertex's four largest weights and scales them to add up to 1.
w_q = w_q ÷ Σ of the kept weights
Skin weights and skinning anim/rig.js32-bit in part- ModelCraft
-
Linear blend skinning
Moves each vertex to the weighted sum of its positions under its bones' matrices.
p′ = Σ wᵢ × (Mᵢ × p)
Skin weights and skinning anim/rig.js32-bit in part- ModelCraft
-
Dual quaternion skinning
Blends the bones' dual quaternions by weight, makes the result unit and moves the vertex with it.
(r, d) = Σ ±wᵢ (rᵢ, dᵢ); both divided by |r|; p′ = r p r⁻¹ + 2 d r⁻¹
Skin weights and skinning anim/rig.js32-bit in part- ModelCraft
-
Distance from a point to a bone
The distance from a vertex to the segment from a bone's head to its tail.
k = clamp(((p − a) · (b − a)) ÷ |b − a|², 0, 1); d = |a + (b − a) k − p|
Skin weights and skinning anim/weights.js64-bit- ModelCraft
-
Edge weights of the mesh
For each vertex, its neighbors and a weight for each edge, used to spread heat and to smooth.
edge weight = 1 ÷ max(1e-12, length²)
Skin weights and skinning anim/weights.js64-bit- ModelCraft
-
Automatic weights
Each bone's weight on each vertex, by bone heat or by distance, with faint weights dropped and each vertex's weights adding up to 1.
heat: solve (L + H) w = H p per bone, H = 1 ÷ nearest distance²; envelope: w = 1 ÷ d⁴ for bones within twice the nearest distance; drop w < 0.01; divide by the sum
Skin weights and skinning anim/weights.js32-bit in part- 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.