pub struct CuRegion<T, const N: usize>{
pub start: CuPoint<T, N>,
pub end: CuPoint<T, N>,
}
Expand description
Represents an axis aligned cuboid region in N-dimensional Euclidean space whose coordinates are numeric type T
Fields§
§start: CuPoint<T, N>
§end: CuPoint<T, N>
Trait Implementations§
source§impl<T, const N: usize> KdRegion for CuRegion<T, N>
impl<T, const N: usize> KdRegion for CuRegion<T, N>
type Point = CuPoint<T, N>
source§fn split(&self, point: &Self::Point, layer: usize) -> (Self, Self)
fn split(&self, point: &Self::Point, layer: usize) -> (Self, Self)
Given a point
p
in this region A
and a layer l
, split A
into two subregions B
and C
so that: Read moresource§fn min_sqdist(&self, point: &Self::Point) -> T
fn min_sqdist(&self, point: &Self::Point) -> T
Return the minimal squared distance any point in this region could have to a given point.
The return value must be
<= KdPoint::sqdist
between the given point and any point within this region.
It’s safe to return a smaller value, or even always return Distance::zero()
, but this degrades performance because
we can’t prune subtrees from the search.
If B
is a subregion of A
and p
is a point not in A
, then B.min_sqdist(p) >= A.min_sqdist(p)
source§fn max_sqdist(&self, point: &Self::Point) -> Option<T>
fn max_sqdist(&self, point: &Self::Point) -> Option<T>
Return the maximal squared distance any point in this region could have to a given point, or
None
if infinite.
The return value must be >= KdPoint::sqdist
between the given point and any point within this region.
None
is considered infinitely far away. It’s safe to return a larger value, or even always return None
,
but this may degrade performace for some queries that cull based on minimal distance.
Currently, this only happens for kdtree::KdTree::k_closest
where [kdtree::QueryOptions::lower_bound
] is kdtree::QueryBound::SqDist
.
If B
is a subregion of A
and p
is a point not in A
, then B.max_sqdist(p) <= A.max_sqdist(p)
.source§fn might_overlap(&self, other: &Self) -> bool
fn might_overlap(&self, other: &Self) -> bool
Return true if this region and another region might overlap, or false if they are definitely disjoint.
Conservative implementors can always return true.
Currently only used by
kdtree::KdTree::k_closest
if kdtree::QueryOptions::outer_bound
is kdtree::QueryBound::Region
.source§fn is_superset(&self, other: &Self) -> bool
fn is_superset(&self, other: &Self) -> bool
Return true if this region is DEFINITELY a superset of another region, or false if it is not.
A
may be a superset of B
even if B
is internally tangent to A
or B
is A
.
May return false even if self is a superset of other, if it would be expensive or difficult to compute correctly.
Currently only used by kdtree::KdTree::k_closest
if kdtree::QueryOptions::inner_bound
is kdtree::QueryBound::Region
source§fn extend(&mut self, point: &Self::Point)
fn extend(&mut self, point: &Self::Point)
Given a region and a point possibly not in the region, extend the region to include the point if
necessary. The concrete requirements this places on the implementation are that
self.min_sqdist(q)
can only decrease or remain the same for any fixed q
, and in particular self.extend(q)
should cause self.min_sqdist(q)
to be 0
if it wasn’t alreadysource§fn single_point(point: &Self::Point) -> Self
fn single_point(point: &Self::Point) -> Self
Create a region consisting of a single point. For cuboid regions for example, this is represented as
a cuboid whose inclusive “start” and “end” points are both the same. Types implementing this trait
should be able to represent single points fairly well, but because of the conservative nature of
everything, it is acceptable to fudge it by having a very small region containing the point.
It’s not necessary for types to be able to represent an empty region well or even at all.
impl<T: Ord + Copy + NumRef, const N: usize> Copy for CuRegion<T, N>
Auto Trait Implementations§
impl<T, const N: usize> RefUnwindSafe for CuRegion<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for CuRegion<T, N>where
T: Send,
impl<T, const N: usize> Sync for CuRegion<T, N>where
T: Sync,
impl<T, const N: usize> Unpin for CuRegion<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for CuRegion<T, N>where
T: UnwindSafe,
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