pub struct ExtentN<N> {
pub minimum: PointN<N>,
pub shape: PointN<N>,
}
Expand description
An N-dimensional extent. This is mathematically the Cartesian product of a half-closed interval [a, b)
in each dimension.
You can also just think of it as an axis-aligned box with some shape and a minimum point. When doing queries against lattice
maps, this is the primary structure used to determine the bounds of your query.
Fields§
§minimum: PointN<N>
The least point contained in the extent.
shape: PointN<N>
The length of each dimension.
Implementations§
Source§impl<N> ExtentN<N>
impl<N> ExtentN<N>
Sourcepub fn from_min_and_shape(minimum: PointN<N>, shape: PointN<N>) -> Self
pub fn from_min_and_shape(minimum: PointN<N>, shape: PointN<N>) -> Self
The default representation of an extent as the minimum point and shape.
Source§impl<N> ExtentN<N>
impl<N> ExtentN<N>
pub fn volume(&self) -> <PointN<N> as Point>::Scalar
Sourcepub fn with_minimum(&self, new_min: PointN<N>) -> Self
pub fn with_minimum(&self, new_min: PointN<N>) -> Self
Translate the extent such that it has new_min
as it’s new minimum.
Sourcepub fn least_upper_bound(&self) -> PointN<N>
pub fn least_upper_bound(&self) -> PointN<N>
The least point p
for which all points q
in the extent satisfy q < p
.
Sourcepub fn contains(&self, p: PointN<N>) -> bool
pub fn contains(&self, p: PointN<N>) -> bool
Returns true
iff the point p
is contained in this extent.
Sourcepub fn add_to_shape(&self, delta: PointN<N>) -> Self
pub fn add_to_shape(&self, delta: PointN<N>) -> Self
Resize the extent by mutating its shape
by delta
.
Source§impl<N> ExtentN<N>where
PointN<N>: IntegerPoint<N>,
impl<N> ExtentN<N>where
PointN<N>: IntegerPoint<N>,
Sourcepub fn num_points(&self) -> usize
pub fn num_points(&self) -> usize
The number of points contained in the extent.
Sourcepub fn from_min_and_lub(
minimum: PointN<N>,
least_upper_bound: PointN<N>,
) -> Self
pub fn from_min_and_lub( minimum: PointN<N>, least_upper_bound: PointN<N>, ) -> Self
An alternative representation of an extent as the minimum point and least upper bound.
Sourcepub fn intersection(&self, other: &Self) -> Self
pub fn intersection(&self, other: &Self) -> Self
Returns the extent containing only the points in both self
and other
.
Sourcepub fn is_subset_of(&self, other: &Self) -> bool
pub fn is_subset_of(&self, other: &Self) -> bool
Returns true
iff the intersection of self
and other
is equal to self
.
Sourcepub fn from_min_and_max(minimum: PointN<N>, max: PointN<N>) -> Self
pub fn from_min_and_max(minimum: PointN<N>, max: PointN<N>) -> Self
An alternative representation of an integer extent as the minimum point and maximum point. This only works for integer extents, where there is a unique maximum point.
Sourcepub fn from_corners(p1: PointN<N>, p2: PointN<N>) -> Self
pub fn from_corners(p1: PointN<N>, p2: PointN<N>) -> Self
Constructs the unique extent with both p1
and p2
as corners.
Sourcepub fn iter_points(&self) -> <PointN<N> as IterExtent<N>>::PointIter
pub fn iter_points(&self) -> <PointN<N> as IterExtent<N>>::PointIter
Iterate over all points in the extent.
let extent = Extent3i::from_min_and_shape(PointN([0, 0, 0]), PointN([2, 2, 1]));
let points = extent.iter_points().collect::<Vec<_>>();
assert_eq!(points, vec![
PointN([0, 0, 0]), PointN([1, 0, 0]), PointN([0, 1, 0]), PointN([1, 1, 0])
]);
Trait Implementations§
Source§impl<T> AddAssign<PointN<T>> for ExtentN<T>
impl<T> AddAssign<PointN<T>> for ExtentN<T>
Source§fn add_assign(&mut self, rhs: PointN<T>)
fn add_assign(&mut self, rhs: PointN<T>)
+=
operation. Read moreSource§impl<'de, N> Deserialize<'de> for ExtentN<N>where
N: Deserialize<'de>,
impl<'de, N> Deserialize<'de> for ExtentN<N>where
N: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T> SubAssign<PointN<T>> for ExtentN<T>
impl<T> SubAssign<PointN<T>> for ExtentN<T>
Source§fn sub_assign(&mut self, rhs: PointN<T>)
fn sub_assign(&mut self, rhs: PointN<T>)
-=
operation. Read moreimpl<N> Copy for ExtentN<N>
impl<N: Eq> Eq for ExtentN<N>
Auto Trait Implementations§
impl<N> Freeze for ExtentN<N>where
N: Freeze,
impl<N> RefUnwindSafe for ExtentN<N>where
N: RefUnwindSafe,
impl<N> Send for ExtentN<N>where
N: Send,
impl<N> Sync for ExtentN<N>where
N: Sync,
impl<N> Unpin for ExtentN<N>where
N: Unpin,
impl<N> UnwindSafe for ExtentN<N>where
N: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.