Struct crater::cuboid::CuPoint

source ·
pub struct CuPoint<T, const N: usize>
where T: Ord + Clone + NumRef,
{ /* private fields */ }
Expand description

Represents a point in N-dimensional Euclidean space whose coordinates are numeric type T Wrapping CuPoint<i64, 3> or CuPoint<f64, 3> is a good way to get started quickly if you don’t need a topologically exotic implementation

Implementations§

source§

impl<T, const N: usize> CuPoint<T, N>
where T: Ord + Clone + NumRef,

source

pub fn make(buf: [T; N]) -> Self

make a point with a given value

source

pub fn view(&self) -> &[T; N]

get readonly access to the buffer

source

pub fn extract(self) -> [T; N]

consume the point to mutably access the buffer

Trait Implementations§

source§

impl<T, const N: usize> Clone for CuPoint<T, N>
where T: Ord + Clone + NumRef + Clone,

source§

fn clone(&self) -> CuPoint<T, N>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T, const N: usize> Debug for CuPoint<T, N>
where T: Ord + Clone + NumRef + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, const N: usize> Default for CuPoint<T, N>
where T: Ord + Clone + NumRef,

Generate a default point (all coordinates zero)

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T, const N: usize> Distribution<CuPoint<T, N>> for Uniform<T>
where T: Ord + Clone + NumRef + SampleUniform,

Generate a random point in a square/cube/etc. Given a Uniform distribution sampling from a range, this adds the ability to randomly generate CuPoints whose coordinates are iid (independent and identically distributed) from that range

source§

fn sample<R>(&self, rng: &mut R) -> CuPoint<T, N>
where R: Rng + ?Sized,

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<T, const N: usize> From<[T; N]> for CuPoint<T, N>
where T: Ord + Clone + NumRef,

source§

fn from(buf: [T; N]) -> Self

Converts to this type from the input type.
source§

impl<T, const N: usize> KdPoint for CuPoint<T, N>
where T: Ord + Clone + NumRef,

§

type Distance = T

The type used by sqdist and related KdRegion functions to represent (squared) distance. Must be totally ordered, where greater distances mean points are farther apart. Also must be Clone and have a meaningful minimum value (0)
source§

fn cmp(&self, other: &Self, layer: usize) -> Ordering

Compare two points in some layer of the tree. This generalizes splitting different layers of the tree in different dimensions and is tied to KdRegion::split. Traditionally, points in a KD tree are compared by their 1st coordinate in layer 0, their 2nd in layer 1, …, onto their Kth in layer k - 1, and then in layer K it wraps around to 0 and repeats. So for a 3D KD tree, layer 0 would compare x coordinates with the root having the median x coordinate, all points in the first subtree having x coordinate <=, and all points in the second subtree having x coordinate >=. This method allows for more general strategies, but pushes some of the burden of layer-dependent behavior onto the point type. It’s still possible to just implement a by-coordinate cmp function of course, and this is what the prebuilt CuPoint does.
source§

fn sqdist(&self, other: &Self) -> Self::Distance

The squared distance is more computationally convenient than the proper distance in many cases. The distance function only has to be topologically consistent and totally ordered. See KdRegion::min_sqdist for more info. The return value should be >= Distance::zero().
source§

impl<T, const N: usize> PartialEq for CuPoint<T, N>
where T: Ord + Clone + NumRef + PartialEq,

source§

fn eq(&self, other: &CuPoint<T, N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Ord + Copy + NumRef, const N: usize> Copy for CuPoint<T, N>

source§

impl<T: Ord + Clone + NumRef, const N: usize> Eq for CuPoint<T, N>

source§

impl<T, const N: usize> StructuralPartialEq for CuPoint<T, N>
where T: Ord + Clone + NumRef,

Auto Trait Implementations§

§

impl<T, const N: usize> RefUnwindSafe for CuPoint<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for CuPoint<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for CuPoint<T, N>
where T: Sync,

§

impl<T, const N: usize> Unpin for CuPoint<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for CuPoint<T, N>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V