Function iter_num_tools::grid_space [−][src]
pub fn grid_space<T, R, S, const N: usize>(
range: R,
steps: S
) -> GridSpace<T, N>ⓘ where
R: IntoGridSpace<T, S, N>,
Expand description
Creates a linear grid space over range with a fixed number of width and height steps
use iter_num_tools::grid_space; let it = grid_space([0.0, 0.0]..[1.0, 2.0], [2, 4]); itertools::assert_equal(it, vec![ [0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.0, 1.5], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [0.5, 1.5], ]); // inclusive and with a single step count let it = grid_space([0.0, 0.0]..=[1.0, 2.0], 3); itertools::assert_equal(it, vec![ [0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.5, 0.0], [0.5, 1.0], [0.5, 2.0], [1.0, 0.0], [1.0, 1.0], [1.0, 2.0], ]); // even 3d spaces let it = grid_space([0, 0, 0]..=[1, 1, 1], 2); itertools::assert_equal(it, vec![ [0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1], ]);