nx_skull_canon_lib.nx
buildroot/runtime/nx_skull_canon_lib.nx
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
imports: nx_syscalls.nxnx_tissuefield_lib.nx
imported by: nx_skull_canon_gate.nxnx_skull_canon_measure_t334.nx
structs
| none |
consts
| 40 | const SKC_I64: i64 = 8 |
| 41 | const SKC_Q: i64 = TFL_NQ // 4096: the frame's unit-vector scale = the mesh's own normal scale |
| 42 | const SKC_LM_F: i64 = 4 // per landmark: x y z state |
| 43 | const SKC_LM_N: i64 = 20 |
| 44 | const SKC_MEAS_N: i64 = 16 |
| 45 | const SKC_REC_N: i64 = SKC_LM_N * SKC_LM_F + SKC_MEAS_N |
| 46 | const SKC_FR_N: i64 = 14 // frame: lateral(3) up(3) front(3) origin(3) in SKC_Q, then chord pitch and euryon roll (permil) |
| 48 | const SKC_VERTEX: i64 = 0 |
| 49 | const SKC_GLABELLA: i64 = 1 |
| 50 | const SKC_NASION: i64 = 2 |
| 51 | const SKC_RHINION: i64 = 3 |
| 52 | const SKC_APFLOOR: i64 = 4 |
| 53 | const SKC_NASOSPINALE: i64 = 5 |
| 54 | const SKC_PROSTHION: i64 = 6 |
| 55 | const SKC_SUPRAMENTALE: i64 = 7 |
| 56 | const SKC_POGONION: i64 = 8 |
| 57 | const SKC_GNATHION: i64 = 9 |
| 58 | const SKC_ZYGION_L: i64 = 10 |
| 59 | const SKC_ZYGION_R: i64 = 11 |
| 60 | const SKC_GONION_L: i64 = 12 |
| 61 | const SKC_GONION_R: i64 = 13 |
| 62 | const SKC_OPISTHOCRANION: i64 = 14 |
| 63 | const SKC_EURYON_L: i64 = 15 |
| 64 | const SKC_EURYON_R: i64 = 16 |
| 65 | const SKC_ORBIT_L: i64 = 17 // centre of the left orbit's rims (z = the eye seed's front) |
| 66 | const SKC_ORBIT_R: i64 = 18 |
| 67 | const SKC_APERTURE: i64 = 19 // centre of the piriform aperture's rims |
| 69 | const SKC_M_AP_W: i64 = 0 // aperture width, lateral rim crest to rim crest at the floor's row |
| 70 | const SKC_M_AP_H: i64 = 1 // aperture height, rhinion to nasospinale |
| 71 | const SKC_M_ORB_L_W: i64 = 2 |
| 72 | const SKC_M_ORB_L_H: i64 = 3 |
| 73 | const SKC_M_ORB_R_W: i64 = 4 |
| 74 | const SKC_M_ORB_R_H: i64 = 5 |
| 75 | const SKC_M_AP_DEPTH: i64 = 6 // the aperture's rim front minus its floor front |
| 76 | const SKC_M_ORB_L_DEPTH: i64 = 7 |
| 77 | const SKC_M_ORB_R_DEPTH: i64 = 8 |
| 78 | const SKC_M_GOP_PITCH: i64 = 9 // the glabella-opisthocranion chord's pitch, permil rise per backward run (reported, never applied) |
| 79 | const SKC_M_NV: i64 = 10 |
| 80 | const SKC_M_EDGE: i64 = 11 |
| 81 | const SKC_M_AP_BOUNDED: i64 = 12 // 1 when a rim crest walk found no surface (the measure is not a value) |
| 82 | const SKC_M_ORB_BOUNDED: i64 = 13 |
| 83 | const SKC_M_LOCATED: i64 = 14 |
| 84 | const SKC_M_FALLBACK: i64 = 15 |
| 86 | const SKC_QN: i64 = 18 |
| 87 | const SKC_Q_CHIN_DEPTH: i64 = 0 // pogonion z - glabella z (sagittal; a muzzle reads far positive) |
| 88 | const SKC_Q_NASAL_POSITION: i64 = 1 // nasion y - nasospinale y (the bony nasal height) |
| 89 | const SKC_Q_APERTURE_HEIGHT: i64 = 2 // rhinion to nasospinale |
| 90 | const SKC_Q_APERTURE_WIDTH: i64 = 3 // lateral rim crest to rim crest |
| 91 | const SKC_Q_ORBIT_SPACING: i64 = 4 // orbit centre x_l - x_r |
| 92 | const SKC_Q_ORBIT_HEIGHT: i64 = 5 // glabella y - mean orbit centre y |
| 93 | const SKC_Q_ORBIT_WIDTH: i64 = 6 // mean orbit width, medial crest to ectoconchion |
| 94 | const SKC_Q_ZYGION_WIDTH: i64 = 7 // bizygomatic breadth |
| 95 | const SKC_Q_GONION_WIDTH: i64 = 8 // bigonial breadth |
| 96 | const SKC_Q_PROSTHION_DEPTH: i64 = 9 // prosthion z - glabella z |
| 97 | const SKC_Q_UPPER_FACE_HEIGHT: i64 = 10 // nasion y - prosthion y |
| 98 | const SKC_Q_THIRDS_IMBALANCE: i64 = 11 // (glabella y - nasospinale y) - (nasospinale y - gnathion y) |
| 99 | const 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 |
| 100 | const SKC_Q_ORBIT_DEPTH: i64 = 13 // mean rim-minus-floor of the orbital depressions |
| 101 | const SKC_Q_GOP_PITCH: i64 = 14 // the glabella-opisthocranion chord pitch, permil: where the occiput sits against the brow |
| 105 | const SKC_Q_ORBIT_RIM_HEIGHT: i64 = 15 // mean supraorbital-to-infraorbital crest height: a socket, never a slit |
| 106 | const SKC_Q_NASION_DEPTH: i64 = 16 // glabella z - nasion z: the dip at the root of the nose (a block fills it to zero) |
| 107 | const SKC_Q_NASAL_PROJECTION: i64 = 17 // rhinion z - nasion z: how far the nasal bones come forward |
| 109 | const SKC_P_SHIFT_POS: i64 = 0 |
| 110 | const SKC_P_PITCH: i64 = 1 |
| 111 | const SKC_P_YAW: i64 = 2 |
| 112 | const SKC_P_SHIFT_NEG: i64 = 3 |
| 113 | const SKC_P_ROLL: i64 = 4 |
| 114 | const SKC_BAND_KINDS: i64 = 3 // kinds 0..2 build the band; 3..4 are held out |
| 115 | const SKC_HOLDOUT_KINDS: i64 = 2 |
| 259 | const SKC_FRAME_AUTHORED: i64 = 0 |
| 260 | const SKC_FRAME_BODYPARTS3D: i64 = 1 |
functions
| 117 | func skc_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } |
| 118 | func skc_max(a: i64, b: i64) -> i64 { if a > b { return a } return b } |
| 119 | func skc_min(a: i64, b: i64) -> i64 { if a < b { return a } return b } called by 1: skc_midline_locate |
| 121 | func skc_name(i: i64) -> *u8 |
| 143 | func skc_qname(q: i64) -> *u8 |
| 165 | func skc_rec_new() -> *i64 |
| 171 | func skc_rec_copy(R: *i64) -> *i64 |
| 177 | func skc_x(R: *i64, i: i64) -> i64 { return R[i * SKC_LM_F] } |
| 178 | func skc_y(R: *i64, i: i64) -> i64 { return R[i * SKC_LM_F + 1] } |
| 179 | func skc_z(R: *i64, i: i64) -> i64 { return R[i * SKC_LM_F + 2] } |
| 180 | func skc_state(R: *i64, i: i64) -> i64 { return R[i * SKC_LM_F + 3] } |
| 181 | func skc_set(R: *i64, i: i64, x: i64, y: i64, z: i64, st: i64) -> i64 |
| 185 | func skc_meas(R: *i64, k: i64) -> i64 { return R[SKC_LM_N * SKC_LM_F + k] } |
| 186 | func skc_meas_set(R: *i64, k: i64, v: i64) -> i64 { R[SKC_LM_N * SKC_LM_F + k] = v; return 0 } |
| 198 | func skc_lattice_n(M: *i64, t: i64, step: i64) -> i64 |
| 215 | func skc_densify(M: *i64) -> i64 |
| 261 | func skc_load(path: *u8, frame: i64) -> *i64 |
| 282 | func skc_tab_reset(T: *i64) -> i64 |
| 287 | func skc_row_state(T: *i64, name: *u8) -> i64 |
| 295 | func skc_perturb(M: *i64, kind: i64) -> *i64 |
| 327 | func 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 |
| 329 | func skc_unit(x: i64, y: i64, z: i64, out3: *i64) -> i64 called by 1: skc_frame |
| 342 | func skc_frame(RAW: *i64, F: *i64) -> i64 |
| 361 | func skc_apply(F: *i64, x: i64, y: i64, z: i64, out3: *i64) -> i64 |
| 371 | func skc_farthest(M: *i64, x: i64, y: i64, z: i64) -> i64 called by 1: skc_locate_pass |
| 398 | func skc_midline_locate(M: *i64, T: *i64, KS: *i64) -> i64 called by 1: skc_locate_pass calls 17: sys_mmaptfl_profiletfl_noisefloortfl_extrematfl_kvtfl_puts+11 |
| 555 | func skc_locate_pass(M: *i64, T: *i64, RAW: *i64) -> i64 |
| 666 | func skc_measure(M: *i64, T: *i64, R: *i64, RAWOUT: *i64, FOUT: *i64) -> i64 called by 4: mainskc_bandsskc_holdoutmain calls 12: skc_rec_newskc_locate_passsys_mmapskc_frameskc_meas_setskc_apply+6 |
| 688 | func skc_dump_profile(M: *i64, tag: *u8) -> i64 |
| 708 | func skc_run_generator(out: *u8, sex: i64, robust: i64, cell_um: i64, res_permil: i64) -> i64 |
| 739 | func skc_quantity(R: *i64, q: i64) -> i64 called by 9: skg_write_oracle_qskg_toothmainskc_holdoutskc_inbandskc_print_line+3 calls 4: skc_zskc_yskc_measskc_x |
| 760 | func skc_quantity_band(B: *i64, q: i64) -> i64 called by 9: skg_write_oracle_qskg_toothmainskc_holdoutskc_inbandskc_print_line+3 calls 4: skc_zskc_yskc_measskc_x |
| 782 | func skc_quantity_asym(R: *i64, q: i64) -> i64 called by 7: skg_toothmainskc_holdoutskc_inbandskc_print_lineskg_tooth+1 calls 4: skc_absskc_xskc_yskc_meas |
| 793 | func skc_quantity_ready(R: *i64, q: i64) -> i64 |
| 818 | func skc_band_fold(B: *i64, R: *i64, P: *i64) -> i64 |
| 839 | func skc_band_floor(B: *i64, edge: i64) -> i64 |
| 856 | func skc_bands(M: *i64, T: *i64, R: *i64, B: *i64, k0: i64, nk: i64) -> i64 |
| 874 | func skc_holdout(M: *i64, T: *i64, R: *i64, B: *i64, k0: i64, nk: i64, out2: *i64) -> i64 |
| 911 | func skc_inband(RO: *i64, RM: *i64, BO: *i64, BM: *i64) -> i64 called by 1: skc_print_line calls 5: skc_quantity_readyskc_quantity_bandskc_quantity_asymskc_absskc_quantity |
| 923 | func skc_print_line(RO: *i64, RM: *i64, BO: *i64, BM: *i64) -> i64 called by 2: mainmain calls 8: tfl_putsskc_quantity_bandskc_quantity_asymskc_qnameskc_quantity_readytfl_pn+2 |