nx_river_quality.nx
buildroot/runtime/nx_river_quality.nx
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
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
structs
| none |
consts
| 34 | const NX_RQ_Q: nx_int = 16384 |
| 35 | const NX_RQ_POINT_STRIDE: nx_int = 2 |
| 37 | const NX_RQ_AXIS_SINUOSITY: nx_int = 0 |
| 38 | const NX_RQ_AXIS_SEG_CONSISTENCY: nx_int = 1 |
| 39 | const NX_RQ_AXIS_MEANDER: nx_int = 2 |
| 40 | const NX_RQ_AXIS_ENDPOINT_DISP: nx_int = 3 |
| 41 | const NX_RQ_AXIS_NO_REVERSAL: nx_int = 4 |
| 42 | const NX_RQ_AXIS_COUNT: nx_int = 5 |
functions
| 45 | func _rq_isqrt(n: nx_int) -> nx_int |
| 57 | func _rq_segment_total(points: *i64, n: nx_int) -> nx_int |
| 69 | func _rq_straight_len(points: *i64, n: nx_int) -> nx_int |
| 76 | func _rq_sinuosity_q14(points: *i64, n: nx_int) -> nx_int |
| 99 | func _rq_seg_consistency_q14(points: *i64, n: nx_int) -> nx_int |
| 135 | func _rq_meander_q14(points: *i64, n: nx_int) -> nx_int |
| 179 | func _rq_endpoint_disp_q14(points: *i64, n: nx_int) -> nx_int |
| 204 | func _rq_no_reversal_q14(points: *i64, n: nx_int) -> nx_int called by 1: nx_river_quality_grade |
| 236 | func nx_river_quality_grade( |
| 256 | func main() -> i64 |