code wiki / (root) / nx_skull_canon_lib.nx

nx_skull_canon_lib.nx

buildroot/runtime/nx_skull_canon_lib.nx

56847 B936 linesdepth 5pulls 11 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_skull_canon_lib.nx -- THE GENERATED SKULL'S OWN RULER: craniometric landmarks on OUR skull and on the scanned oracle by ONE locator, compared in a landmark-defined frame, with bands measured off the resource (anatomy AN17, 2026-09-18). WHY: knowledge/status/skullfit_trend.jsonl scores the generated skull as millimetres per REGION against the oracle surface, and its regions are dominated by the vault and the base (n_ours 9,335 + 8,672 of about 31,000 samples), so a lumpy ovoid with a 49 mm muzzle reads "4 mm mean" and its nasal region reads n=0. This library measures the FACE: the craniometric landmarks that decide whether a skull reads as a skull (chin depth, the nasal aperture's position, height, width and depth, the orbits' centres, widths and depths, the bizygomatic and bigonial breadths, the prosthion, the bony thirds), each located by the SAME rule on both skulls, so every number is a difference between two measurements and never a difference between two definitions. COMPOSES, NEVER RE-IMPLEMENTS: the landmark locator is nx_tissuefield_lib.tfl_locate (midline-profile extrema by noise-floor prominence, support directions, rim crests); the mesh reader is its NXMSH2 welder (tfl_mesh_load); the frontal depth map is its tfl_front_at. Added here, because a face ruler needs them and the locator does not name them: (1) the opisthocranion (the point farthest from the glabella: maximum cranial length) and the euryons (the most lateral points above the brow) as chords and supports; the piriform aperture by its RIMS (rhinion and nasospinale on the midline, the lateral margins as rim crests walked by the locator's own tfl_crest rule) and the orbits by theirs (the locator's supraorbital, infraorbital and ectoconchion crests plus a medial crest walked here), so widths, heights and depths are rim-to-rim or rim-to-floor and a see-through hole reads DEEPER than any socket; (2) THE FRAME: a translation to the nasion and no rotation (skc_frame says why); the rotation it refuses to apply -- the glabella-opisthocranion chord's pitch -- is a measured quantity of its own; (3) THE BANDS: the locator's own noise, measured by re-locating on rigidly perturbed copies of the same mesh (a half-edge translation, a pitch and a yaw that move the vertex by one mesh edge), floored at the mesh's own resolution (a vertex set e apart cannot place a point better than e/2); a paired landmark adds the oracle's own bilateral asymmetry. Two further perturbations (a negative translation, a roll) are HELD OUT so a gate can ask whether the bands generalise instead of reading them back to itself; (4) THE MIDLINE RULES of tfl_locate with two changes, both measured on the scan and filed for the locator's owner: the aperture is the most PROMINENT minimum, never the smallest absolute z; the glabella is the most anterior point above the aperture floor and the pogonion the most anterior maximum below the prosthion (skc_midline_locate). FRAME CONVENTION: +y up, +z anterior, x lateral (nx_skullsdf emits so). The BodyParts3D oracle in knowledge/skull.nxmesh is stored anterior -z, exactly as nx_skullsdf's own tune (ss_load_ref) and gapmap read it, so skc_load(path, 1) negates z on load; a reflection through the coronal plane is a rotation by half a turn about y for a bilaterally symmetric skull, so widths and midline coordinates are unaffected and the pair names are read as a PAIR, never as sides. UNITS: the welder's u10 (tenths of a millimetre). LIB, no main. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_tissuefield_lib.nx nx_skull_canon_lib.nx nx_skull_canon_gate.nx nx_skull_canon_measure_t334.nx

imports: nx_syscalls.nxnx_tissuefield_lib.nx

imported by: nx_skull_canon_gate.nxnx_skull_canon_measure_t334.nx

structs

none

consts

40const SKC_I64: i64 = 8
41const SKC_Q: i64 = TFL_NQ // 4096: the frame's unit-vector scale = the mesh's own normal scale
42const SKC_LM_F: i64 = 4 // per landmark: x y z state
43const SKC_LM_N: i64 = 20
44const SKC_MEAS_N: i64 = 16
45const SKC_REC_N: i64 = SKC_LM_N * SKC_LM_F + SKC_MEAS_N
46const SKC_FR_N: i64 = 14 // frame: lateral(3) up(3) front(3) origin(3) in SKC_Q, then chord pitch and euryon roll (permil)
48const SKC_VERTEX: i64 = 0
49const SKC_GLABELLA: i64 = 1
50const SKC_NASION: i64 = 2
51const SKC_RHINION: i64 = 3
52const SKC_APFLOOR: i64 = 4
53const SKC_NASOSPINALE: i64 = 5
54const SKC_PROSTHION: i64 = 6
55const SKC_SUPRAMENTALE: i64 = 7
56const SKC_POGONION: i64 = 8
57const SKC_GNATHION: i64 = 9
58const SKC_ZYGION_L: i64 = 10
59const SKC_ZYGION_R: i64 = 11
60const SKC_GONION_L: i64 = 12
61const SKC_GONION_R: i64 = 13
62const SKC_OPISTHOCRANION: i64 = 14
63const SKC_EURYON_L: i64 = 15
64const SKC_EURYON_R: i64 = 16
65const SKC_ORBIT_L: i64 = 17 // centre of the left orbit's rims (z = the eye seed's front)
66const SKC_ORBIT_R: i64 = 18
67const SKC_APERTURE: i64 = 19 // centre of the piriform aperture's rims
69const SKC_M_AP_W: i64 = 0 // aperture width, lateral rim crest to rim crest at the floor's row
70const SKC_M_AP_H: i64 = 1 // aperture height, rhinion to nasospinale
71const SKC_M_ORB_L_W: i64 = 2
72const SKC_M_ORB_L_H: i64 = 3
73const SKC_M_ORB_R_W: i64 = 4
74const SKC_M_ORB_R_H: i64 = 5
75const SKC_M_AP_DEPTH: i64 = 6 // the aperture's rim front minus its floor front
76const SKC_M_ORB_L_DEPTH: i64 = 7
77const SKC_M_ORB_R_DEPTH: i64 = 8
78const SKC_M_GOP_PITCH: i64 = 9 // the glabella-opisthocranion chord's pitch, permil rise per backward run (reported, never applied)
79const SKC_M_NV: i64 = 10
80const SKC_M_EDGE: i64 = 11
81const SKC_M_AP_BOUNDED: i64 = 12 // 1 when a rim crest walk found no surface (the measure is not a value)
82const SKC_M_ORB_BOUNDED: i64 = 13
83const SKC_M_LOCATED: i64 = 14
84const SKC_M_FALLBACK: i64 = 15
86const SKC_QN: i64 = 18
87const SKC_Q_CHIN_DEPTH: i64 = 0 // pogonion z - glabella z (sagittal; a muzzle reads far positive)
88const SKC_Q_NASAL_POSITION: i64 = 1 // nasion y - nasospinale y (the bony nasal height)
89const SKC_Q_APERTURE_HEIGHT: i64 = 2 // rhinion to nasospinale
90const SKC_Q_APERTURE_WIDTH: i64 = 3 // lateral rim crest to rim crest
91const SKC_Q_ORBIT_SPACING: i64 = 4 // orbit centre x_l - x_r
92const SKC_Q_ORBIT_HEIGHT: i64 = 5 // glabella y - mean orbit centre y
93const SKC_Q_ORBIT_WIDTH: i64 = 6 // mean orbit width, medial crest to ectoconchion
94const SKC_Q_ZYGION_WIDTH: i64 = 7 // bizygomatic breadth
95const SKC_Q_GONION_WIDTH: i64 = 8 // bigonial breadth
96const SKC_Q_PROSTHION_DEPTH: i64 = 9 // prosthion z - glabella z
97const SKC_Q_UPPER_FACE_HEIGHT: i64 = 10 // nasion y - prosthion y
98const SKC_Q_THIRDS_IMBALANCE: i64 = 11 // (glabella y - nasospinale y) - (nasospinale y - gnathion y)
99const SKC_Q_APERTURE_DEPTH: i64 = 12 // rim front minus floor front: an opening is deep, a dent is not, a tunnel deeper than any aperture
100const SKC_Q_ORBIT_DEPTH: i64 = 13 // mean rim-minus-floor of the orbital depressions
101const SKC_Q_GOP_PITCH: i64 = 14 // the glabella-opisthocranion chord pitch, permil: where the occiput sits against the brow
105const SKC_Q_ORBIT_RIM_HEIGHT: i64 = 15 // mean supraorbital-to-infraorbital crest height: a socket, never a slit
106const SKC_Q_NASION_DEPTH: i64 = 16 // glabella z - nasion z: the dip at the root of the nose (a block fills it to zero)
107const SKC_Q_NASAL_PROJECTION: i64 = 17 // rhinion z - nasion z: how far the nasal bones come forward
109const SKC_P_SHIFT_POS: i64 = 0
110const SKC_P_PITCH: i64 = 1
111const SKC_P_YAW: i64 = 2
112const SKC_P_SHIFT_NEG: i64 = 3
113const SKC_P_ROLL: i64 = 4
114const SKC_BAND_KINDS: i64 = 3 // kinds 0..2 build the band; 3..4 are held out
115const SKC_HOLDOUT_KINDS: i64 = 2
259const SKC_FRAME_AUTHORED: i64 = 0
260const SKC_FRAME_BODYPARTS3D: i64 = 1

functions

117func skc_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
118func skc_max(a: i64, b: i64) -> i64 { if a > b { return a } return b }
119func skc_min(a: i64, b: i64) -> i64 { if a < b { return a } return b }
called by 1: skc_midline_locate
121func skc_name(i: i64) -> *u8
143func skc_qname(q: i64) -> *u8
165func skc_rec_new() -> *i64
171func skc_rec_copy(R: *i64) -> *i64
called by 2: mainmain calls 1: skc_rec_new
177func skc_x(R: *i64, i: i64) -> i64 { return R[i * SKC_LM_F] }
178func skc_y(R: *i64, i: i64) -> i64 { return R[i * SKC_LM_F + 1] }
179func skc_z(R: *i64, i: i64) -> i64 { return R[i * SKC_LM_F + 2] }
180func skc_state(R: *i64, i: i64) -> i64 { return R[i * SKC_LM_F + 3] }
181func skc_set(R: *i64, i: i64, x: i64, y: i64, z: i64, st: i64) -> i64
185func skc_meas(R: *i64, k: i64) -> i64 { return R[SKC_LM_N * SKC_LM_F + k] }
186func skc_meas_set(R: *i64, k: i64, v: i64) -> i64 { R[SKC_LM_N * SKC_LM_F + k] = v; return 0 }
198func skc_lattice_n(M: *i64, t: i64, step: i64) -> i64
called by 1: skc_densify calls 1: skc_max
215func skc_densify(M: *i64) -> i64
261func skc_load(path: *u8, frame: i64) -> *i64
282func skc_tab_reset(T: *i64) -> i64
called by 1: skc_locate_pass calls 1: tfl_row
287func skc_row_state(T: *i64, name: *u8) -> i64
called by 1: skc_locate_pass calls 2: tfl_row_findtfl_row
295func skc_perturb(M: *i64, kind: i64) -> *i64
327func skc_dot(ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64) -> i64 { return ax * bx + ay * by + az * bz }
called by 1: skc_apply
329func skc_unit(x: i64, y: i64, z: i64, out3: *i64) -> i64
called by 1: skc_frame
342func skc_frame(RAW: *i64, F: *i64) -> i64
361func skc_apply(F: *i64, x: i64, y: i64, z: i64, out3: *i64) -> i64
called by 1: skc_measure calls 1: skc_dot
371func skc_farthest(M: *i64, x: i64, y: i64, z: i64) -> i64
called by 1: skc_locate_pass
398func skc_midline_locate(M: *i64, T: *i64, KS: *i64) -> i64
555func skc_locate_pass(M: *i64, T: *i64, RAW: *i64) -> i64
666func skc_measure(M: *i64, T: *i64, R: *i64, RAWOUT: *i64, FOUT: *i64) -> i64
688func skc_dump_profile(M: *i64, tag: *u8) -> i64
708func skc_run_generator(out: *u8, sex: i64, robust: i64, cell_um: i64, res_permil: i64) -> i64
739func skc_quantity(R: *i64, q: i64) -> i64
760func skc_quantity_band(B: *i64, q: i64) -> i64
782func skc_quantity_asym(R: *i64, q: i64) -> i64
793func skc_quantity_ready(R: *i64, q: i64) -> i64
818func skc_band_fold(B: *i64, R: *i64, P: *i64) -> i64
839func skc_band_floor(B: *i64, edge: i64) -> i64
856func skc_bands(M: *i64, T: *i64, R: *i64, B: *i64, k0: i64, nk: i64) -> i64
874func skc_holdout(M: *i64, T: *i64, R: *i64, B: *i64, k0: i64, nk: i64, out2: *i64) -> i64
911func skc_inband(RO: *i64, RM: *i64, BO: *i64, BM: *i64) -> i64
923func skc_print_line(RO: *i64, RM: *i64, BO: *i64, BM: *i64) -> i64