code wiki / (root) / nx_skinspectra_lib.nx

nx_skinspectra_lib.nx

buildroot/runtime/nx_skinspectra_lib.nx

8305 B188 linesdepth 3pulls 5 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_skinspectra_lib.nx -- MEASURED ABSORPTION SPECTRA, PARSED NOT TRANSCRIBED (2026-09-03, rung ST6) WHY PARSING AND NOT A TABLE OF CONSTANTS. Every coefficient on /compare/skintwin was a PROBE VALUE, and pinning the published spectra was supposed to fix that. It nearly fixed it the wrong way: the obvious move is to read the mirrored table and copy numbers into a conf. That is transcription, and transcription is exactly the failure this rung exists to remove -- MEASURED THE SAME DAY, the probe melanin coefficients carried a blue-to-red ratio of 5.0 against the published law's 2.72, so the shape was right and the slope was 1.8x too steep. A number typed by hand is a number that can be wrong. A number parsed out of a sha-pinned mirror is the mirror's responsibility. SO THE ONLY VALUES TYPED HERE ARE THE ONES THE PUBLISHED LAW ITSELF STATES -- 1.70, the decade count 12, the exponent 3.48, and the source's own conversion constants 2.303 and 64500 -- each written as it appears in the source rather than pre-multiplied. The haemoglobin numbers are never typed at all; they are read from the mirror at run time. SOURCES, BOTH MIRRORED AND PINNED (skintwin.refs): MELANIN [@omlc_mel] Jacques and McAuliffe 1987; Jacques, Glickman and Schwartz 1996. Melanosome absorption measured by the threshold for explosive vaporization under pulsed lasers. Fitted spectrum for skin: mua = 1.70e12 * lambda^-3.48 [cm-1], lambda in nm. HAEMOGLOBIN [@omlc_hb] Prahl, compiled from Gratzer (MRC Labs, London) and Kollias (Wellman Labs, Harvard Medical School). Tabulated MOLAR EXTINCTION e in [cm-1/(moles/litre)], converted by the source's own formula mua = 2.303 * e * x / 64500, x in grams of haemoglobin per litre. THE PREFACTOR IS A DISTRIBUTION, NOT A CONSTANT, AND THE SOURCE SAYS SO IN ITS OWN WORDS: "The concentration of melanin within melanosomes is quite variable. Ten-fold variation is to be expected." So ss_melanin_mua returns the LAW at unit concentration and takes concentration as a caller argument. A lib that folded a tenfold-variable quantity into a fixed coefficient would publish a constant wearing a measurement's clothes. NUMERICAL NOTE THAT MATTERS: 1.70e12 is far outside Q30 and must never exist as a value. mua is computed as ONE exponential of (ln 1.70 + 12 ln 10 - 3.48 ln lambda), so the huge prefactor is never materialised and the result lands in range at every visible wavelength. MEASURED: 993.73 / 494.30 / 365.16 per cm at 450 / 550 / 600 nm, and the prefactor-free ratio reproduces (600/450)^3.48 = 2.721365 EXACTLY. license_tier: ORIGINAL No hw writes (Rule 26). LIB (no main).

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_fixq30_lib.nx nx_skinspectra_lib.nx nx_skinspectra_gate.nx

imports: nx_syscalls.nxnx_fixq30_lib.nx

imported by: nx_skinspectra_gate.nx

structs

none

consts

38const SS_REFUSED: i64 = 0 - 1
40const SS_MEL_PREFACTOR_MILLI: i64 = 1700 // 1.70, carried at 1/1000
41const SS_MEL_DECADES: i64 = 12 // the 10^12
42const SS_MEL_EXP_MILLI: i64 = 3480 // 3.48, carried at 1/1000
43const SS_MILLI: i64 = 1000
44const SS_TEN: i64 = 10
46const SS_HB_LN10_MILLI: i64 = 2303 // 2.303, carried at 1/1000
47const SS_HB_GRAM_MOLE: i64 = 64500 // grams per mole of haemoglobin, stated by the source
50const SS_LAMBDA_MIN: i64 = 250
51const SS_LAMBDA_MAX: i64 = 1000
52const SS_BOX: i64 = 8
53const SS_DIG0: i64 = 48
54const SS_DIG9: i64 = 57
55const SS_SPACE: i64 = 32
56const SS_TABCH: i64 = 9
57const SS_NL: i64 = 10

functions

60func ss_melanin_mua(fq: *i64, lambda_nm: i64) -> i64
71func ss_melanin_mua_at(fq: *i64, lambda_nm: i64, conc: i64) -> i64
called by 1: main calls 2: ss_melanin_muafq_mul
79func ss_hb_mua(e_molar: i64, grams_per_litre: i64) -> i64
called by 1: main
87func ss_int_at(buf: *u8, n: i64, p: i64, box: *i64) -> i64
called by 1: ss_hb_lookup
115func ss_skip_ws(buf: *u8, n: i64, p: i64) -> i64
called by 1: ss_hb_lookup
133func ss_line_end(buf: *u8, n: i64, p: i64) -> i64
called by 1: ss_hb_lookup
150func ss_hb_lookup(path: *u8, lambda_nm: i64, out2: *i64) -> i64