interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / design / boot / MATHS.md

206 lines · 11658 bytes Raw Blame History Source

The night, as maths

The boot reference (night.html, this folder) and the kernel draw the same night. This page writes every step as an equation, with the kernel line it comes from, so a port to any framebuffer needs no guessing.

Source: native/kernel/ui/night.c, chirp.c, paint.c, allen_ui.c on feat/allen-boot-everywhere (L266 milestone 1, byte-identical to the iMac's aienos_commit 0930240). The kernel is integer-only; the sketch uses floating point. Where they differ it is said below.

1. Space and time

ConstantmsKernel
holes appear2600CK_NIGHT_HOLES_MS
spiral begins6000CK_NIGHT_SPIRAL_MS
fade-in ends6800CK_NIGHT_FADE_END_MS
merger12000CK_NIGHT_MERGE_MS
ripple run3600CK_NIGHT_RIPPLE_MS
last hole gone15200CK_NIGHT_GONE_MS
wide orbit, one turn5200ORBIT_MS (night.c 371)

2. Noise (paint.c)

The sketch ports these bit for bit (JavaScript Math.imul), so every star sits where the kernel puts it.

3. The sky, made once

3.1 The Milky Way band (night.c 72)

A line from (−W/20, 0.90·H) along (1.10·W, −0.92·H), half-width h₀ = 0.16·H. For a point: across = ((x−x₀)·dy − (y−y₀)·dx)/len, along = ((x−x₀)·dx + (y−y₀)·dy)/len.

3.2 The soft layer at a quarter resolution (night.c 97)

On the grid x = 4i, y = 4j, with n₁ = fbm(768x/H, 768y/H, 101, 5), n₂ = fbm(1792x/H, 1792y/H, 202, 4):

Scaled to full size bilinearly with a 4 × 4 Bayer dither added before dropping to 8 bits (night.c 140), so the faint gradients show no bands.

3.3 Stars (night.c 170)

Every star is a glow: added light a · (1 − d²/r²)³ inside radius r, colour by hash % 100: <10 (170,192,255), <55 (218,228,255), <85 (255,250,242), <97 (255,234,196), else (255,204,160).

PopulationCountPositionKept whenLevel lv / radius
fieldW·H/800hash(i,1|2,77) in 16thshash(i,3,77)&65535 ≤ 36000 + 29535·gauss(across, h₀)14 + 241·u⁴/2³², u = hash(i,4,77)&255; r = (20 + 16·lv/255)·k/256 16ths
dustW·H/170hash(i,6|7,78)hash(i,8,78)&65535 ≤ gauss(across, 0.8h₀)²10 + hash(i,9,78)%44, r = 20k/256 16ths, colour (226,230,255)
brightclamp(W·H/50000, 24, 256)hash(i,1|2,91)always190 + hash%66, r = 34k/256; plus a halo of 5r at level 22; they twinkle (§4.7)

3.4 Galaxies (night.c 221)

Six, from gdef (position in thousandths, radius in design px, tilt, turn, kind, brightness). Per pixel, rotate by turn, unflatten by cos(tilt) (at least 600/16384), radius ρ in 256ths of the galaxy's own:

3.5 When each part of the sky comes out of the dark (night.c 296)

On a 4 × 4 cell grid: appear = (6·fbm(640x/H, 640y/H, 909, 4)/256 + 4·255·|p − C|/far)/10, far = the farthest corner.

4. Each frame

4.1 Coming out of the dark, 0 to 6.8 s (night.c 314)

For a pixel of brightness l (its largest channel, 0..255): starts at t₀ = 300 + 12·appear + 8·(255 − l) ms, then smooth((t − t₀)/1365). Bright stars come first, faint sky last, in patches spreading from the centre.

4.2 The orbit (night.c 373)

Wide separation a₀ = S(270) px. Angle in turns:

Integer form: L^⅛ by three integer square roots of a Q30 number (root8); L^¼ = r², L^⅝ = r⁵.

4.3 Each hole grows in (night.c 400)

Einstein radius E = S(60)·smooth((t − 2600)/2600); shadow radius r_s = S(20)·smooth((t − 4000)/2000).

4.4 Bent light (night.c 480)

A point lens moves the image at angle θ from a hole to where the star really is: β = θ − E²/θ. Per pixel p, for each hole at h: d = p − h; if |d|² < (4.4E)², the sky is sampled at p − d·f with f = E²/|d|² (|d|² at least 1/4 px²), eased to zero between 2.2E and 4.4E by ((19.36E² − |d|²)/(14.52E²))². Both holes' pulls add. Stars behind a hole stretch into arcs and a second image appears on the far side.

The kernel works this out exactly within max(E, 1.5r_s) + 8 px of a hole and on an 8-pixel grid, bilinearly interpolated, elsewhere in the bent region (night.c 568). The sketch works it out exactly everywhere; the arcs are a little sharper (receipts, §6).

4.5 Shadow and photon ring (night.c 523)

Inside 1.5·r_s: darken to black with a half-pixel soft edge at r_s; add (255,228,196) at (22 − 16·|r − 1.04r_s|)·6/256 (a ring about 1.4 px wide just outside the shadow) plus a glow 46/256 · (1.5r_s − r)/(0.5r_s) between r_s and 1.5r_s.

4.6 Merger, ring-down and the ripple (night.c 412, 436)

4.7 Twinkling (night.c 629)

Each bright star adds a glow of radius 2·34k/256 16ths at ((1 + sin 2π(t + phase)/period)/2)² · 120/256, period 2.6 to 6.8 s, scaled by its fade-in; skipped where the lens region covers it.

4.8 The merger's flash (allen_ui.c 437)

12.0 s to 13.6 s: radius S(40) + S(220)·easeOut(t/1200) with easeOut(x) = 1 − (1 − x)³, strength smooth(t/120)·exp(−max(0, t − 120)/450)·0.9. Two glows at C: (200,210,255) at strength/3 and (255,240,224) at a third of the radius. From 100 ms the remaining hole's shadow takes its black back over 300 ms.

5. The chirp (chirp.c)

48 kHz, one channel copied to both. T = 600 ms before the merger, L the share of it left.

The kernel builds a 4096-entry sine table by rotation and works in Q30 (chirp.c); the sketch uses Math.sin.

6. Receipts

Commands run from the repository root on the Spark, 2026-10-20. Kernel frames come from the design skill's render_night.c built against the L266 sources (git archive origin/feat/allen-boot-everywhere native/kernel/ui).

6.1 The sketch matches the kernel

ffmpeg -i <sketch>.png -i <kernel>.ppm -lavfi psnr (8-bit RGB, 1920 × 1080; higher is closer; 48 dB is about one level of 255 on average):

t (ms)whole frame (dB)centre 480 × 360 around the holes (dB)
150085.4not measured
400051.444.9
900056.649.9
1180057.349.9
1400051.049.1
1600059.8not measured

OBSERVED. The flash (12.0 to 13.6 s) is drawn by allen_ui.c, not night.c, so these frames avoid it; it is checked by eye only.

6.2 Frame time per stage

See receipts/frame-times.md.

7. Not in this sketch

8. PROPOSAL, not shipped: closer to the physics

The aien-design-language skill asks for real astrophysics. The night as shipped is a faithful look, not a simulation. If Drake wants it closer, these are the changes, for L266 to weigh (none is in the sketch or the kernel):

  1. Shadow size from the lens: for a non-spinning hole the shadow radius is √27/2 Rs ≈ 2.6 Rs. Today r_s = S(20) and E = S(60) are set independently; tying r_s to the mass that sets E would keep their ratio physical.
  2. The ring-down frequency and damping from the merged mass (today 95 ms period and 260 ms decay, chosen by eye).
  3. Real stars: positions, magnitudes and B−V colours from a public catalogue (Hipparcos or Tycho-2) instead of hashed stars, as the brand-art renderer already plans.
  4. The chirp's time stretch stated as a factor in the science doc (a real 30-solar-mass merger sweeps through this band in well under a second; the 600 ms here is chosen).