[][src]Struct building_blocks::prelude::PointN

pub struct PointN<N>(pub N);

An N-dimensional point (where N=2 or N=3), which is usually just a primitive array like [i32; 2] or [i32; 3]. It is most convenient to construct points of any dimension as:

use building_blocks_core::PointN;

let p2 = PointN([1, 2]); // 2D
let p3 = PointN([1, 2, 3]); // 3D

Points support basic linear algebraic operations such as addition, subtraction, scalar multiplication, and scalar division.

let p1 = PointN([1, 2]);
let p2 = PointN([3, 4]);

assert_eq!(p1 + p2, PointN([4, 6]));
assert_eq!(p1 - p2, PointN([-2, -2]));

assert_eq!(p1 * 2, PointN([2, 4]));
assert_eq!(p1 / 2, PointN([0, 1]));

// Also some component-wise operations.
assert_eq!(p1 * p2, PointN([3, 8]));
assert_eq!(p1 / p2, PointN([0, 0]));
assert_eq!(p2 / p1, PointN([3, 2]));

There is also a partial order defined on points which says that a point A is greater than a point B if and only if all of the components of point A are greater than point B. This is useful for easily checking is a point is inside of the extent between two other points:

let min = PointN([0, 0, 0]);
let least_upper_bound = PointN([3, 3, 3]);

let p = PointN([0, 1, 2]);
assert!(min <= p && p < least_upper_bound);

Implementations

impl<T> PointN<[T; 2]>[src]

pub fn x_mut(&mut self) -> &mut T[src]

pub fn y_mut(&mut self) -> &mut T[src]

impl<T> PointN<[T; 2]> where
    T: Copy
[src]

pub fn x(&self) -> T[src]

pub fn y(&self) -> T[src]

pub fn yx(&self) -> PointN<[T; 2]>[src]

impl<T> PointN<[T; 2]> where
    T: Copy + Integer
[src]

pub fn vector_div_floor(&self, rhs: &PointN<[T; 2]>) -> PointN<[T; 2]>[src]

pub fn scalar_div_floor(&self, rhs: T) -> PointN<[T; 2]>[src]

impl PointN<[f32; 2]>[src]

pub fn round(&self) -> PointN<[f32; 2]>[src]

pub fn floor(&self) -> PointN<[f32; 2]>[src]

impl PointN<[f32; 2]>[src]

pub fn as_2i(&self) -> PointN<[i32; 2]>[src]

pub fn in_pixel(&self) -> PointN<[i32; 2]>[src]

impl<T> PointN<[T; 3]>[src]

pub fn x_mut(&mut self) -> &mut T[src]

pub fn y_mut(&mut self) -> &mut T[src]

pub fn z_mut(&mut self) -> &mut T[src]

impl<T> PointN<[T; 3]> where
    T: Copy
[src]

pub fn x(&self) -> T[src]

pub fn y(&self) -> T[src]

pub fn z(&self) -> T[src]

pub fn xy(&self) -> PointN<[T; 2]>[src]

pub fn yx(&self) -> PointN<[T; 2]>[src]

pub fn yz(&self) -> PointN<[T; 2]>[src]

pub fn zy(&self) -> PointN<[T; 2]>[src]

pub fn zx(&self) -> PointN<[T; 2]>[src]

pub fn xz(&self) -> PointN<[T; 2]>[src]

pub fn yzx(&self) -> PointN<[T; 3]>[src]

pub fn zxy(&self) -> PointN<[T; 3]>[src]

pub fn zyx(&self) -> PointN<[T; 3]>[src]

impl<T> PointN<[T; 3]> where
    T: Mul<T, Output = T> + Sub<T, Output = T> + Copy
[src]

pub fn cross(&self, other: &PointN<[T; 3]>) -> PointN<[T; 3]>[src]

impl<T> PointN<[T; 3]> where
    T: Copy + Integer
[src]

pub fn vector_div_floor(&self, rhs: &PointN<[T; 3]>) -> PointN<[T; 3]>[src]

pub fn scalar_div_floor(&self, rhs: T) -> PointN<[T; 3]>[src]

impl PointN<[f32; 3]>[src]

pub fn round(&self) -> PointN<[f32; 3]>[src]

pub fn floor(&self) -> PointN<[f32; 3]>[src]

impl PointN<[f32; 3]>[src]

pub fn as_3i(&self) -> PointN<[i32; 3]>[src]

pub fn in_voxel(&self) -> PointN<[i32; 3]>[src]

Trait Implementations

impl<T> Add<PointN<[T; 2]>> for PointN<[T; 2]> where
    T: Copy + AddAssign<T>, 
[src]

type Output = PointN<[T; 2]>

The resulting type after applying the + operator.

impl<T> Add<PointN<[T; 3]>> for PointN<[T; 3]> where
    T: AddAssign<T> + Copy
[src]

type Output = PointN<[T; 3]>

The resulting type after applying the + operator.

impl<T> Add<PointN<T>> for ExtentN<T> where
    PointN<T>: Add<PointN<T>>,
    <PointN<T> as Add<PointN<T>>>::Output == PointN<T>, 
[src]

type Output = ExtentN<T>

The resulting type after applying the + operator.

impl<N> AddAssign<PointN<N>> for PointN<N> where
    N: Copy,
    PointN<N>: Add<PointN<N>>,
    <PointN<N> as Add<PointN<N>>>::Output == PointN<N>, 
[src]

impl<T> AddAssign<PointN<T>> for ExtentN<T> where
    ExtentN<T>: Copy,
    ExtentN<T>: Add<PointN<T>>,
    <ExtentN<T> as Add<PointN<T>>>::Output == ExtentN<T>, 
[src]

impl<T> Bounded for PointN<[T; 2]> where
    T: Bounded
[src]

impl<T> Bounded for PointN<[T; 3]> where
    T: Bounded
[src]

impl ChunkShape<[i32; 2]> for PointN<[i32; 2]>[src]

impl ChunkShape<[i32; 3]> for PointN<[i32; 3]>[src]

impl<N> Clone for PointN<N> where
    N: Clone
[src]

impl<N> Copy for PointN<N> where
    N: Copy
[src]

impl<N> Debug for PointN<N> where
    N: Debug
[src]

impl<N> Default for PointN<N> where
    N: Default
[src]

impl<'de, N> Deserialize<'de> for PointN<N> where
    N: Deserialize<'de>, 
[src]

impl<T> Distance for PointN<[T; 3]> where
    T: Add<T, Output = T> + Pow<u16, Output = T> + Copy + Signed,
    PointN<[T; 3]>: Point,
    <PointN<[T; 3]> as Point>::Scalar == T, 
[src]

impl<T> Distance for PointN<[T; 2]> where
    T: Add<T, Output = T> + Pow<u16, Output = T> + Copy + Signed,
    PointN<[T; 2]>: Point,
    <PointN<[T; 2]> as Point>::Scalar == T, 
[src]

impl Div<PointN<[f32; 2]>> for PointN<[f32; 2]>[src]

type Output = PointN<[f32; 2]>

The resulting type after applying the / operator.

impl Div<PointN<[f32; 3]>> for PointN<[f32; 3]>[src]

type Output = PointN<[f32; 3]>

The resulting type after applying the / operator.

impl Div<PointN<[i32; 2]>> for PointN<[i32; 2]>[src]

type Output = PointN<[i32; 2]>

The resulting type after applying the / operator.

impl Div<PointN<[i32; 3]>> for PointN<[i32; 3]>[src]

type Output = PointN<[i32; 3]>

The resulting type after applying the / operator.

impl Div<f32> for PointN<[f32; 2]>[src]

type Output = PointN<[f32; 2]>

The resulting type after applying the / operator.

impl Div<f32> for PointN<[f32; 3]>[src]

type Output = PointN<[f32; 3]>

The resulting type after applying the / operator.

impl Div<i32> for PointN<[i32; 2]>[src]

type Output = PointN<[i32; 2]>

The resulting type after applying the / operator.

impl Div<i32> for PointN<[i32; 3]>[src]

type Output = PointN<[i32; 3]>

The resulting type after applying the / operator.

impl<T> DotProduct for PointN<[T; 2]> where
    T: Add<T, Output = T> + Mul<T, Output = T> + Copy
[src]

type Scalar = T

impl<T> DotProduct for PointN<[T; 3]> where
    T: Add<T, Output = T> + Mul<T, Output = T> + Copy
[src]

type Scalar = T

impl<N> Eq for PointN<N> where
    N: Eq
[src]

impl<N, T> ForEach<N, PointN<N>> for AmbientExtent<N, T> where
    T: Clone,
    ExtentN<N>: IntegerExtent<N>, 
[src]

type Data = T

impl<'a, F, N, T> ForEach<N, PointN<N>> for F where
    F: Fn(&PointN<N>) -> T,
    PointN<N>: Copy,
    ExtentN<N>: IntegerExtent<N>, 
[src]

type Data = T

impl<N, T> ForEach<N, PointN<N>> for ArrayN<N, T> where
    ArrayN<N, T>: Sized,
    ArrayN<N, T>: Array<N>,
    ArrayN<N, T>: Get<Stride>,
    ArrayN<N, T>: GetUnchecked<Stride>,
    <ArrayN<N, T> as Get<Stride>>::Data == T,
    <ArrayN<N, T> as GetUnchecked<Stride>>::Data == T, 
[src]

type Data = T

impl<'a, N, T, M> ForEach<N, PointN<N>> for ChunkMapReader<'a, N, T, M> where
    M: Clone,
    T: Copy,
    PointN<N>: IntegerPoint,
    PointN<N>: ChunkShape<N>,
    PointN<N>: Eq,
    PointN<N>: Hash,
    ExtentN<N>: IntegerExtent<N>,
    ArrayN<N, T>: Array<N>,
    ArrayN<N, T>: ForEach<N, PointN<N>>,
    <ArrayN<N, T> as ForEach<N, PointN<N>>>::Data == T, 
[src]

type Data = T

impl<N, T> ForEachMut<N, PointN<N>> for ArrayN<N, T> where
    ArrayN<N, T>: Sized,
    ArrayN<N, T>: Array<N>,
    ArrayN<N, T>: GetMut<Stride>,
    ArrayN<N, T>: GetUncheckedMut<Stride>,
    ExtentN<N>: Copy,
    <ArrayN<N, T> as GetMut<Stride>>::Data == T,
    <ArrayN<N, T> as GetUncheckedMut<Stride>>::Data == T, 
[src]

type Data = T

impl<'a, N, T, M> ForEachMut<N, PointN<N>> for ChunkMap<N, T, M> where
    M: Clone,
    T: Copy,
    PointN<N>: Point,
    PointN<N>: ChunkShape<N>,
    PointN<N>: Eq,
    PointN<N>: Hash,
    ExtentN<N>: IntegerExtent<N>,
    ArrayN<N, T>: ForEachMut<N, PointN<N>>,
    <ArrayN<N, T> as ForEachMut<N, PointN<N>>>::Data == T, 
[src]

type Data = T

impl From<Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2, U1>>::Buffer>> for PointN<[f32; 2]>[src]

impl From<Matrix<f32, U3, U1, <DefaultAllocator as Allocator<f32, U3, U1>>::Buffer>> for PointN<[f32; 3]>[src]

impl From<Matrix<i32, U2, U1, <DefaultAllocator as Allocator<i32, U2, U1>>::Buffer>> for PointN<[i32; 2]>[src]

impl From<Matrix<i32, U3, U1, <DefaultAllocator as Allocator<i32, U3, U1>>::Buffer>> for PointN<[i32; 3]>[src]

impl From<Point<f32, U2>> for PointN<[f32; 2]>[src]

impl From<Point<f32, U3>> for PointN<[f32; 3]>[src]

impl From<Point<i32, U2>> for PointN<[i32; 2]>[src]

impl From<Point<i32, U3>> for PointN<[i32; 3]>[src]

impl<T> From<Point2<T>> for PointN<[T; 2]>[src]

impl<T> From<Point3<T>> for PointN<[T; 3]>[src]

impl From<PointN<[i32; 2]>> for PointN<[f32; 2]>[src]

impl From<PointN<[i32; 3]>> for PointN<[f32; 3]>[src]

impl<T> From<Vector2<T>> for PointN<[T; 2]>[src]

impl<T> From<Vector3<T>> for PointN<[T; 3]>[src]

impl<'_, N, T> Get<&'_ PointN<N>> for ArrayN<N, T> where
    T: Clone,
    ArrayN<N, T>: Array<N>,
    ArrayN<N, T>: for<'r> Get<&'r Local<N>>,
    PointN<N>: Point,
    <ArrayN<N, T> as Get<&'r Local<N>>>::Data == T, 
[src]

type Data = T

impl<'a, '_, N, T, M> Get<&'_ PointN<N>> for ChunkMapReader<'a, N, T, M> where
    M: Clone,
    T: Copy,
    PointN<N>: IntegerPoint,
    PointN<N>: ChunkShape<N>,
    PointN<N>: Eq,
    PointN<N>: Hash,
    ExtentN<N>: IntegerExtent<N>,
    ArrayN<N, T>: Array<N>, 
[src]

type Data = T

impl<'_, N, T> GetMut<&'_ PointN<N>> for ArrayN<N, T> where
    ArrayN<N, T>: Array<N>,
    ArrayN<N, T>: for<'r> GetMut<&'r Local<N>>,
    PointN<N>: Point,
    <ArrayN<N, T> as GetMut<&'r Local<N>>>::Data == T, 
[src]

type Data = T

impl<'_, N, T, M> GetMut<&'_ PointN<N>> for ChunkMap<N, T, M> where
    M: Clone,
    T: Copy,
    PointN<N>: IntegerPoint,
    PointN<N>: ChunkShape<N>,
    PointN<N>: Eq,
    PointN<N>: Hash,
    ExtentN<N>: IntegerExtent<N>,
    ArrayN<N, T>: Array<N>, 
[src]

type Data = T

impl<'_, N, T> GetUnchecked<&'_ PointN<N>> for ArrayN<N, T> where
    T: Clone,
    ArrayN<N, T>: Array<N>,
    ArrayN<N, T>: for<'r> GetUnchecked<&'r Local<N>>,
    PointN<N>: Point,
    <ArrayN<N, T> as GetUnchecked<&'r Local<N>>>::Data == T, 
[src]

type Data = T

impl<'_, N, T> GetUncheckedMut<&'_ PointN<N>> for ArrayN<N, T> where
    ArrayN<N, T>: Array<N>,
    ArrayN<N, T>: for<'r> GetUncheckedMut<&'r Local<N>>,
    PointN<N>: Point,
    <ArrayN<N, T> as GetUncheckedMut<&'r Local<N>>>::Data == T, 
[src]

type Data = T

impl<N> Hash for PointN<N> where
    N: Hash
[src]

impl IntegerPoint for PointN<[i32; 3]>[src]

impl IntegerPoint for PointN<[i32; 2]>[src]

impl<T> Mul<PointN<[T; 2]>> for PointN<[T; 2]> where
    T: Copy + Mul<T, Output = T>, 
[src]

type Output = PointN<[T; 2]>

The resulting type after applying the * operator.

impl<T> Mul<PointN<[T; 3]>> for PointN<[T; 3]> where
    T: Copy + Mul<T, Output = T>, 
[src]

type Output = PointN<[T; 3]>

The resulting type after applying the * operator.

impl<T> Mul<T> for PointN<[T; 2]> where
    T: Copy + Mul<T, Output = T>, 
[src]

type Output = PointN<[T; 2]>

The resulting type after applying the * operator.

impl<T> Mul<T> for PointN<[T; 3]> where
    T: Copy + Mul<T, Output = T>, 
[src]

type Output = PointN<[T; 3]>

The resulting type after applying the * operator.

impl<N> Neg for PointN<N> where
    N: Copy,
    PointN<N>: Sub<PointN<N>>,
    PointN<N>: Zero,
    <PointN<N> as Sub<PointN<N>>>::Output == PointN<N>, 
[src]

type Output = PointN<N>

The resulting type after applying the - operator.

impl NormSquared for PointN<[f32; 2]>[src]

impl NormSquared for PointN<[i32; 3]>[src]

impl NormSquared for PointN<[i32; 2]>[src]

impl NormSquared for PointN<[f32; 3]>[src]

impl<T> Ones for PointN<[T; 3]> where
    T: SmallOne
[src]

impl<T> Ones for PointN<[T; 2]> where
    T: SmallOne
[src]

impl<N> PartialEq<PointN<N>> for PointN<N> where
    N: PartialEq<N>, 
[src]

impl<T> PartialOrd<PointN<[T; 2]>> for PointN<[T; 2]> where
    T: Copy + PartialOrd<T>, 
[src]

impl<T> PartialOrd<PointN<[T; 3]>> for PointN<[T; 3]> where
    T: Copy + PartialOrd<T>, 
[src]

impl Point for PointN<[i32; 3]>[src]

type Scalar = i32

impl Point for PointN<[f32; 3]>[src]

type Scalar = f32

impl Point for PointN<[f32; 2]>[src]

type Scalar = f32

impl Point for PointN<[i32; 2]>[src]

type Scalar = i32

impl<N> Serialize for PointN<N> where
    N: Serialize
[src]

impl<T> SmallZero for PointN<[T; 2]> where
    T: SmallZero
[src]

impl<T> SmallZero for PointN<[T; 3]> where
    T: SmallZero
[src]

impl<N> StructuralEq for PointN<N>[src]

impl<N> StructuralPartialEq for PointN<N>[src]

impl<T> Sub<PointN<[T; 2]>> for PointN<[T; 2]> where
    T: Copy + SubAssign<T>, 
[src]

type Output = PointN<[T; 2]>

The resulting type after applying the - operator.

impl<T> Sub<PointN<[T; 3]>> for PointN<[T; 3]> where
    T: SubAssign<T> + Copy
[src]

type Output = PointN<[T; 3]>

The resulting type after applying the - operator.

impl<T> Sub<PointN<T>> for ExtentN<T> where
    PointN<T>: Sub<PointN<T>>,
    <PointN<T> as Sub<PointN<T>>>::Output == PointN<T>, 
[src]

type Output = ExtentN<T>

The resulting type after applying the - operator.

impl<N> SubAssign<PointN<N>> for PointN<N> where
    N: Copy,
    PointN<N>: Sub<PointN<N>>,
    <PointN<N> as Sub<PointN<N>>>::Output == PointN<N>, 
[src]

impl<T> SubAssign<PointN<T>> for ExtentN<T> where
    ExtentN<T>: Copy,
    ExtentN<T>: Sub<PointN<T>>,
    <ExtentN<T> as Sub<PointN<T>>>::Output == ExtentN<T>, 
[src]

impl<N> Zero for PointN<N> where
    PointN<N>: Point,
    PointN<N>: SmallZero
[src]

Auto Trait Implementations

impl<N> RefUnwindSafe for PointN<N> where
    N: RefUnwindSafe

impl<N> Send for PointN<N> where
    N: Send

impl<N> Sync for PointN<N> where
    N: Sync

impl<N> Unpin for PointN<N> where
    N: Unpin

impl<N> UnwindSafe for PointN<N> where
    N: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> ClosedNeg for T where
    T: Neg<Output = T>, 

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

impl<T> CollisionObjectHandle for T where
    T: 'static + PartialEq<T> + Eq + Send + Copy + Sync + Hash
[src]

impl<T> Compressible<BincodeLz4> for T where
    T: DeserializeOwned + Serialize

type Compressed = BincodeLz4Compressed<T>

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

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

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

impl<'a, F, N, T> ForEach<N, PointN<N>> for F where
    F: Fn(&PointN<N>) -> T,
    PointN<N>: Copy,
    ExtentN<N>: IntegerExtent<N>, 
[src]

type Data = T

impl<'a, F, N, T> ForEach<N, PointN<N>> for F where
    F: Fn(&PointN<N>) -> T,
    PointN<N>: Copy,
    ExtentN<N>: IntegerExtent<N>, 
[src]

type Data = T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<M> Measure for M where
    M: Debug + PartialOrd<M> + Add<M, Output = M> + Default + Clone
[src]

impl<T> Norm for T where
    T: NormSquared
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: PartialEq<T> + Copy + Any + Debug
[src]

impl<T> Slottable for T where
    T: Copy
[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,