pub struct ContinuousSpace3D { /* private fields */ }Expand description
3D continuous space with uniform-grid spatial hashing for fast neighbor queries.
The space spans [0, extent_x) x [0, extent_y) x [0, extent_z).
An internal grid of cells (side length = spacing) accelerates
nearby_ids_euclidean to O(k) where k is the number of agents in the
neighborhood, rather than O(n).
Implementations§
Source§impl ContinuousSpace3D
impl ContinuousSpace3D
Sourcepub fn new(
extent_x: f64,
extent_y: f64,
extent_z: f64,
periodic: bool,
spacing: f64,
) -> Result<Self, ContinuousSpace3DConfigError>
pub fn new( extent_x: f64, extent_y: f64, extent_z: f64, periodic: bool, spacing: f64, ) -> Result<Self, ContinuousSpace3DConfigError>
Create a new 3D continuous space.
§Arguments
extent_x,extent_y,extent_z- space dimensions.periodic- whether boundaries wrap.spacing- cell side length for the spatial hash grid.
Sourcepub fn agent_position(&self, id: AgentId) -> Option<&ContinuousPos3D>
pub fn agent_position(&self, id: AgentId) -> Option<&ContinuousPos3D>
Look up the current position of an agent.
Sourcepub fn move_agent_pos(
&mut self,
id: AgentId,
new_pos: ContinuousPos3D,
) -> Result<ContinuousPos3D, ContinuousSpace3DError>
pub fn move_agent_pos( &mut self, id: AgentId, new_pos: ContinuousPos3D, ) -> Result<ContinuousPos3D, ContinuousSpace3DError>
Move an agent to a new position, updating the spatial hash.
Returns the (possibly normalized) final position, or an error if the position is out of bounds in a non-periodic space.
Sourcepub fn nearby_ids_euclidean(
&self,
pos: &ContinuousPos3D,
radius: f64,
) -> Vec<AgentId> ⓘ
pub fn nearby_ids_euclidean( &self, pos: &ContinuousPos3D, radius: f64, ) -> Vec<AgentId> ⓘ
Find all agent IDs within Euclidean distance radius of pos.
Respects periodic boundaries when enabled.
Trait Implementations§
Source§impl Clone for ContinuousSpace3D
impl Clone for ContinuousSpace3D
Source§fn clone(&self) -> ContinuousSpace3D
fn clone(&self) -> ContinuousSpace3D
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 moreSource§impl Debug for ContinuousSpace3D
impl Debug for ContinuousSpace3D
Source§impl<A> SpaceInteraction<A> for ContinuousSpace3Dwhere
A: PositionedAgent<Position = ContinuousPos3D>,
impl<A> SpaceInteraction<A> for ContinuousSpace3Dwhere
A: PositionedAgent<Position = ContinuousPos3D>,
Source§type Error = ContinuousSpace3DError
type Error = ContinuousSpace3DError
Error type for space operations.
Source§fn random_position<R: RngCore>(&self, rng: &mut R) -> A::Position
fn random_position<R: RngCore>(&self, rng: &mut R) -> A::Position
Generate a random valid position within this space.
Source§fn add_agent(&mut self, agent: &A) -> Result<(), Self::Error>
fn add_agent(&mut self, agent: &A) -> Result<(), Self::Error>
Register an agent with the space at its current position.
impl Space for ContinuousSpace3D
Auto Trait Implementations§
impl Freeze for ContinuousSpace3D
impl RefUnwindSafe for ContinuousSpace3D
impl Send for ContinuousSpace3D
impl Sync for ContinuousSpace3D
impl Unpin for ContinuousSpace3D
impl UnsafeUnpin for ContinuousSpace3D
impl UnwindSafe for ContinuousSpace3D
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