Struct vectory::Vec3[][src]

#[repr(C)]pub struct Vec3<T> where
    T: Copy
{ pub x: T, pub y: T, pub z: T, }

A generic 3D vector type that represented by named struct.

Fields

x: Ty: Tz: T

Implementations

impl<T> Vec3<T> where
    T: Copy
[src]

pub const LANES: usize[src]

The number of lanes in this vector.

pub fn new(x: T, y: T, z: 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_x() -> Vec3<T> where
    T: Copy + One + Zero
[src]

Returns a unit vector which points along the x axis.

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

Returns a unit vector which points along the y axis.

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

Returns a unit vector which points along the z 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) -> Vec3<M> where
    M: Copy,
    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 cross(self, other: Self) -> Self where
    T: Copy + Mul<Output = T> + Sub<Output = T>, 
[src]

Returns the cross product between self and other.

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

Returns true if any elements are NaN.

Trait Implementations

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

type Output = Self

The resulting type after applying the + operator.

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

type Output = Vec3<f32>

The resulting type after applying the + operator.

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

type Output = Vec3<f64>

The resulting type after applying the + operator.

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

type Output = Vec3<i128>

The resulting type after applying the + operator.

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

type Output = Vec3<i16>

The resulting type after applying the + operator.

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

type Output = Vec3<i32>

The resulting type after applying the + operator.

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

type Output = Vec3<i64>

The resulting type after applying the + operator.

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

type Output = Vec3<i8>

The resulting type after applying the + operator.

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

type Output = Vec3<u128>

The resulting type after applying the + operator.

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

type Output = Vec3<u16>

The resulting type after applying the + operator.

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

type Output = Vec3<u32>

The resulting type after applying the + operator.

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

type Output = Vec3<u64>

The resulting type after applying the + operator.

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

type Output = Vec3<u8>

The resulting type after applying the + operator.

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

impl<T> AsMut<[T]> for Vec3<T> where
    T: Copy
[src]

impl<T> AsMut<Vec3<T>> for Vec3<T> where
    T: Copy
[src]

impl<T> AsRef<[T]> for Vec3<T> where
    T: Copy
[src]

impl<T> AsRef<Vec3<T>> for Vec3<T> where
    T: Copy
[src]

impl<T> Borrow<[T]> for Vec3<T> where
    T: Copy
[src]

impl<T> BorrowMut<[T]> for Vec3<T> where
    T: Copy
[src]

impl<T: Clone> Clone for Vec3<T> where
    T: Copy
[src]

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

impl<T> Deref for Vec3<T> where
    T: Copy
[src]

type Target = [T]

The resulting type after dereferencing.

impl<T> DerefMut for Vec3<T> where
    T: Copy
[src]

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

type Output = Self

The resulting type after applying the / operator.

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

type Output = Self

The resulting type after applying the / operator.

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

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

impl<T> From<[T; 3]> for Vec3<T> where
    T: Copy
[src]

impl<T> From<(T, T, T)> for Vec3<T> where
    T: Copy
[src]

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

impl<T> Into<[T; 3]> for Vec3<T> where
    T: Copy
[src]

impl<T> Into<(T, T, T)> for Vec3<T> where
    T: Copy
[src]

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

type Output = Self

The resulting type after applying the * operator.

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

type Output = Self

The resulting type after applying the * operator.

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

type Output = Vec3<f32>

The resulting type after applying the * operator.

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

type Output = Vec3<f64>

The resulting type after applying the * operator.

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

type Output = Vec3<i128>

The resulting type after applying the * operator.

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

type Output = Vec3<i16>

The resulting type after applying the * operator.

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

type Output = Vec3<i32>

The resulting type after applying the * operator.

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

type Output = Vec3<i64>

The resulting type after applying the * operator.

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

type Output = Vec3<i8>

The resulting type after applying the * operator.

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

type Output = Vec3<u128>

The resulting type after applying the * operator.

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

type Output = Vec3<u16>

The resulting type after applying the * operator.

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

type Output = Vec3<u32>

The resulting type after applying the * operator.

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

type Output = Vec3<u64>

The resulting type after applying the * operator.

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

type Output = Vec3<u8>

The resulting type after applying the * operator.

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

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

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

type Output = Self

The resulting type after applying the - operator.

impl<T: PartialEq> PartialEq<Vec3<T>> for Vec3<T> where
    T: Copy
[src]

impl<T> StructuralPartialEq for Vec3<T> where
    T: Copy
[src]

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

type Output = Self

The resulting type after applying the - operator.

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

Auto Trait Implementations

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

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

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

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

impl<T> UnwindSafe for Vec3<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.