Struct vectory::Vec2[][src]

#[repr(C)]pub struct Vec2<T>(_, _);

A generic 2D vector type that represented by tuple struct.

Implementations

impl<T> Vec2<T>[src]

pub const LANES: usize[src]

The number of lanes in this vector.

pub fn new(a0: T, a1: T) -> Self[src]

Constructs a new vector with the given values.

pub fn splat(value: T) -> Self where
    T: Copy
[src]

Construct a new vector by setting each of its element to the given value.

pub fn unit_0() -> Vec2<T> where
    T: Copy + One + Zero
[src]

Returns a unit vector which points along the 0 axis.

pub fn unit_1() -> Vec2<T> where
    T: Copy + One + Zero
[src]

Returns a unit vector which points along the 1 axis.

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

Views this vector as an immutable slice.

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

Views this vector as a mutable slice.

pub fn sum(self) -> T where
    T: Add<Output = T>, 
[src]

Returns the sum of all elements in this vector.

pub fn product(self) -> T where
    T: Mul<Output = T>, 
[src]

Returns the product of all elements in this vector.

pub fn dot(self, other: Self) -> T where
    T: Add<Output = T> + Mul<Output = T>, 
[src]

Returns the dot product between self and other.

pub fn length_squared(self) -> T where
    T: Copy + Add<Output = T> + Mul<Output = T>, 
[src]

Returns the sqaured length of this vector.

pub fn length(self) -> T where
    T: Copy + Real + Add<Output = T> + Mul<Output = T>, 
[src]

Returns the length of this vector.

pub fn length_recip(self) -> T where
    T: Copy + One + Real + Add<Output = T> + Mul<Output = T>, 
[src]

Returns the reciprocal of its length.

Panics

Panics if self is of length zero.

pub fn distance_squared(self, other: Self) -> T where
    T: Copy + Real + Add<Output = T> + Sub<Output = T> + Mul<Output = T>, 
[src]

Returns the squared euclidean distance between two points.

pub fn distance(self, other: Self) -> T where
    T: Copy + Real + Add<Output = T> + Sub<Output = T> + Mul<Output = T>, 
[src]

Returns the euclidean distance between two points.

pub fn min(self, other: Self) -> Self where
    T: Copy + PartialOrd
[src]

Returns a vector containing the mininum values for each elements of self and other.

pub fn max(self, other: Self) -> Self where
    T: Copy + PartialOrd
[src]

Returns a vector containing the maximun values for each elements of self and other.

pub fn min_elem(self) -> T where
    T: Copy + PartialOrd
[src]

Returns the smallest element in this vector.

pub fn max_elem(self) -> T where
    T: Copy + PartialOrd
[src]

Returns the largest element in this vector.

pub fn map<M, F>(self, f: F) -> Vec2<M> where
    F: FnMut(T) -> M, 
[src]

Returns an vector of the same shape as self, with function f applied to each element in order.

pub fn apply<F>(&mut self, f: F) where
    T: Copy,
    F: FnMut(T) -> T, 
[src]

Applies the function f to each element in order, in-place.

pub fn abs(self) -> Self where
    T: Signed
[src]

Computes the absolute value of self.

pub fn normalize(self) -> Self where
    T: Add<Output = T> + Real + One
[src]

Returns a normalized self whose length is equal to 1.

pub fn clamp(self, min: Self, max: Self) -> Self where
    T: PartialOrd
[src]

Restricts each element in self to a certain interval given by the corresponing element in min and max.

Panics

For each corresponing element in min and max, panics if min > max, min is NaN, or max is NaN.

pub fn is_nan(self) -> bool where
    T: Float
[src]

Returns true if any elements are NaN.

Trait Implementations

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

type Output = Self

The resulting type after applying the + operator.

impl Add<Vec2<f32>> for f32[src]

type Output = Vec2<f32>

The resulting type after applying the + operator.

impl Add<Vec2<f64>> for f64[src]

type Output = Vec2<f64>

The resulting type after applying the + operator.

impl Add<Vec2<i128>> for i128[src]

type Output = Vec2<i128>

The resulting type after applying the + operator.

impl Add<Vec2<i16>> for i16[src]

type Output = Vec2<i16>

The resulting type after applying the + operator.

impl Add<Vec2<i32>> for i32[src]

type Output = Vec2<i32>

The resulting type after applying the + operator.

impl Add<Vec2<i64>> for i64[src]

type Output = Vec2<i64>

The resulting type after applying the + operator.

impl Add<Vec2<i8>> for i8[src]

type Output = Vec2<i8>

The resulting type after applying the + operator.

impl Add<Vec2<u128>> for u128[src]

type Output = Vec2<u128>

The resulting type after applying the + operator.

impl Add<Vec2<u16>> for u16[src]

type Output = Vec2<u16>

The resulting type after applying the + operator.

impl Add<Vec2<u32>> for u32[src]

type Output = Vec2<u32>

The resulting type after applying the + operator.

impl Add<Vec2<u64>> for u64[src]

type Output = Vec2<u64>

The resulting type after applying the + operator.

impl Add<Vec2<u8>> for u8[src]

type Output = Vec2<u8>

The resulting type after applying the + operator.

impl<T> AddAssign<Vec2<T>> for Vec2<T> where
    T: AddAssign<T>, 
[src]

impl<T> AsMut<[T]> for Vec2<T>[src]

impl<T> AsMut<Vec2<T>> for Vec2<T>[src]

impl<T> AsRef<[T]> for Vec2<T>[src]

impl<T> AsRef<Vec2<T>> for Vec2<T>[src]

impl<T> Borrow<[T]> for Vec2<T>[src]

impl<T> BorrowMut<[T]> for Vec2<T>[src]

impl<T: Clone> Clone for Vec2<T>[src]

impl<T: Copy> Copy for Vec2<T>[src]

impl<T> Deref for Vec2<T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<T> DerefMut for Vec2<T>[src]

impl<T> Div<T> for Vec2<T> where
    T: Copy + Mul<Output = T> + Div<Output = T> + One
[src]

type Output = Self

The resulting type after applying the / operator.

impl<T> Div<Vec2<T>> for Vec2<T> where
    T: Div<T, Output = T>, 
[src]

type Output = Self

The resulting type after applying the / operator.

impl<T> DivAssign<T> for Vec2<T> where
    T: Copy + Div<Output = T> + Mul<Output = T> + MulAssign + One
[src]

impl<T> DivAssign<Vec2<T>> for Vec2<T> where
    T: DivAssign<T>, 
[src]

impl<T> From<[T; 2]> for Vec2<T>[src]

impl<T> From<(T, T)> for Vec2<T>[src]

impl<T> From<T> for Vec2<T> where
    T: Copy
[src]

impl<T> Into<[T; 2]> for Vec2<T>[src]

impl<T> Into<(T, T)> for Vec2<T>[src]

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

type Output = Self

The resulting type after applying the * operator.

impl<T> Mul<Vec2<T>> for Vec2<T> where
    T: Mul<T, Output = T>, 
[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Vec2<f32>> for f32[src]

type Output = Vec2<f32>

The resulting type after applying the * operator.

impl Mul<Vec2<f64>> for f64[src]

type Output = Vec2<f64>

The resulting type after applying the * operator.

impl Mul<Vec2<i128>> for i128[src]

type Output = Vec2<i128>

The resulting type after applying the * operator.

impl Mul<Vec2<i16>> for i16[src]

type Output = Vec2<i16>

The resulting type after applying the * operator.

impl Mul<Vec2<i32>> for i32[src]

type Output = Vec2<i32>

The resulting type after applying the * operator.

impl Mul<Vec2<i64>> for i64[src]

type Output = Vec2<i64>

The resulting type after applying the * operator.

impl Mul<Vec2<i8>> for i8[src]

type Output = Vec2<i8>

The resulting type after applying the * operator.

impl Mul<Vec2<u128>> for u128[src]

type Output = Vec2<u128>

The resulting type after applying the * operator.

impl Mul<Vec2<u16>> for u16[src]

type Output = Vec2<u16>

The resulting type after applying the * operator.

impl Mul<Vec2<u32>> for u32[src]

type Output = Vec2<u32>

The resulting type after applying the * operator.

impl Mul<Vec2<u64>> for u64[src]

type Output = Vec2<u64>

The resulting type after applying the * operator.

impl Mul<Vec2<u8>> for u8[src]

type Output = Vec2<u8>

The resulting type after applying the * operator.

impl<T> MulAssign<T> for Vec2<T> where
    T: Copy + MulAssign
[src]

impl<T> MulAssign<Vec2<T>> for Vec2<T> where
    T: MulAssign<T>, 
[src]

impl<T> Neg for Vec2<T> where
    T: Neg<Output = T>, 
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: PartialEq> PartialEq<Vec2<T>> for Vec2<T>[src]

impl<T> StructuralPartialEq for Vec2<T>[src]

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

type Output = Self

The resulting type after applying the - operator.

impl<T> SubAssign<Vec2<T>> for Vec2<T> where
    T: SubAssign<T>, 
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Vec2<T> where
    T: RefUnwindSafe

impl<T> Send for Vec2<T> where
    T: Send

impl<T> Sync for Vec2<T> where
    T: Sync

impl<T> Unpin for Vec2<T> where
    T: Unpin

impl<T> UnwindSafe for Vec2<T> where
    T: 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> From<!> for T[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[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.