code wiki / (root) / nx_river_quality.nx

nx_river_quality.nx

buildroot/runtime/nx_river_quality.nx

11898 B315 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_river_quality.nx -- per-kind grader for nx_river_carve paths. Reads a river polyline (control point array) and grades on 5 axes: 0. SINUOSITY_INDEX: actual polyline length / straight-line endpoint distance. A perfectly straight river = 1.0 (low score; rivers should meander); target [1.2, 2.0]. 1. SEGMENT_CONSISTENCY: stddev of per-segment lengths. Wildly varying segments suggest noise; uniform segments suggest natural meander. 2. MEANDER_BAND: mean perpendicular deviation from the start-end baseline. A river that never deviates is a canal. 3. ENDPOINT_DISPLACEMENT: ||end - start|| / sum_segment_lengths. Closer to 0 = the river loops back to itself (bad); closer to 1 = straight line (also less interesting); target [0.4, 0.8]. 4. NO_REVERSAL: count of segments where direction flips by > 90 deg from the dominant flow direction; penalty for many reversals. EMITS LAYER_VERDICT (kind = NX_LAYER_KIND_RIVER). genealogy_id: leopold_wolman_1957 + genevaux_2013 + sinuosity_canon lineage_id: nx_river_quality_5axis_v1

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_layer_verdict.nx nx_river_quality.nx

imports: nx_syscalls.nxnx_tier.nxnx_layer_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nx_river_quality_grade _rq_sinuosity_q14 _rq_straight_len _rq_isqrt _rq_segment_total _rq_isqrt ↻ _rq_seg_consistency_q14 _rq_isqrt ↻ _rq_meander_q14 _rq_isqrt ↻ _rq_endpoint_disp_q14 _rq_segment_total ↻ _rq_straight_len ↻ _rq_no_reversal_q14 nx_layer_verdict_init nx_layer_verdict_finalize nx_layer_grade_from_axes nx_lv_axis_verdict nx_lv_grade_is_valid

structs

none

consts

34const NX_RQ_Q: nx_int = 16384
35const NX_RQ_POINT_STRIDE: nx_int = 2
37const NX_RQ_AXIS_SINUOSITY: nx_int = 0
38const NX_RQ_AXIS_SEG_CONSISTENCY: nx_int = 1
39const NX_RQ_AXIS_MEANDER: nx_int = 2
40const NX_RQ_AXIS_ENDPOINT_DISP: nx_int = 3
41const NX_RQ_AXIS_NO_REVERSAL: nx_int = 4
42const NX_RQ_AXIS_COUNT: nx_int = 5

functions

45func _rq_isqrt(n: nx_int) -> nx_int
57func _rq_segment_total(points: *i64, n: nx_int) -> nx_int
69func _rq_straight_len(points: *i64, n: nx_int) -> nx_int
76func _rq_sinuosity_q14(points: *i64, n: nx_int) -> nx_int
99func _rq_seg_consistency_q14(points: *i64, n: nx_int) -> nx_int
called by 1: nx_river_quality_grade calls 1: _rq_isqrt
135func _rq_meander_q14(points: *i64, n: nx_int) -> nx_int
called by 1: nx_river_quality_grade calls 1: _rq_isqrt
179func _rq_endpoint_disp_q14(points: *i64, n: nx_int) -> nx_int
204func _rq_no_reversal_q14(points: *i64, n: nx_int) -> nx_int
236func nx_river_quality_grade(
256func main() -> i64