[][src]Struct building_blocks_core::point::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) -> Self[src]

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

pub fn vector_div_floor(&self, rhs: &Self) -> Self[src]

pub fn scalar_div_floor(&self, rhs: T) -> Self[src]

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

pub fn round(&self) -> Self[src]

pub fn floor(&self) -> Self[src]

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

pub fn as_2i(&self) -> Point2i[src]

pub fn in_pixel(&self) -> Point2i[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) -> Point2<T>[src]

pub fn yx(&self) -> Point2<T>[src]

pub fn yz(&self) -> Point2<T>[src]

pub fn zy(&self) -> Point2<T>[src]

pub fn zx(&self) -> Point2<T>[src]

pub fn xz(&self) -> Point2<T>[src]

pub fn yzx(&self) -> Point3<T>[src]

pub fn zxy(&self) -> Point3<T>[src]

pub fn zyx(&self) -> Point3<T>[src]

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

pub fn cross(&self, other: &Self) -> Self[src]

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

pub fn vector_div_floor(&self, rhs: &Self) -> Self[src]

pub fn scalar_div_floor(&self, rhs: T) -> Self[src]

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

pub fn round(&self) -> Self[src]

pub fn floor(&self) -> Self[src]

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

pub fn as_3i(&self) -> Point3i[src]

pub fn in_voxel(&self) -> Point3i[src]

Trait Implementations

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

type Output = Self

The resulting type after applying the + operator.

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

type Output = Self

The resulting type after applying the + operator.

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

type Output = Self

The resulting type after applying the + operator.

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

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

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

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

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

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

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

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

type Output = Self

The resulting type after applying the / operator.

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

type Output = Self

The resulting type after applying the / operator.

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

type Output = Self

The resulting type after applying the / operator.

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

type Output = Self

The resulting type after applying the / operator.

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

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

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

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

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

type Output = Self

The resulting type after applying the * operator.

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

type Output = Self

The resulting type after applying the * operator.

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

type Output = Self

The resulting type after applying the - operator.

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

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

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

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

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

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

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

type Output = Self

The resulting type after applying the - operator.

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

type Output = Self

The resulting type after applying the - operator.

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

type Output = Self

The resulting type after applying the - operator.

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

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

impl<N> Zero for PointN<N> where
    Self: Point + 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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

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

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

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.