[−][src]Struct building_blocks_core::point::PointN
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]
impl<T> PointN<[T; 2]> where
T: Copy,
[src]
T: Copy,
impl<T> PointN<[T; 2]> where
T: Copy + Integer,
[src]
T: Copy + Integer,
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]
impl PointN<[f32; 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]
T: Copy,
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]
T: Copy + Mul<Output = T> + Sub<Output = T>,
impl<T> PointN<[T; 3]> where
T: Copy + Integer,
[src]
T: Copy + Integer,
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]
impl PointN<[f32; 3]>
[src]
Trait Implementations
impl<T> Add<PointN<[T; 2]>> for Point2<T> where
T: Copy + AddAssign,
[src]
T: Copy + AddAssign,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self::Output
[src]
impl<T> Add<PointN<[T; 3]>> for PointN<[T; 3]> where
T: AddAssign + Copy,
[src]
T: AddAssign + Copy,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self::Output
[src]
impl<T> Add<PointN<T>> for ExtentN<T> where
PointN<T>: Add<Output = PointN<T>>,
[src]
PointN<T>: Add<Output = PointN<T>>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: PointN<T>) -> Self::Output
[src]
impl<N> AddAssign<PointN<N>> for PointN<N> where
N: Copy,
PointN<N>: Add<Output = Self>,
[src]
N: Copy,
PointN<N>: Add<Output = Self>,
fn add_assign(&mut self, rhs: Self)
[src]
impl<T> AddAssign<PointN<T>> for ExtentN<T> where
Self: Copy + Add<PointN<T>, Output = ExtentN<T>>,
[src]
Self: Copy + Add<PointN<T>, Output = ExtentN<T>>,
fn add_assign(&mut self, rhs: PointN<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]
N: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Div<PointN<[f32; 2]>> for Point2f
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> Self
[src]
impl Div<PointN<[f32; 3]>> for Point3f
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> Self
[src]
impl Div<PointN<[i32; 2]>> for Point2i
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Point2i) -> Self
[src]
impl Div<PointN<[i32; 3]>> for Point3i
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Point3i) -> Self
[src]
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]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Mul<PointN<[T; 2]>> for Point2<T> where
T: Copy + Mul<Output = T>,
[src]
T: Copy + Mul<Output = T>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self
[src]
impl<T> Mul<PointN<[T; 3]>> for Point3<T> where
T: Copy + Mul<Output = T>,
[src]
T: Copy + Mul<Output = T>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self
[src]
impl<N> Neg for PointN<N> where
N: Copy,
PointN<N>: Sub<Output = Self> + Zero,
[src]
N: Copy,
PointN<N>: Sub<Output = Self> + Zero,
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl<N: PartialEq> PartialEq<PointN<N>> for PointN<N>
[src]
impl<T> PartialOrd<PointN<[T; 2]>> for Point2<T> where
T: Copy + PartialOrd,
[src]
T: Copy + PartialOrd,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<T> PartialOrd<PointN<[T; 3]>> for Point3<T> where
T: Copy + PartialOrd,
[src]
T: Copy + PartialOrd,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
impl<N> Serialize for PointN<N> where
N: Serialize,
[src]
N: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
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]
T: Copy + SubAssign,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self::Output
[src]
impl<T> Sub<PointN<[T; 3]>> for PointN<[T; 3]> where
T: SubAssign + Copy,
[src]
T: SubAssign + Copy,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self::Output
[src]
impl<T> Sub<PointN<T>> for ExtentN<T> where
PointN<T>: Sub<Output = PointN<T>>,
[src]
PointN<T>: Sub<Output = PointN<T>>,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: PointN<T>) -> Self::Output
[src]
impl<N> SubAssign<PointN<N>> for PointN<N> where
N: Copy,
PointN<N>: Sub<Output = Self>,
[src]
N: Copy,
PointN<N>: Sub<Output = Self>,
fn sub_assign(&mut self, rhs: Self)
[src]
impl<T> SubAssign<PointN<T>> for ExtentN<T> where
Self: Copy + Sub<PointN<T>, Output = ExtentN<T>>,
[src]
Self: Copy + Sub<PointN<T>, Output = ExtentN<T>>,
fn sub_assign(&mut self, rhs: PointN<T>)
[src]
impl<N> Zero for PointN<N> where
Self: Point + SmallZero,
[src]
Self: Point + SmallZero,
Auto Trait Implementations
impl<N> RefUnwindSafe for PointN<N> where
N: RefUnwindSafe,
N: RefUnwindSafe,
impl<N> Send for PointN<N> where
N: Send,
N: Send,
impl<N> Sync for PointN<N> where
N: Sync,
N: Sync,
impl<N> Unpin for PointN<N> where
N: Unpin,
N: Unpin,
impl<N> UnwindSafe for PointN<N> where
N: UnwindSafe,
N: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Norm for T where
T: NormSquared,
[src]
T: NormSquared,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,