How the firmware turns a chosen quantum state into the (x, y, z) points a frame actually draws — every draw, lookup, and coordinate transform that runs per point or per element switch.
Both pipelines below start from tables that already exist — the flash-resident hydrogen samplers (built host-side in Python; see the companion diagram), the compile-time angular tables, the flash-resident atomSFE radial rows, and the Clementi–Raimondi constants. Dashed boxes mark that given data; solid boxes are operations this pipeline performs. How the hydrogen tables themselves get built is covered in Coefficients to Tables; the atomSFE rows' provenance and the hydrogenic/Z_eff fallback model live in ATOMS.md (§5) and pc/RUN_HFS.md.
src/physics/pointcloud.h · orbital_presets.cpp — repeated kOrbitalNumPoints times per preset
Given — OrbitalSampler(n, ℓ, m)
Three independent inverse-CDF tables — Fr−1, Fθ−1, Fφ−1 — already built so that sampling each marginal on its own reproduces this joint density exactly.
invRTable / invThetaTable / invPhiTable1 · Draw three uniforms
A fixed-order PRNG draw per axis — same seed, same three numbers, in every port (C++ / MicroPython / JS).
XorShift32::uniform01()2 · Invert through the table
T is one of the 1001-entry tables above; i = ⌊u·(N−1)⌋ is the table index just below u, and η = u·(N−1) − i is the fractional remainder used to blend T[i] toward T[i+1]. One interpolated read per axis, O(1) — no rejection loop, no per-point search, so every point costs exactly the same.
getValueFromLookupTable()3 · Spherical → Cartesian
The point's position is fixed here — everything after this only decides its color.
sampleOrbitalPoint()4 · Evaluate ψ at that point
bk are the radial polynomial's coefficients (from the associated Laguerre polynomial, one fixed set per (n,ℓ)) and cj are the angular polynomial's coefficients (from the associated Legendre polynomial, one fixed set per (ℓ,m)) — the same arrays already used to build the sampler tables above (same b/c naming as Coefficients to Tables), just re-evaluated at this one point instead of at every table entry.
psiReal()5 · Rank → brightness, sign → phase
Rank, not raw magnitude — ψ² is heavily right-skewed, so ranking spreads brightness evenly instead of crushing most points into the dim end. M is the cloud's point count (kOrbitalNumPoints), not the 1001-entry table size N; Lmin = 80, Lmax = 255.
computeOrbitalLevels() / orbitalLevelToColor565()6 · Auto-zoom from the whole cloud
ptarget = 100 px. Every preset — 1s or 6p — fills the same on-screen radius, so switching orbitals never means "just a dot far away".
scaleFromRadii()src/physics/atom_cloud.cpp · slater.h · hfs_radial.h — runs once per Z, not per frame
Given — tables for this Z
The atomSFE rows come from the SPARC-atomSFE Kohn–Sham solver (LDA_SVWN) — see ATOMS.md §5 and pc/RUN_HFS.md.
1 · Ground-state configuration
Cr, Cu, Nb, the lanthanide/actinide anomalies, etc. override the naive fill rule where the real atom disagrees with it.
electronConfiguration()2 · Expand each subshell into drawing groups
Full — occ = 2(2ℓ+1)
Partial — Hund's rule
Full-shell density is exactly spherical (Unsöld's theorem) — only a partial shell needs per-orbital treatment. Without this split, carbon's 2p² would render spherical, which it isn't.
drawingGroups() / hundFillM()3 · Split the point budget
N is this element's total point budget (kAtomNumPoints). Largest-remainder method afterward, so the per-group counts sum to exactly N — not "close to it".
splitCounts()4 · Pick this group's radial source
Table available — Z≤92
Fallback — hydrogenic
Clementi–Raimondi where the table has it (Z≤54); otherwise Slater's shielding rule (0.35/0.85/1.00) with the n* correction that keeps heavy elements from being systematically too big.
hfsRLookup() / slaterZEff() / zEffRadial()5 · Build this group's radial inverse-CDF
Isotropic group (full subshell)
Oriented group (Hund's rule)
Both branches invert density ∝ [r·R(r)]² (u = r·R, so u² is the same quantity); they differ in the grid. The isotropic branch integrates the table's own grid directly; the oriented branch re-samples R on an even grid first — an asymmetry deliberately kept from the Python model (hfs_radial.h). The hydrogenic fallback branch always uses the even-grid sweep.
buildHfsRadialSamplerIsotropic() / buildHfsRadialSamplerOriented() / buildRadialSamplerRuntime()6 · Sample this group's points
Isotropic group
Oriented group (m fixed)
Which branch a group takes was already decided back in step 2 — isotropic groups draw a uniform direction, oriented groups draw θ and φ from that (ℓ, m)'s own angular tables.
sampleIsotropicPoint() / sampleOrientedPoint()7 · Measure each subshell's reach
8 · Color by shell, emphasize valence
Points in every other subshell are dimmed instead — otherwise the valence subshell, often a small minority of the point budget, disappears visually. Points are emitted in contiguous per-subshell runs (AtomSubshellRange), so this is one lerp per subshell, not per point.
colorizeAtomSubshells()9 · Calibrate and fit to screen
The κZ multiply happens inside buildAtomPointCloud: it scales the whole cloud so the valence subshell's mode radius lands on the Clementi–Raimondi literature value — it mainly keeps the pm scale bar and dissection depths consistent, since scaleForAtom renormalizes on-screen size anyway. That target-pixel-radius idea (same as the orbital pipeline's step 6) keeps lithium and uranium both legible on a 240px screen, at the cost of the real size trend between elements.
scaleForAtom() / kAtomSizeCalibFactor