pub struct DensityGrid { /* private fields */ }Expand description
Spatial density grid for computing agents-per-square-meter.
Implementations§
Source§impl DensityGrid
impl DensityGrid
Sourcepub fn new(
extent_x: f64,
extent_y: f64,
cell_size: f64,
) -> Result<Self, DensityGridError>
pub fn new( extent_x: f64, extent_y: f64, cell_size: f64, ) -> Result<Self, DensityGridError>
Create a new density grid.
Sourcepub fn grid_dimensions(&self) -> (usize, usize)
pub fn grid_dimensions(&self) -> (usize, usize)
Grid dimensions as (width_cells, height_cells).
Sourcepub fn add_position(&mut self, x: f64, y: f64)
pub fn add_position(&mut self, x: f64, y: f64)
Register an agent’s position.
Positions outside the extent are clamped to the nearest edge cell.
Sourcepub fn add_positions(&mut self, positions: impl IntoIterator<Item = (f64, f64)>)
pub fn add_positions(&mut self, positions: impl IntoIterator<Item = (f64, f64)>)
Register multiple agent positions from an iterator of (x, y) pairs.
Sourcepub fn density_at(&self, x: f64, y: f64) -> f64
pub fn density_at(&self, x: f64, y: f64) -> f64
Density (agents per cell area) in the cell containing (x, y).
Sourcepub fn los_at(&self, x: f64, y: f64, criteria: &dyn LosCriteria) -> LosGrade
pub fn los_at(&self, x: f64, y: f64, criteria: &dyn LosCriteria) -> LosGrade
LoS grade for the cell containing (x, y) using the given criteria.
Sourcepub fn density_at_cell(&self, cx: usize, cy: usize) -> f64
pub fn density_at_cell(&self, cx: usize, cy: usize) -> f64
Density for a specific cell index (cx, cy).
Sourcepub fn count_at_cell(&self, cx: usize, cy: usize) -> u32
pub fn count_at_cell(&self, cx: usize, cy: usize) -> u32
Agent count for a specific cell index (cx, cy).
Sourcepub fn max_density(&self) -> f64
pub fn max_density(&self) -> f64
Maximum density across all cells.
Sourcepub fn mean_density_occupied(&self) -> f64
pub fn mean_density_occupied(&self) -> f64
Mean density across occupied cells only.
Returns 0.0 if no cells are occupied.
Sourcepub fn mean_density_all(&self) -> f64
pub fn mean_density_all(&self) -> f64
Mean density across all cells.
Sourcepub fn statistics(&self, criteria: &dyn LosCriteria) -> DensityStatistics
pub fn statistics(&self, criteria: &dyn LosCriteria) -> DensityStatistics
Compute full statistics using the given LoS criteria.
Sourcepub fn total_agents(&self) -> usize
pub fn total_agents(&self) -> usize
Total number of agents registered.
Trait Implementations§
Source§impl Clone for DensityGrid
impl Clone for DensityGrid
Source§fn clone(&self) -> DensityGrid
fn clone(&self) -> DensityGrid
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 DensityGrid
impl RefUnwindSafe for DensityGrid
impl Send for DensityGrid
impl Sync for DensityGrid
impl Unpin for DensityGrid
impl UnsafeUnpin for DensityGrid
impl UnwindSafe for DensityGrid
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