Trait sif_rtree::Point

source ·
pub trait Point: Clone {
    type Coord: Num + Copy + PartialOrd;

    const DIM: usize;

    // Required methods
    fn coord(&self, axis: usize) -> Self::Coord;
    fn build<F>(f: F) -> Self
       where F: FnMut(usize) -> Self::Coord;

    // Provided methods
    fn min(&self, other: &Self) -> Self { ... }
    fn max(&self, other: &Self) -> Self { ... }
}
Expand description

Defines a finite-dimensional space in terms of coordinate values along a chosen set of axes

Required Associated Types§

source

type Coord: Num + Copy + PartialOrd

The type of the coordinate values

Required Associated Constants§

source

const DIM: usize

The dimension of the underlying space

Required Methods§

source

fn coord(&self, axis: usize) -> Self::Coord

Access the coordinate value of the point along the given axis

source

fn build<F>(f: F) -> Self
where F: FnMut(usize) -> Self::Coord,

Builds a new point by specifying its coordinate values along each axis

§Example
use sif_rtree::Point;

fn scale<P>(point: P, factor: P::Coord) -> P
where
    P: Point,
{
    P::build(|axis| point.coord(axis) * factor)
}

Provided Methods§

source

fn min(&self, other: &Self) -> Self

Computes the point which has the minimum coordinate values of self and other along each axis

The default implementation is based on build and PartialOrd and assumes that coordinate values are finite.

source

fn max(&self, other: &Self) -> Self

Computes the point which has the maximum coordinate values of self and other along each axis

The default implementation is based on build and PartialOrd and assumes that coordinate values are finite.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T, const N: usize> Point for [T; N]
where T: Num + Copy + PartialOrd,

N-dimensional space using Euclidean distance

source§

const DIM: usize = N

§

type Coord = T

source§

fn coord(&self, axis: usize) -> Self::Coord

source§

fn build<F>(f: F) -> Self
where F: FnMut(usize) -> Self::Coord,

Implementors§