ExtentN

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>) -> ExtentN<N>

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>) -> ExtentN<N>

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>) -> ExtentN<N>

Resize the extent by mutating its shape by delta.

Source

pub fn padded(&self, pad_amount: <PointN<N> as Point>::Scalar) -> ExtentN<N>
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>, ) -> ExtentN<N>

An alternative representation of an extent as the minimum point and least upper bound.

Source

pub fn intersection(&self, other: &ExtentN<N>) -> ExtentN<N>

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

Source

pub fn is_subset_of(&self, other: &ExtentN<N>) -> 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>) -> 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.

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>) -> ExtentN<N>

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>) -> <ExtentN<T> as Add<PointN<T>>>::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign<PointN<T>> for ExtentN<T>
where ExtentN<T>: 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) -> ExtentN<N>

Returns a duplicate 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 for ExtentN<N>
where N: Debug,

Source§

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

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<ExtentN<N>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

impl From<Octant> for ExtentN<[i32; 3]>

Source§

fn from(octant: Octant) -> ExtentN<[i32; 3]>

Converts to this type from the input type.
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>) -> <ExtentN<T> as Mul<PointN<T>>>::Output

Performs the * operation. Read more
Source§

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

Source§

fn eq(&self, other: &ExtentN<N>) -> 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 as Serializer>::Ok, <__S as Serializer>::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>) -> <ExtentN<T> as Sub<PointN<T>>>::Output

Performs the - operation. Read more
Source§

impl<T> SubAssign<PointN<T>> for ExtentN<T>
where ExtentN<T>: 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 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> 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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>,