[−][src]Trait rstar::Point
Defines a point type that is compatible with rstar.
Point
is implemented out of the box for arrays like [f32; 2]
or [f64; 7]
(up to dimension 9).
Implementation example
Supporting a custom point type might look like this:
use rstar::Point; #[derive(Copy, Clone, PartialEq, Debug)] struct IntegerPoint { x: i32, y: i32 } impl Point for IntegerPoint { type Scalar = i32; const DIMENSIONS: usize = 2; fn generate(generator: impl Fn(usize) -> Self::Scalar) -> Self { IntegerPoint { x: generator(0), y: generator(1) } } fn nth(&self, index: usize) -> Self::Scalar { match index { 0 => self.x, 1 => self.y, _ => unreachable!() } } fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar { match index { 0 => &mut self.x, 1 => &mut self.y, _ => unreachable!() } } }
Associated Types
Loading content...Associated Constants
const DIMENSIONS: usize
The number of dimensions of this point type.
Required methods
fn generate(generator: impl Fn(usize) -> Self::Scalar) -> Self
Creates a new point value with given values for each dimension.
The value that each dimension should be initialized with is given by the parameter generator
.
Calling generator(n)
returns the value of dimension n
, n
will be in the range 0 .. Self::DIMENSIONS
.
fn nth(&self, index: usize) -> Self::Scalar
Returns a single coordinate of this point.
Returns the coordinate indicated by index
. index
is always smaller than Self::DIMENSIONS
.
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
Mutable variant of nth.
Implementations on Foreign Types
impl<S> Point for [S; 2] where
S: RTreeNum,
[src]
S: RTreeNum,
type Scalar = S
const DIMENSIONS: usize
[src]
fn generate(generator: impl Fn(usize) -> S) -> Self
[src]
fn nth(&self, index: usize) -> Self::Scalar
[src]
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
[src]
impl<S> Point for [S; 3] where
S: RTreeNum,
[src]
S: RTreeNum,
type Scalar = S
const DIMENSIONS: usize
[src]
fn generate(generator: impl Fn(usize) -> S) -> Self
[src]
fn nth(&self, index: usize) -> Self::Scalar
[src]
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
[src]
impl<S> Point for [S; 4] where
S: RTreeNum,
[src]
S: RTreeNum,
type Scalar = S
const DIMENSIONS: usize
[src]
fn generate(generator: impl Fn(usize) -> S) -> Self
[src]
fn nth(&self, index: usize) -> Self::Scalar
[src]
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
[src]
impl<S> Point for [S; 5] where
S: RTreeNum,
[src]
S: RTreeNum,
type Scalar = S
const DIMENSIONS: usize
[src]
fn generate(generator: impl Fn(usize) -> S) -> Self
[src]
fn nth(&self, index: usize) -> Self::Scalar
[src]
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
[src]
impl<S> Point for [S; 6] where
S: RTreeNum,
[src]
S: RTreeNum,
type Scalar = S
const DIMENSIONS: usize
[src]
fn generate(generator: impl Fn(usize) -> S) -> Self
[src]
fn nth(&self, index: usize) -> Self::Scalar
[src]
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
[src]
impl<S> Point for [S; 7] where
S: RTreeNum,
[src]
S: RTreeNum,
type Scalar = S
const DIMENSIONS: usize
[src]
fn generate(generator: impl Fn(usize) -> S) -> Self
[src]
fn nth(&self, index: usize) -> Self::Scalar
[src]
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
[src]
impl<S> Point for [S; 8] where
S: RTreeNum,
[src]
S: RTreeNum,
type Scalar = S
const DIMENSIONS: usize
[src]
fn generate(generator: impl Fn(usize) -> S) -> Self
[src]
fn nth(&self, index: usize) -> Self::Scalar
[src]
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
[src]
impl<S> Point for [S; 9] where
S: RTreeNum,
[src]
S: RTreeNum,