code wiki / (root) / nx_slice_plane_test.nx

nx_slice_plane_test.nx

buildroot/runtime/nx_slice_plane_test.nx

3194 B86 linesdepth 8pulls 8 transitivereach 0 importersview sourcekind gate/prooftopic slice
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_mesh.nx nx_mesh_print_check.nx nx_bvh.nx nx_slice_plane.nx nx_slice_plane_test.nx

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

main nx_mesh_make_tetrahedron nx_mesh_alloc sys_mmap nx_mesh_set_vertex nx_mesh_set_triangle nx_bvh_build nx_bvh_build_with_threshol sys_mmap ↻ nx_bvh_compute_tri_info nx_mesh_print_tri_v nx_mesh_get_vertex_x nx_mesh_get_vertex_y nx_mesh_get_vertex_z nx_bvh_tri_at nx_bvh_min3 nx_bvh_max3 nx_bvh_build_subtree nx_bvh_alloc_node nx_bvh_fill_subtree nx_bvh_node_at nx_bvh_range_aabb nx_bvh_tri_at ↻ nx_bvh_longest_axis nx_bvh_partition_by_axis nx_bvh_centroid_on_axis nx_bvh_swap_tri_order nx_bvh_alloc_node ↻ nx_bvh_fill_subtree ↻ nx_slice_plane nx_slice_soup_new sys_mmap ↻ nx_slice_walk_node nx_bvh_node_at ↻ nx_slice_one_tri nx_mesh_print_tri_v ↻ nx_mesh_get_vertex_x ↻ nx_mesh_get_vertex_y ↻ nx_mesh_get_vertex_z ↻ nx_slice_soup_emit

structs

none

consts

37const Q14_ONE: i64 = 16384
38const Q14_HALF: i64 = 8192

functions

41func smoke_count_endpoint(s: *NxSliceSoup, px: i64, py: i64) -> i64
called by 1: main calls 1: nx_slice_soup_seg_ptr
53func main() -> i64