BoxN

Struct BoxN 

Source
pub struct BoxN<const N: usize, T, L = Inclusive, R = L>(/* private fields */);
Expand description

n-dimensional axis-aligned box as a cartesian product set of intervals, i.g., [a, b)^n.

Implementations§

Source§

impl<const N: usize, T, L, R> BoxN<N, T, L, R>

Source

pub fn from_array(src: [Interval<T, L, R>; N]) -> Self

Source

pub fn into_array(self) -> [Interval<T, L, R>; N]

Source§

impl<T, L, R> BoxN<2, T, L, R>

Source

pub fn new(x: Interval<T, L, R>, y: Interval<T, L, R>) -> Self

Source§

impl<T, L, R> BoxN<3, T, L, R>

Source

pub fn new( x: Interval<T, L, R>, y: Interval<T, L, R>, z: Interval<T, L, R>, ) -> Self

Source§

impl<T, L, R> BoxN<4, T, L, R>

Source

pub fn new( x: Interval<T, L, R>, y: Interval<T, L, R>, z: Interval<T, L, R>, w: Interval<T, L, R>, ) -> Self

Source§

impl<const N: usize, T: PartialOrd + Clone, L: BoundaryOf<Left>, R: BoundaryOf<Right>> BoxN<N, T, L, R>

Source

pub fn try_between(a: &[T; N], b: &[T; N]) -> Option<Self>
where T: Into<Bound<T, L>> + Into<Bound<T, R>>,

use inter_val::{Box2, Exclusive};
let a: Box2<i32> = Box2::try_between(&[0, 0], &[10, 20]).unwrap();
assert_eq!(a.x.inf(), &0);
assert_eq!(a.y.sup(), &20);

assert!(Box2::<i32, Exclusive>::try_between(&[0, 0], &[0, 1]).is_none());
Source

pub fn between(a: &[T; N], b: &[T; N]) -> Self
where T: Into<Bound<T, L>> + Into<Bound<T, R>>,

use inter_val::Box2;
let a: Box2<i32> = Box2::between(&[0, 0], &[10, 20]);
assert_eq!(a.inf(), [0, 0]);
assert_eq!(a.sup(), [10, 20]);
Source

pub fn inf(&self) -> NDim<N, T>

Source

pub fn sup(&self) -> NDim<N, T>

Source

pub fn contains(&self, t: &[T; N]) -> bool

Source

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

Source

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

Source

pub fn closure(&self) -> BoxN<N, T, Inclusive>

Source

pub fn interior(&self) -> Option<BoxN<N, T, Exclusive>>

Source

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

Source

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

Source

pub fn dilate(&self, delta: T) -> Self
where T: Add<Output = T> + Sub<Output = T>,

Source

pub fn hull(self, p: &[T; N]) -> Self

use inter_val::Box2;
let a: Box2<i32> = Box2::between(&[0, 0], &[10, 10]);
let b = a.hull(&[20, 5]);
assert_eq!(b, Box2::between(&[0, 0], &[20, 10]));
Source

pub fn span_many<A: Into<Self>>( items: impl IntoIterator<Item = A>, ) -> Option<Self>

Source

pub fn hull_many<'a>( items: impl IntoIterator<Item = &'a [T; N]>, ) -> Option<Self>
where T: Clone + Into<Bound<T, L>> + Into<Bound<T, R>> + 'a,

Source§

impl<const N: usize, T, L, R> BoxN<N, T, L, R>
where T: PartialOrd + Clone + Num, L: BoundaryOf<Left>, R: BoundaryOf<Right>,

Source

pub fn size(&self) -> NDim<N, T>

Source

pub fn measure(&self) -> T

Source§

impl<const N: usize, T: Float, L: BoundaryOf<Left>, R: BoundaryOf<Right>> BoxN<N, T, L, R>

Source

pub fn center(&self) -> NDim<N, T>

Methods from Deref<Target = NDim<N, Interval<T, L, R>>>§

Source

pub fn as_array(&self) -> &[T; N]

Source

pub fn as_array_mut(&mut self) -> &mut [T; N]

Source

pub fn iter(&self) -> Iter<'_, T>

Trait Implementations§

Source§

impl<const N: usize, T, L, R> AsRef<[Interval<T, L, R>; N]> for BoxN<N, T, L, R>

Source§

fn as_ref(&self) -> &[Interval<T, L, R>; N]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<const N: usize, T: Clone, L: Clone, R: Clone> Clone for BoxN<N, T, L, R>

Source§

fn clone(&self) -> BoxN<N, T, L, R>

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<const N: usize, T: Debug, L: Debug, R: Debug> Debug for BoxN<N, T, L, R>

Source§

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

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

impl<const N: usize, T, L, R> Deref for BoxN<N, T, L, R>

Source§

type Target = NDim<N, Interval<T, L, R>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<const N: usize, T, L, R> DerefMut for BoxN<N, T, L, R>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<const N: usize, T, L, R> From<[Interval<T, L, R>; N]> for BoxN<N, T, L, R>

Source§

fn from(src: [Interval<T, L, R>; N]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize, T, L, R> From<BoxN<N, T, L, R>> for [Interval<T, L, R>; N]

Source§

fn from(src: BoxN<N, T, L, R>) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize, T: PartialEq, L: PartialEq, R: PartialEq> PartialEq for BoxN<N, T, L, R>

Source§

fn eq(&self, other: &BoxN<N, T, L, R>) -> 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<const N: usize, T: Copy, L: Copy, R: Copy> Copy for BoxN<N, T, L, R>

Source§

impl<const N: usize, T: Eq, L: Eq, R: Eq> Eq for BoxN<N, T, L, R>

Source§

impl<const N: usize, T, L, R> StructuralPartialEq for BoxN<N, T, L, R>

Auto Trait Implementations§

§

impl<const N: usize, T, L, R> Freeze for BoxN<N, T, L, R>
where T: Freeze, L: Freeze, R: Freeze,

§

impl<const N: usize, T, L, R> RefUnwindSafe for BoxN<N, T, L, R>

§

impl<const N: usize, T, L, R> Send for BoxN<N, T, L, R>
where T: Send, L: Send, R: Send,

§

impl<const N: usize, T, L, R> Sync for BoxN<N, T, L, R>
where T: Sync, L: Sync, R: Sync,

§

impl<const N: usize, T, L, R> Unpin for BoxN<N, T, L, R>
where T: Unpin, L: Unpin, R: Unpin,

§

impl<const N: usize, T, L, R> UnwindSafe for BoxN<N, T, L, R>
where T: UnwindSafe, L: UnwindSafe, R: 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.