Struct ExtentN

Source
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>

Source

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>
where PointN<N>: Point,

Source

pub fn volume(&self) -> <PointN<N> as Point>::Scalar

Source

pub fn with_minimum(&self, new_min: PointN<N>) -> Self

Translate the extent such that it has new_min as it’s new minimum.

Source

pub fn least_upper_bound(&self) -> PointN<N>

The least point p for which all points q in the extent satisfy q < p.

Source

pub fn contains(&self, p: PointN<N>) -> bool

Returns true iff the point p is contained in this extent.

Source

pub fn add_to_shape(&self, delta: PointN<N>) -> Self

Resize the extent by mutating its shape by delta.

Source

pub fn padded(&self, pad_amount: <PointN<N> as Point>::Scalar) -> Self
where <PointN<N> as Point>::Scalar: Add<Output = <PointN<N> as Point>::Scalar>,

Returns a new extent that’s been padded on all borders by pad_amount.

Source§

impl<N> ExtentN<N>
where PointN<N>: IntegerPoint<N>,

Source

pub fn num_points(&self) -> usize

The number of points contained in the extent.

Source

pub fn is_empty(&self) -> bool

Returns true iff the number of points in the extent is 0.

Source

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.

Source

pub fn intersection(&self, other: &Self) -> Self

Returns the extent containing only the points in both self and other.

Source

pub fn is_subset_of(&self, other: &Self) -> bool

Returns true iff the intersection of self and other is equal to self.

Source

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.

Source

pub fn max(&self) -> PointN<N>

The unique greatest point in the extent.

Source

pub fn from_corners(p1: PointN<N>, p2: PointN<N>) -> Self

Constructs the unique extent with both p1 and p2 as corners.

Source

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> Add<PointN<T>> for ExtentN<T>
where PointN<T>: Add<Output = PointN<T>>,

Source§

type Output = ExtentN<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: PointN<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign<PointN<T>> for ExtentN<T>
where Self: Copy + Add<PointN<T>, Output = ExtentN<T>>,

Source§

fn add_assign(&mut self, rhs: PointN<T>)

Performs the += operation. Read more
Source§

impl<N> Clone for ExtentN<N>
where PointN<N>: Clone,

Source§

fn clone(&self) -> Self

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<N: Debug> Debug for ExtentN<N>

Source§

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

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

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Mul<PointN<T>> for ExtentN<T>
where PointN<T>: Copy + Mul<Output = PointN<T>>,

Source§

type Output = ExtentN<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: PointN<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<N> PartialEq for ExtentN<N>
where PointN<N>: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N> Serialize for ExtentN<N>
where N: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Sub<PointN<T>> for ExtentN<T>
where PointN<T>: Sub<Output = PointN<T>>,

Source§

type Output = ExtentN<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: PointN<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> SubAssign<PointN<T>> for ExtentN<T>
where Self: Copy + Sub<PointN<T>, Output = ExtentN<T>>,

Source§

fn sub_assign(&mut self, rhs: PointN<T>)

Performs the -= operation. Read more
Source§

impl<N> Copy for ExtentN<N>
where PointN<N>: Copy,

Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: Copy + PartialEq + Debug + Any,

Source§

fn inlined_clone(&self) -> T

Performance hack: Clone doesn’t get inlined for Copy types in debug mode, so make it inline anyway.
Source§

fn is<T>() -> bool
where T: Scalar,

Tests if Self the same as the type T Read more
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<T, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

Source§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,