nx_slice_plane_test.nx
buildroot/runtime/nx_slice_plane_test.nx
about
nx_slice_plane_test.nx -- slice a unit tetrahedron at its midplane
and verify the resulting segment soup describes the expected
right-triangle cross-section.
Tetrahedron at unit-mm scale:
v0=(0,0,0), v1=(1,0,0), v2=(0,1,0), v3=(0,0,1) (in Q14: 0 vs 16384)
Sliced at z = 0.5 mm (8192 Q14):
T0 (v1,v2,v3): produces segment (8192,0) -- (0,8192)
T1 (v0,v3,v2): produces segment (0,0) -- (0,8192)
T2 (v0,v1,v3): produces segment (8192,0) -- (0,0)
T3 (v0,v2,v1): all z=0, plane at 8192 -> all below -> no segment
Result: 3 segments whose 6 endpoints cover the set
{(0,0), (8192,0), (0,8192)}, each appearing exactly twice.
This is the boundary of a right triangle in 2D.
Closed-form invariants:
(a) Soup verdict == OK.
(b) Exactly 3 segments at z=8192.
(c) Each of the 3 corner points appears exactly twice in the
segment-endpoint multiset.
(d) Slicing at z above tetrahedron (z = 2 * Q14) -> 0 segments.
(e) Slicing at z below tetrahedron (z = -1) -> 0 segments.
(f) Slicing at the bottom face (z = 0) yields 3 segments
(the three coplanar tri edges of the bottom face's
neighbours; T3 itself coplanar -> no segment).
expect_exit: 0
license_tier: ORIGINAL
dependencies 5 imports · 0 importers
imports: nx_syscalls.nxnx_mesh.nxnx_mesh_print_check.nxnx_bvh.nxnx_slice_plane.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 37 | const Q14_ONE: i64 = 16384 |
| 38 | const Q14_HALF: i64 = 8192 |
functions
| 41 | func smoke_count_endpoint(s: *NxSliceSoup, px: i64, py: i64) -> i64 |
| 53 | func main() -> i64 |