pub fn thin_random(
points: &[ThinPoint3],
target_count: usize,
seed: u64,
) -> Vec<ThinPoint3>Expand description
Random thinning: keep target_count points selected uniformly without
replacement via a deterministic Fisher-Yates shuffle.
The shuffle is driven by an internal LCG (lcg_next) rather than the
rand crate, in keeping with the project’s no rand dependency policy.
Identical seed values produce identical outputs across runs and across
platforms (the LCG state is a u64 and only wrapping_* arithmetic is
used). Output points are returned in input order — the shuffle is applied
to an index vector, the first target_count indices are retained, and the
final point vector is materialised in the original order.
Edge cases:
- Empty input returns an empty
Vec. target_count >= points.len()returns a copy of the input (no thinning).target_count == 0returns an emptyVec.
§Examples
use oxigdal_algorithms::raster::{ThinPoint3, thin_random};
let pts: Vec<_> = (0..100)
.map(|i| ThinPoint3::new(i as f64, 0.0, 0.0))
.collect();
let a = thin_random(&pts, 10, 0xC0FFEE);
let b = thin_random(&pts, 10, 0xC0FFEE);
assert_eq!(a, b); // deterministic for a given seed
assert_eq!(a.len(), 10);