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.

  • 6,917 calculations in 1,248 source files
  • 143 exact
  • 6,286 in 64-bit
  • 335 with a 32-bit step
  • Last reviewed

Calculations

  • Event order

    Decides which of two queued events runs first.

    earlier time first; equal times: lower priority number first; then lower sequence number

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Time-weighted mean and maximum

    The mean and maximum over time of a queue length, a count of busy servers or an on/off state.

    area = Σ value × (time it held); mean = (area + value × (now − last change)) ÷ (now − start)

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Rounding of reported statistics

    Rounds a statistic to 6 decimals before it goes into the results.

    r6(x) = round(x × 10⁶) ÷ 10⁶

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Load type by weight

    Picks the type of a new load in proportion to the types' weights.

    u = random × Σ weights; subtract each weight in turn until u < 0

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Throughput and lead time at a sink

    Counts finished loads and works out loads per hour and the mean and maximum time from creation to the sink.

    lead = now − born; per hour = n ÷ span × 3600; mean lead = Σ lead ÷ n

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Station utilization, blocking and waiting

    The share of server time spent busy, blocked and idle, the mean queue and the mean wait at a station.

    utilization = mean busy ÷ servers; blocked = mean blocked ÷ servers; idle = 1 − (mean busy + mean blocked) ÷ servers; wait = Σ wait ÷ starts

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Gate cycle phase

    Whether a cycling gate starts open and when it first switches.

    period = open + closed; phase = ((0 − offset) mod period + period) mod period; open when phase < open

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Position of a load on a belt

    Where the tail of a load is now, on an accumulating belt or on a belt that stops as a whole.

    accumulating: p = min(v × t + c, S); stopping belt: p = D(t) − D at entry, D(t) = D₀ + v × (t − t₀)

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • When the next load can get on a belt

    The time at which the last load has moved far enough for the next one to enter.

    pitch = load length + gap (or the fixed zone pitch); accumulating: t = (pitch − c_last) ÷ v; stopping belt: t = now + (pitch − gap so far) ÷ v

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • A load gets on a belt

    Sets the two numbers that describe the new load's motion: where it is held back and where it stops.

    empty belt: c = −v × now (or less, to keep the pitch behind the load that just left), S = length − L; else c = min(−v × now, c_last − pitch), S = S_last − pitch

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • When the head load reaches the end

    The time the first load's head arrives at the end of the belt.

    accumulating: t = (length − L − c) ÷ v; stopping belt: t = t₀ + (D at entry + length − L − D₀) ÷ v

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Loads close up when the head leaves

    Works out again, for every load left on the belt, where it is held back and where it stops.

    first: c = min(−v × entry, length − L_gone − v × now − pitch), S = length − L; others: c = min(−v × entry, c_front − pitch), S = S_front − pitch

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • A belt starts again after a breakdown

    Shifts every load's timeline by the time the belt stood still.

    dur = now − time it stopped; c = c − v × dur; entry = entry + dur

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Photo-eye covered by a load

    Whether a load is over a sensor placed a given distance along a belt.

    covered when p − 1e-7 ≤ at ≤ p + L + 1e-7

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Shortest vehicle routes

    The shortest path distance from one path node to every other, used to pick the nearest idle vehicle and its route.

    Dijkstra: dist(to) = min over edges of dist(from) + edge length

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Vehicle travel time on a segment

    When a vehicle that enters a path segment reaches its end.

    t₁ = now + length ÷ speed

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Vehicle time shares and distances

    For each vehicle: the share of time in each state, the distance driven loaded and empty, and how busy it was.

    share = time in state ÷ span; busy = 1 − idle share − down share

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Run results

    Throughput per hour and the lead time count, mean, minimum, median, 95th percentile and maximum for the whole run.

    per hour = done ÷ span × 3600; mean = Σ lead ÷ n; percentile p = sorted[min(n − 1, floor(p × n))]

    Material flow simulation addons/flow/lib/sim.js
    • ModelCraft
    64-bit
  • Seeds from a string

    Turns the seed and a stream key into four 32-bit seeds.

    Random numbers and time distributions for material flow addons/flow/lib/rng.js
    • ModelCraft
    Exact
  • Uniform random number

    One number from 0 up to, but not including, 1.

    next = (32-bit state output) ÷ 4294967296

    Random numbers and time distributions for material flow addons/flow/lib/rng.js
    • ModelCraft
    64-bit
  • One time from a distribution

    A time in seconds drawn from a constant, uniform, exponential, Erlang, normal or triangular distribution.

    exponential: −mean × ln(1 − u); Erlang: −(mean ÷ k) × ln(Π (1 − uᵢ)); normal: mean + sd × √(−2 ln u₁) × cos(2π u₂); triangular: a + √(u (b − a)(m − a)) or b − √((1 − u)(b − a)(b − m))

    Random numbers and time distributions for material flow addons/flow/lib/rng.js
    • ModelCraft
    64-bit
  • Mean of a distribution

    The mean time of a distribution, as the panel shows it.

    uniform: (a + b) ÷ 2; triangular: (a + m + b) ÷ 3; others: the stated mean

    Random numbers and time distributions for material flow addons/flow/lib/rng.js
    • ModelCraft
    64-bit
  • Center line of a conveyor

    The length of a straight, zoned, inclined or curved conveyor and the point and heading at a distance along it.

    incline: L = √(length² + rise²); curve: L = r × |angle|, point = (r sin θ, ± r (1 − cos θ)), θ = s ÷ r

    Material flow layout geometry addons/flow/lib/catalog.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    32-bit, display only
  • 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.js
    • ModelCraft
    32-bit, display only
  • 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.js
    • ModelCraft
    32-bit, display only
  • 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.js
    • ModelCraft
    32-bit, display only
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • A curve object's line in world coordinates

    The polyline a follow-path constraint runs along.

    Inverse kinematics and constraints anim/cns-model.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit
  • 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.js
    • ModelCraft
    64-bit

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.