code wiki / (root) / nx_anatomy_placement_test.nx

nx_anatomy_placement_test.nx source

↩ module page · 65 lines · 3136 B

1import "nx_syscalls.nx" 2import "nx_anatomy_placement.nx" 3 4func main() -> i64 { 5 let result: *i64 = (sys_mmap(NX_PLACE_RES_FIELDS * 8 + 16)) as *i64 6 7 // T1: Nipple correctly placed on breast. 8 // Breast bbox: 100-200 horizontally, 100-200 vertically (100x100). 9 // Nipple centroid at (150, 165): x = 50% of width (center), y = 65% (mid-band). 10 nx_nipple_on_breast_check(100, 100, 200, 200, 150, 165, result) 11 let v1: i64 = result[NX_PLACE_RES_VERDICT] 12 let d1: i64 = result[NX_PLACE_RES_DIST_TOTAL_Q10] 13 if v1 != NX_PLACE_CORRECT { return 1 } 14 if d1 != 0 { return 2 } 15 16 // T2: Image #56 scenario — nipple at TOP of breast bbox (y=110, breast 100-200). 17 // y = 10% from top → way above the 55-70% expected band. 18 nx_nipple_on_breast_check(100, 100, 200, 200, 150, 110, result) 19 let v2: i64 = result[NX_PLACE_RES_VERDICT] 20 let dy2: i64 = result[NX_PLACE_RES_DIST_Y_Q10] 21 if v2 != NX_PLACE_OUT_OF_PLACE { return 10 } 22 // y_q10 = 102, expected band 563-717, so dy = 461 (very far). 23 if dy2 < 400 { return 11 } 24 25 // T3: Nipple horizontally off (way left). 26 // Nipple at (105, 165): x = 5% of width, expected center 50%. 27 nx_nipple_on_breast_check(100, 100, 200, 200, 105, 165, result) 28 let v3: i64 = result[NX_PLACE_RES_VERDICT] 29 let dx3: i64 = result[NX_PLACE_RES_DIST_X_Q10] 30 if v3 != NX_PLACE_OUT_OF_PLACE { return 20 } 31 if dx3 < 300 { return 21 } 32 33 // T4: SLIGHTLY_OFF — nipple at edge of acceptable band. 34 // y = 75% (515 from top of 100x100 bbox + 75 = 175). Just past max 70%. 35 // y_q10 = 768, max_y_q10 = 717, dy_off = 51 -> well within 256. 36 // Try y=180 = 80% → y_q10=819, dy=102 (still under 256? yes) → CORRECT. 37 // Try y=190 = 90% → y_q10=921, dy=204 (under 256) → still CORRECT. 38 // Need dy > 256: y_q10 > 973 → y > 197. 39 // Try y=197: 100x100 bbox, y_q10 = (197-100)*1024/100 = 993. dy = 993-717 = 276. > 256 → SLIGHTLY_OFF. 40 nx_nipple_on_breast_check(100, 100, 200, 200, 150, 197, result) 41 let v4: i64 = result[NX_PLACE_RES_VERDICT] 42 if v4 != NX_PLACE_SLIGHTLY_OFF { return 30 } 43 44 // T5: Navel on torso correct position. 45 // Torso 100-200 x 100-400 (100w x 300h). Navel centered at (150, 270). 46 // x = 50% (center) ✓. y = (270-100)/300 = 56.7%. Expected 50-60%. → CORRECT. 47 nx_navel_on_torso_check(100, 100, 200, 400, 150, 270, result) 48 let v5: i64 = result[NX_PLACE_RES_VERDICT] 49 if v5 != NX_PLACE_CORRECT { return 40 } 50 51 // T6: Navel too high (in upper torso) → OUT_OF_PLACE. 52 // y = 130 → y_q10 = 102. Expected 512-614. dy = 410 → OUT_OF_PLACE. 53 nx_navel_on_torso_check(100, 100, 200, 400, 150, 130, result) 54 let v6: i64 = result[NX_PLACE_RES_VERDICT] 55 if v6 != NX_PLACE_OUT_OF_PLACE { return 50 } 56 57 // T7: Pubic mound correctly placed. 58 // Torso 100-200 x 100-400. Pubic at (150, 380). 59 // y = (380-100)/300 = 93.3%. Expected 85-95% → CORRECT. 60 nx_pubic_on_torso_check(100, 100, 200, 400, 150, 380, result) 61 let v7: i64 = result[NX_PLACE_RES_VERDICT] 62 if v7 != NX_PLACE_CORRECT { return 60 } 63 64 return 0 65}