pub trait Envelope:
Clone
+ PartialEq
+ Debug {
type Point: Point;
Show 14 methods
// Required methods
fn new_empty() -> Self;
fn contains_point(&self, point: &Self::Point) -> bool;
fn contains_envelope(&self, aabb: &Self) -> bool;
fn merge(&mut self, other: &Self);
fn merged(&self, other: &Self) -> Self;
fn intersects(&self, other: &Self) -> bool;
fn intersection_area(&self, other: &Self) -> <Self::Point as Point>::Scalar;
fn area(&self) -> <Self::Point as Point>::Scalar;
fn distance_2(&self, point: &Self::Point) -> <Self::Point as Point>::Scalar;
fn min_max_dist_2(
&self,
point: &Self::Point,
) -> <Self::Point as Point>::Scalar;
fn center(&self) -> Self::Point;
fn perimeter_value(&self) -> <Self::Point as Point>::Scalar;
fn sort_envelopes<T: RTreeObject<Envelope = Self>>(
axis: usize,
envelopes: &mut [T],
);
fn partition_envelopes<T: RTreeObject<Envelope = Self>>(
axis: usize,
envelopes: &mut [T],
selection_size: usize,
);
}
Expand description
An envelope type that encompasses some child nodes.
An envelope defines how different bounding boxes of inserted children in an r-tree can interact, e.g. how they can be merged or intersected. This trait is not meant to be implemented by the user. Currently, only one implementation exists (crate::AABB) and should be used.
Required Associated Types§
Required Methods§
Sourcefn contains_point(&self, point: &Self::Point) -> bool
fn contains_point(&self, point: &Self::Point) -> bool
Returns true if a point is contained within this envelope.
Sourcefn contains_envelope(&self, aabb: &Self) -> bool
fn contains_envelope(&self, aabb: &Self) -> bool
Returns true if another envelope is fully contained within self
.
Sourcefn merged(&self, other: &Self) -> Self
fn merged(&self, other: &Self) -> Self
Returns the minimal envelope containing self
and another envelope.
Sourcefn intersects(&self, other: &Self) -> bool
fn intersects(&self, other: &Self) -> bool
Returns true if self
and other
intersect. The intersection might be
of zero area (the two envelopes only touching each other).
Sourcefn intersection_area(&self, other: &Self) -> <Self::Point as Point>::Scalar
fn intersection_area(&self, other: &Self) -> <Self::Point as Point>::Scalar
Returns the area of the intersection of self
and another envelope.
Sourcefn area(&self) -> <Self::Point as Point>::Scalar
fn area(&self) -> <Self::Point as Point>::Scalar
Returns this envelope’s area. Must be at least 0.
Sourcefn distance_2(&self, point: &Self::Point) -> <Self::Point as Point>::Scalar
fn distance_2(&self, point: &Self::Point) -> <Self::Point as Point>::Scalar
Returns the squared distance between the envelope’s border and a point.
§Notes
- While euclidean distance will be the correct choice for most use cases, any distance metric fulfilling the usual axioms can be used when implementing this method
- Implementers must ensure that the distance metric used matches that of crate::PointDistance::distance_2
Sourcefn min_max_dist_2(&self, point: &Self::Point) -> <Self::Point as Point>::Scalar
fn min_max_dist_2(&self, point: &Self::Point) -> <Self::Point as Point>::Scalar
Returns the squared min-max distance, a concept that helps to find nearest neighbors efficiently.
Visually, if an AABB and a point are given, the min-max distance returns the distance at which we can be assured that an element must be present. This serves as an upper bound during nearest neighbor search.
§References
Sourcefn perimeter_value(&self) -> <Self::Point as Point>::Scalar
fn perimeter_value(&self) -> <Self::Point as Point>::Scalar
Returns a value proportional to the envelope’s perimeter.
Sourcefn sort_envelopes<T: RTreeObject<Envelope = Self>>(
axis: usize,
envelopes: &mut [T],
)
fn sort_envelopes<T: RTreeObject<Envelope = Self>>( axis: usize, envelopes: &mut [T], )
Sorts a given set of objects with envelopes along one of their axes.
Sourcefn partition_envelopes<T: RTreeObject<Envelope = Self>>(
axis: usize,
envelopes: &mut [T],
selection_size: usize,
)
fn partition_envelopes<T: RTreeObject<Envelope = Self>>( axis: usize, envelopes: &mut [T], selection_size: usize, )
Partitions objects with an envelope along a certain axis.
After calling this, envelopes[0..selection_size] are all smaller than envelopes[selection_size + 1..].
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.