Crates.io | halton |
lib.rs | halton |
version | 0.2.1 |
source | src |
created_at | 2018-04-15 16:49:39.742488 |
updated_at | 2019-12-06 05:23:03.277298 |
description | A module for generating Halton sequences |
homepage | https://github.com/matsadler/halton |
repository | https://github.com/matsadler/halton |
max_upload_size | |
id | 60771 |
size | 32,275 |
A module for generating Halton sequences, a deterministic low discrepancy sequence that appears to be random. The uniform distribution and repeatability makes the sequence ideal for choosing sample points or placing objects in 2D or 3D space.
use halton::Sequence;
let mut grid = [["."; 10]; 10];
let alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").skip(1).take(26);
let seq = Sequence::new(2).zip(Sequence::new(3)).zip(alpha);
for ((x, y), c) in seq {
grid[(y * 10.0) as usize][(x * 10.0) as usize] = c;
}
for row in grid.iter() {
println!("{}", row.join(" "));
}
Outputs:
. . R . . I . . . .
. L . . . . U C . .
X . . F . . . . . O
. . . J . A . . . .
. D . . . . M S . .
P . . . V . . . G .
. . B . . Y . . . .
. T . . . . E . K .
H . . . N . . . . W
. . . Z . Q . . . .
This project is licensed under either of
at your option.