Type Definition tpntree::tpntree::SpatialTree

source ·
pub type SpatialTree<T, const N: usize> = TpnTree<Vec<T>, N>;
Expand description

A helper type to work with spatial data bins.

Implementations§

Checks if the tree spans over the coordinates of the provided data.

 let tree = Tree3D::root(1.0);

 assert_eq!(tree.spans(&[0.5,0.5,0.5]), true);
 assert_eq!(tree.spans(&[1.5,0.5,0.5]), false);

Inserts data in the tree with its center closest to the data given the constrains of the division_condition.

The division condition determines when a tree divides and inserts its data into its children. Errors if the tree does not span the data.

 let mut tree = Tree3D::root(1.0);
  
assert!(tree.insert_by_coordinates([1.0, 0.0, -1.0], &|_| false).is_ok());

Return the tree closest to the given data coordinates.

Errors if the tree does not span the data.

 let mut tree = Tree3D::root(1.0);
  
tree.insert_by_coordinates([1.0, 0.0, -1.0], &|_| false).expect("Couldn't insert.");
assert!(tree
  .find_by_coordinates(&[0.0, 0.0, 0.0])
  .ok()
  .and_then(|tree| tree.data().map(|vec| vec.contains(&[1.0, 0.0, -1.0])))
  .unwrap());