Struct vectory::Vec2 [−][src]
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]
T: Copy,
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]
T: Copy + One + Zero,
Returns a unit vector which points along the 0
axis.
pub fn unit_1() -> Vec2<T> where
T: Copy + One + Zero,
[src]
T: Copy + One + Zero,
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]
T: Add<Output = T>,
Returns the sum of all elements in this vector.
pub fn product(self) -> T where
T: Mul<Output = T>,
[src]
T: Mul<Output = T>,
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]
T: Add<Output = T> + Mul<Output = T>,
Returns the dot product between self
and other
.
pub fn length_squared(self) -> T where
T: Copy + Add<Output = T> + Mul<Output = T>,
[src]
T: Copy + Add<Output = T> + Mul<Output = T>,
Returns the sqaured length of this vector.
pub fn length(self) -> T where
T: Copy + Real + Add<Output = T> + Mul<Output = T>,
[src]
T: Copy + Real + Add<Output = T> + Mul<Output = T>,
Returns the length of this vector.
pub fn length_recip(self) -> T where
T: Copy + One + Real + Add<Output = T> + Mul<Output = T>,
[src]
T: Copy + One + Real + Add<Output = T> + Mul<Output = T>,
pub fn distance_squared(self, other: Self) -> T where
T: Copy + Real + Add<Output = T> + Sub<Output = T> + Mul<Output = T>,
[src]
T: Copy + Real + Add<Output = T> + Sub<Output = T> + Mul<Output = T>,
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]
T: Copy + Real + Add<Output = T> + Sub<Output = T> + Mul<Output = T>,
Returns the euclidean distance between two points.
pub fn min(self, other: Self) -> Self where
T: Copy + PartialOrd,
[src]
T: Copy + PartialOrd,
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]
T: Copy + PartialOrd,
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]
T: Copy + PartialOrd,
Returns the smallest element in this vector.
pub fn max_elem(self) -> T where
T: Copy + PartialOrd,
[src]
T: Copy + PartialOrd,
Returns the largest element in this vector.
pub fn map<M, F>(self, f: F) -> Vec2<M> where
F: FnMut(T) -> M,
[src]
F: FnMut(T) -> M,
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]
T: Copy,
F: FnMut(T) -> T,
Applies the function f
to each element in order, in-place.
pub fn abs(self) -> Self where
T: Signed,
[src]
T: Signed,
Computes the absolute value of self.
pub fn normalize(self) -> Self where
T: Add<Output = T> + Real + One,
[src]
T: Add<Output = T> + Real + One,
Returns a normalized self
whose length is equal to 1.
pub fn clamp(self, min: Self, max: Self) -> Self where
T: PartialOrd,
[src]
T: PartialOrd,
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]
T: Float,
Returns true
if any elements are NaN
.
Trait Implementations
impl<T> Add<Vec2<T>> for Vec2<T> where
T: Add<T, Output = T>,
[src]
T: Add<T, Output = T>,
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self::Output
[src]
impl Add<Vec2<f32>> for f32
[src]
type Output = Vec2<f32>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<f32>) -> Self::Output
[src]
impl Add<Vec2<f64>> for f64
[src]
type Output = Vec2<f64>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<f64>) -> Self::Output
[src]
impl Add<Vec2<i128>> for i128
[src]
type Output = Vec2<i128>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<i128>) -> Self::Output
[src]
impl Add<Vec2<i16>> for i16
[src]
type Output = Vec2<i16>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<i16>) -> Self::Output
[src]
impl Add<Vec2<i32>> for i32
[src]
type Output = Vec2<i32>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<i32>) -> Self::Output
[src]
impl Add<Vec2<i64>> for i64
[src]
type Output = Vec2<i64>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<i64>) -> Self::Output
[src]
impl Add<Vec2<i8>> for i8
[src]
type Output = Vec2<i8>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<i8>) -> Self::Output
[src]
impl Add<Vec2<u128>> for u128
[src]
type Output = Vec2<u128>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<u128>) -> Self::Output
[src]
impl Add<Vec2<u16>> for u16
[src]
type Output = Vec2<u16>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<u16>) -> Self::Output
[src]
impl Add<Vec2<u32>> for u32
[src]
type Output = Vec2<u32>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<u32>) -> Self::Output
[src]
impl Add<Vec2<u64>> for u64
[src]
type Output = Vec2<u64>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<u64>) -> Self::Output
[src]
impl Add<Vec2<u8>> for u8
[src]
type Output = Vec2<u8>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2<u8>) -> Self::Output
[src]
impl<T> AddAssign<Vec2<T>> for Vec2<T> where
T: AddAssign<T>,
[src]
T: AddAssign<T>,
fn add_assign(&mut self, rhs: Self)
[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]
fn borrow_mut(&mut self) -> &mut [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]
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]
T: Copy + Mul<Output = T> + Div<Output = T> + One,
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: T) -> Self::Output
[src]
impl<T> Div<Vec2<T>> for Vec2<T> where
T: Div<T, Output = T>,
[src]
T: Div<T, Output = T>,
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> Self::Output
[src]
impl<T> DivAssign<T> for Vec2<T> where
T: Copy + Div<Output = T> + Mul<Output = T> + MulAssign + One,
[src]
T: Copy + Div<Output = T> + Mul<Output = T> + MulAssign + One,
fn div_assign(&mut self, rhs: T)
[src]
impl<T> DivAssign<Vec2<T>> for Vec2<T> where
T: DivAssign<T>,
[src]
T: DivAssign<T>,
fn div_assign(&mut self, rhs: Self)
[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]
T: Copy,
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]
T: Copy + Mul<Output = T>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Self::Output
[src]
impl<T> Mul<Vec2<T>> for Vec2<T> where
T: Mul<T, Output = T>,
[src]
T: Mul<T, Output = T>,
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: Self) -> Self::Output
[src]
impl Mul<Vec2<f32>> for f32
[src]
type Output = Vec2<f32>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<f32>) -> Self::Output
[src]
impl Mul<Vec2<f64>> for f64
[src]
type Output = Vec2<f64>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<f64>) -> Self::Output
[src]
impl Mul<Vec2<i128>> for i128
[src]
type Output = Vec2<i128>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<i128>) -> Self::Output
[src]
impl Mul<Vec2<i16>> for i16
[src]
type Output = Vec2<i16>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<i16>) -> Self::Output
[src]
impl Mul<Vec2<i32>> for i32
[src]
type Output = Vec2<i32>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<i32>) -> Self::Output
[src]
impl Mul<Vec2<i64>> for i64
[src]
type Output = Vec2<i64>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<i64>) -> Self::Output
[src]
impl Mul<Vec2<i8>> for i8
[src]
type Output = Vec2<i8>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<i8>) -> Self::Output
[src]
impl Mul<Vec2<u128>> for u128
[src]
type Output = Vec2<u128>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<u128>) -> Self::Output
[src]
impl Mul<Vec2<u16>> for u16
[src]
type Output = Vec2<u16>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<u16>) -> Self::Output
[src]
impl Mul<Vec2<u32>> for u32
[src]
type Output = Vec2<u32>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<u32>) -> Self::Output
[src]
impl Mul<Vec2<u64>> for u64
[src]
type Output = Vec2<u64>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<u64>) -> Self::Output
[src]
impl Mul<Vec2<u8>> for u8
[src]
type Output = Vec2<u8>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2<u8>) -> Self::Output
[src]
impl<T> MulAssign<T> for Vec2<T> where
T: Copy + MulAssign,
[src]
T: Copy + MulAssign,
fn mul_assign(&mut self, rhs: T)
[src]
impl<T> MulAssign<Vec2<T>> for Vec2<T> where
T: MulAssign<T>,
[src]
T: MulAssign<T>,
fn mul_assign(&mut self, rhs: Self)
[src]
impl<T> Neg for Vec2<T> where
T: Neg<Output = T>,
[src]
T: Neg<Output = T>,
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
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]
T: Sub<T, Output = T>,
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self::Output
[src]
impl<T> SubAssign<Vec2<T>> for Vec2<T> where
T: SubAssign<T>,
[src]
T: SubAssign<T>,
fn sub_assign(&mut self, rhs: Self)
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Vec2<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Vec2<T> where
T: Send,
T: Send,
impl<T> Sync for Vec2<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Vec2<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Vec2<T> where
T: UnwindSafe,
T: 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> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,