code wiki / _hdl_build / nx_eline_gate.nx

nx_eline_gate.nx source

↩ module page · 172 lines · 9042 B

1// nx_eline_gate.nx -- GATE for aesthetictwin rung AT15: the RICKETTS E-LINE profile ruler. 2// CORRECTED: this shipped labelled AT5 for one session, and AT5 is the NEOTENY axis on that board. 3// The rung is AT15 and its row was written into aesthetictwin.plan after the fact. Recording the 4// mislabel rather than quietly renumbering, because a number that moved without explanation costs the 5// next reader the whole reconciliation. 6// 7// WHY THIS RUNG EXISTS. The face was judged "not there" by the operator and the honest first answer was 8// that I had no external ruler for a PROFILE at all -- only my own eye, which the standing rule grades 9// as an interpretation and never as a shipping justification. Ricketts' esthetic plane is a published 10// norm: a line from pronasale to soft-tissue pogonion, with both vermilions sitting BEHIND it in a 11// balanced adult face. That turns "the face looks wrong" into two signed numbers against a bar nobody 12// in this estate gets to choose. 13// 14// THE PAIR T4/T5 IS THE LOAD-BEARING PART AND THEY TEST DIFFERENT TERMS. An offset from a LINE has two 15// endpoints and a subject; a ruler that had quietly degenerated into "how deep is the lip" would still 16// move when the lip moves, so T4 alone cannot tell a line from a depth. T5 leaves the lips untouched 17// and advances the CHIN, which changes only the baseline -- and the measured lip protrusion must fall 18// anyway, because the line rotated forward underneath it. Only both together prove a line was used. 19// 20// T6 is a REACHABLE negative control, not decoration: shrunk to a tenth the face no longer reaches the 21// pogonion band, and the ruler must refuse BY NAME rather than return the most flattering reading 22// available. A measure that answered anyway would be reading its own parameters back out. 23import "nx_syscalls.nx" 24import "nx_gate_verdict.nx" 25import "nx_gatekit_lib.nx" 26import "nx_faceanat.nx" 27 28const EG_ASCII0: i64 = 48 29const EG_MINUS: i64 = 45 30const EG_NL: i64 = 10 31const EG_FIELDS: i64 = 6 32const EG_PART_CZ: i64 = 2 33const EG_LIP_LOWER: i64 = 11 34const EG_CHIN: i64 = 3 35const EG_TENTH: i64 = 10 36// 15x the 4-unit midline sampling step, so a real surface move cannot be read as sampling noise, and 37// ~17mm -- unambiguous, while still leaving the subject a face rather than a caricature. 38const EG_SHIFT: i64 = 60 39 40func eg_pnum(tag: *u8, v: i64) -> i64 { 41 let b: *u8 = sys_mmap(96) 42 let d: *u8 = sys_mmap(64) 43 var n: i64 = 0 44 var x: i64 = v 45 if x < 0 { b[n] = EG_MINUS; n = n + 1; x = 0 - x } 46 var m: i64 = 0 47 if x == 0 { d[m] = EG_ASCII0; m = m + 1 } 48 while x > 0 { 49 let q: i64 = x / 10 50 d[m] = EG_ASCII0 + (x - q * 10) 51 m = m + 1 52 x = q 53 } 54 while m > 0 { m = m - 1; b[n] = d[m]; n = n + 1 } 55 b[n] = EG_NL 56 n = n + 1 57 sys_write(1, tag, gk_len(tag)) 58 sys_write(1, b, n) 59 return 0 60} 61 62func main(argc: i64, argv: *i64) -> i64 { 63 let ctr: *i64 = gv_ctr() 64 gv_head("=== NX-ELINE-GATE -- AT5 Ricketts E-line lip protrusion, read from the blended surface ===" as *u8) 65 66 let base: i64 = sys_mmap(sdf_bytes()) as i64 67 faceanat_build(base) 68 let o: *i64 = sys_mmap(FA_EL_O_FIELDS * 8 + FA_LIP_SLACK) as *i64 69 let r: i64 = fa_eline_offset(base, o) 70 // PRINT THE VALUES, NOT JUST PASS/FAIL -- a gate that reports a boolean cannot say why, and these 71 // landmark coordinates are the whole diagnosis when a tooth does go red. 72 eg_pnum("ELINE return=" as *u8, r) 73 eg_pnum("ELINE reason=" as *u8, o[FA_EL_O_REASON]) 74 eg_pnum("ELINE pronasale_y=" as *u8, o[FA_EL_O_PRN_Y]) 75 eg_pnum("ELINE pronasale_z=" as *u8, o[FA_EL_O_PRN_Z]) 76 eg_pnum("ELINE pogonion_y=" as *u8, o[FA_EL_O_POG_Y]) 77 eg_pnum("ELINE pogonion_z=" as *u8, o[FA_EL_O_POG_Z]) 78 eg_pnum("ELINE labrale_sup_y=" as *u8, o[FA_EL_O_LS_Y]) 79 eg_pnum("ELINE labrale_sup_z=" as *u8, o[FA_EL_O_LS_Z]) 80 eg_pnum("ELINE labrale_inf_y=" as *u8, o[FA_EL_O_LI_Y]) 81 eg_pnum("ELINE labrale_inf_z=" as *u8, o[FA_EL_O_LI_Z]) 82 eg_pnum("ELINE upper_protrusion_mm10=" as *u8, o[FA_EL_O_ULIP]) 83 eg_pnum("ELINE lower_protrusion_mm10=" as *u8, o[FA_EL_O_LLIP]) 84 // The unconverted measurement, so this finding survives any correction to MMU. 85 eg_pnum("ELINE upper_protrusion_units=" as *u8, o[FA_EL_O_ULIP_U]) 86 eg_pnum("ELINE lower_protrusion_units=" as *u8, o[FA_EL_O_LLIP_U]) 87 88 // T1 -- every tooth below reads these landmarks, so a run that never measured them would be 89 // scoring its outcomes against initialised sentinels and reporting that as agreement. 90 var t1: i64 = 0 91 if r == 0 { if o[FA_EL_O_REASON] == FA_EL_R_OK { t1 = 1 } } 92 gv_check("fixture-reached-the-condition-the-ruler-measured-all-four-landmarks" as *u8, t1, ctr) 93 94 // T2 -- anatomical order top to bottom. A band that captured its neighbour's ellipsoid instead of 95 // its own feature shows up here as an ordering violation and nowhere else. 96 var t2: i64 = 0 97 if o[FA_EL_O_PRN_Y] > o[FA_EL_O_LS_Y] { 98 if o[FA_EL_O_LS_Y] > o[FA_EL_O_LI_Y] { 99 if o[FA_EL_O_LI_Y] > o[FA_EL_O_POG_Y] { t2 = 1 } 100 } 101 } 102 gv_check("landmarks-ordered-pronasale-above-both-lips-above-pogonion" as *u8, t2, ctr) 103 104 // T3 -- the baseline must have a direction, or every offset below is measured against noise. 105 var t3: i64 = 0 106 if o[FA_EL_O_PRN_Z] < o[FA_EL_O_POG_Z] { t3 = 1 } 107 gv_check("baseline-has-direction-pronasale-is-prouder-than-pogonion" as *u8, t3, ctr) 108 109 // T4 -- THE SUBJECT TERM. Reading cz back out of the part table would give a plausible number that 110 // is indistinguishable from a surface measurement on a healthy face; the only way to separate them 111 // is to move the geometry and require the measurement to follow. 112 let b2: i64 = sys_mmap(sdf_bytes()) as i64 113 faceanat_build(b2) 114 let p2: *i64 = (b2 + O_PARTS) as *i64 115 p2[EG_LIP_LOWER * EG_FIELDS + EG_PART_CZ] = p2[EG_LIP_LOWER * EG_FIELDS + EG_PART_CZ] + EG_SHIFT 116 let o2: *i64 = sys_mmap(FA_EL_O_FIELDS * 8 + FA_LIP_SLACK) as *i64 117 let r2: i64 = fa_eline_offset(b2, o2) 118 eg_pnum("ELINE lip_pulled_back_lower_protrusion_mm10=" as *u8, o2[FA_EL_O_LLIP]) 119 var t4: i64 = 0 120 if r2 == 0 { if o2[FA_EL_O_LLIP] < o[FA_EL_O_LLIP] { t4 = 1 } } 121 gv_check("surface-not-slider-pulling-the-lower-lip-back-reduces-its-measured-protrusion" as *u8, t4, ctr) 122 123 // T5 -- THE BASELINE TERM, and the one that separates a line from a depth. The lips are untouched 124 // here; only the chin moves, and the protrusion must still fall because the line rotated forward. 125 let b3: i64 = sys_mmap(sdf_bytes()) as i64 126 faceanat_build(b3) 127 let p3: *i64 = (b3 + O_PARTS) as *i64 128 p3[EG_CHIN * EG_FIELDS + EG_PART_CZ] = p3[EG_CHIN * EG_FIELDS + EG_PART_CZ] - EG_SHIFT 129 let o3: *i64 = sys_mmap(FA_EL_O_FIELDS * 8 + FA_LIP_SLACK) as *i64 130 let r3: i64 = fa_eline_offset(b3, o3) 131 eg_pnum("ELINE chin_advanced_lower_protrusion_mm10=" as *u8, o3[FA_EL_O_LLIP]) 132 var t5: i64 = 0 133 if r3 == 0 { if o3[FA_EL_O_LLIP] < o[FA_EL_O_LLIP] { t5 = 1 } } 134 gv_check("it-is-a-line-not-a-depth-advancing-the-chin-alone-reduces-lip-protrusion" as *u8, t5, ctr) 135 136 // T6 -- NEGATIVE CONTROL. Asserts a NAMED refusal rather than one specific code, because which 137 // band empties first is a property of the shrink, not of the contract being tested. 138 let b4: i64 = sys_mmap(sdf_bytes()) as i64 139 faceanat_build(b4) 140 faceanat_scale(b4, EG_TENTH) 141 let o4: *i64 = sys_mmap(FA_EL_O_FIELDS * 8 + FA_LIP_SLACK) as *i64 142 let r4: i64 = fa_eline_offset(b4, o4) 143 eg_pnum("ELINE shrunk_face_return=" as *u8, r4) 144 eg_pnum("ELINE shrunk_face_reason=" as *u8, o4[FA_EL_O_REASON]) 145 var t6: i64 = 0 146 if r4 == FA_LIP_UNMEASURED { 147 if o4[FA_EL_O_LLIP] == FA_LIP_UNMEASURED { 148 if o4[FA_EL_O_REASON] != FA_EL_R_OK { t6 = 1 } 149 } 150 } 151 gv_check("neg-control-a-face-absent-from-the-band-refuses-by-name-and-returns-no-number" as *u8, t6, ctr) 152 153 // T7 -- the profile is a midline quantity, so negating x must not move any of it. An extractor 154 // that had drifted off the midline fails this and passes everything else. 155 let b5: i64 = sys_mmap(sdf_bytes()) as i64 156 faceanat_build(b5) 157 let p5: *i64 = (b5 + O_PARTS) as *i64 158 let nb5: *i64 = (b5 + O_NPART) as *i64 159 var mi: i64 = 0 160 while mi < nb5[0] { p5[mi * EG_FIELDS] = 0 - p5[mi * EG_FIELDS]; mi = mi + 1 } 161 let o5: *i64 = sys_mmap(FA_EL_O_FIELDS * 8 + FA_LIP_SLACK) as *i64 162 let r5: i64 = fa_eline_offset(b5, o5) 163 eg_pnum("ELINE mirrored_lower_protrusion_mm10=" as *u8, o5[FA_EL_O_LLIP]) 164 var t7: i64 = 0 165 if r5 == 0 { 166 if o5[FA_EL_O_LLIP] == o[FA_EL_O_LLIP] { 167 if o5[FA_EL_O_ULIP] == o[FA_EL_O_ULIP] { t7 = 1 } 168 } 169 } 170 gv_check("mirror-invariant-midline-profile-does-not-move-when-x-is-negated" as *u8, t7, ctr) 171 172 return gv_verdict("NX-ELINE-GATE" as *u8, ctr, "AT15: the Ricketts E-line offset is read from the rendered surface against a measured baseline, so it cannot be satisfied by editing a slider" as *u8) 173}