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>) -> ExtentN<N>
pub fn from_min_and_shape(minimum: PointN<N>, shape: PointN<N>) -> ExtentN<N>
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>) -> ExtentN<N>
pub fn with_minimum(&self, new_min: PointN<N>) -> ExtentN<N>
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>) -> ExtentN<N>
pub fn add_to_shape(&self, delta: PointN<N>) -> ExtentN<N>
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>,
) -> ExtentN<N>
pub fn from_min_and_lub( minimum: PointN<N>, least_upper_bound: PointN<N>, ) -> ExtentN<N>
An alternative representation of an extent as the minimum point and least upper bound.
Sourcepub fn intersection(&self, other: &ExtentN<N>) -> ExtentN<N>
pub fn intersection(&self, other: &ExtentN<N>) -> ExtentN<N>
Returns the extent containing only the points in both self and other.
Sourcepub fn is_subset_of(&self, other: &ExtentN<N>) -> bool
pub fn is_subset_of(&self, other: &ExtentN<N>) -> 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>) -> ExtentN<N>
pub fn from_min_and_max(minimum: PointN<N>, max: PointN<N>) -> ExtentN<N>
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>) -> ExtentN<N>
pub fn from_corners(p1: PointN<N>, p2: PointN<N>) -> ExtentN<N>
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<ExtentN<N>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ExtentN<N>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<N> Serialize for ExtentN<N>where
N: Serialize,
impl<N> Serialize for ExtentN<N>where
N: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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 for ExtentN<N>where
N: Eq,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§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.