pub struct NeighborGrid { /* private fields */ }Expand description
Per-tick neighbour grid for the crowd models.
Typical usage:
ⓘ
let mut grid = NeighborGrid::new(1.0);
for _step in 0..num_steps {
grid.rebuild(&peds);
social_force::step_with_grid(&mut peds, &walls, ¶ms, dt, &grid);
}Implementations§
Source§impl NeighborGrid
impl NeighborGrid
Sourcepub fn new(cell_size: f64) -> Self
pub fn new(cell_size: f64) -> Self
Construct a grid with the given cell size (metres).
Choose cell_size close to the dominant model cutoff — e.g.
1.0 m for Social Force with default b_ped, 3.0 m for
Optimal Steps with default ped_range, or the output of
recommended_cell_size.
§Panics
Panics if cell_size is not strictly positive.
Sourcepub fn rebuild(&mut self, peds: &[Pedestrian])
pub fn rebuild(&mut self, peds: &[Pedestrian])
Clear the grid and re-insert every pedestrian keyed by its
slice index cast to u64.
Sourcepub fn for_each_neighbor<F>(
&self,
i: usize,
radius: f64,
peds: &[Pedestrian],
f: F,
)
pub fn for_each_neighbor<F>( &self, i: usize, radius: f64, peds: &[Pedestrian], f: F, )
Invoke f(j, pos_j, ped_j) for every pedestrian within
radius of pos_i, skipping index i.
peds must be the same slice that was passed to
rebuild; the grid stores only indices and
positions, so the caller provides the slice for the actual
pedestrian record lookup.
Sourcepub fn inner(&self) -> &UniformGrid2
pub fn inner(&self) -> &UniformGrid2
Underlying grid, for diagnostics or custom queries.
Trait Implementations§
Source§impl Clone for NeighborGrid
impl Clone for NeighborGrid
Source§fn clone(&self) -> NeighborGrid
fn clone(&self) -> NeighborGrid
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NeighborGrid
impl RefUnwindSafe for NeighborGrid
impl Send for NeighborGrid
impl Sync for NeighborGrid
impl Unpin for NeighborGrid
impl UnsafeUnpin for NeighborGrid
impl UnwindSafe for NeighborGrid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more