Struct vectory::Vec3 [−][src]
A generic 3D vector type that represented by named struct.
Fields
x: T
y: T
z: T
Implementations
impl<T> Vec3<T> where
T: Copy,
[src]
T: Copy,
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]
T: Copy,
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]
T: Copy + One + Zero,
Returns a unit vector which points along the x
axis.
pub fn unit_y() -> Vec3<T> where
T: Copy + One + Zero,
[src]
T: Copy + One + Zero,
Returns a unit vector which points along the y
axis.
pub fn unit_z() -> Vec3<T> where
T: Copy + One + Zero,
[src]
T: Copy + One + Zero,
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]
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) -> Vec3<M> where
M: Copy,
F: FnMut(T) -> M,
[src]
M: Copy,
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 cross(self, other: Self) -> Self where
T: Copy + Mul<Output = T> + Sub<Output = T>,
[src]
T: Copy + Mul<Output = T> + Sub<Output = T>,
Returns the cross product between self
and other
.
pub fn is_nan(self) -> bool where
T: Float,
[src]
T: Float,
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]
T: Copy,
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<Vec3<f32>> for f32
[src]
type Output = Vec3<f32>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<f32>) -> Self::Output
[src]
impl Add<Vec3<f64>> for f64
[src]
type Output = Vec3<f64>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<f64>) -> Self::Output
[src]
impl Add<Vec3<i128>> for i128
[src]
type Output = Vec3<i128>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<i128>) -> Self::Output
[src]
impl Add<Vec3<i16>> for i16
[src]
type Output = Vec3<i16>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<i16>) -> Self::Output
[src]
impl Add<Vec3<i32>> for i32
[src]
type Output = Vec3<i32>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<i32>) -> Self::Output
[src]
impl Add<Vec3<i64>> for i64
[src]
type Output = Vec3<i64>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<i64>) -> Self::Output
[src]
impl Add<Vec3<i8>> for i8
[src]
type Output = Vec3<i8>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<i8>) -> Self::Output
[src]
impl Add<Vec3<u128>> for u128
[src]
type Output = Vec3<u128>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<u128>) -> Self::Output
[src]
impl Add<Vec3<u16>> for u16
[src]
type Output = Vec3<u16>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<u16>) -> Self::Output
[src]
impl Add<Vec3<u32>> for u32
[src]
type Output = Vec3<u32>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<u32>) -> Self::Output
[src]
impl Add<Vec3<u64>> for u64
[src]
type Output = Vec3<u64>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<u64>) -> Self::Output
[src]
impl Add<Vec3<u8>> for u8
[src]
type Output = Vec3<u8>
The resulting type after applying the +
operator.
fn add(self, rhs: Vec3<u8>) -> Self::Output
[src]
impl<T> AddAssign<Vec3<T>> for Vec3<T> where
T: Copy,
T: AddAssign<T>,
[src]
T: Copy,
T: AddAssign<T>,
fn add_assign(&mut self, rhs: Self)
[src]
impl<T> AsMut<[T]> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> AsMut<Vec3<T>> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> AsRef<[T]> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> AsRef<Vec3<T>> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> Borrow<[T]> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> BorrowMut<[T]> for Vec3<T> where
T: Copy,
[src]
T: Copy,
fn borrow_mut(&mut self) -> &mut [T]
[src]
impl<T: Clone> Clone for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T: Copy> Copy for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> Deref for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> DerefMut for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> Div<T> for Vec3<T> where
T: Copy,
T: Copy + Mul<Output = T> + Div<Output = T> + One,
[src]
T: Copy,
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<Vec3<T>> for Vec3<T> where
T: Copy,
T: Div<T, Output = T>,
[src]
T: Copy,
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 Vec3<T> where
T: Copy,
T: Copy + Div<Output = T> + Mul<Output = T> + MulAssign + One,
[src]
T: Copy,
T: Copy + Div<Output = T> + Mul<Output = T> + MulAssign + One,
fn div_assign(&mut self, rhs: T)
[src]
impl<T> DivAssign<Vec3<T>> for Vec3<T> where
T: Copy,
T: DivAssign<T>,
[src]
T: Copy,
T: DivAssign<T>,
fn div_assign(&mut self, rhs: Self)
[src]
impl<T> From<[T; 3]> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> From<(T, T, T)> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> From<T> for Vec3<T> where
T: Copy,
T: Copy,
[src]
T: Copy,
T: Copy,
impl<T> Into<[T; 3]> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> Into<(T, T, T)> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> Mul<T> for Vec3<T> where
T: Copy,
T: Copy + Mul<Output = T>,
[src]
T: Copy,
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<Vec3<T>> for Vec3<T> where
T: Copy,
T: Mul<T, Output = T>,
[src]
T: Copy,
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<Vec3<f32>> for f32
[src]
type Output = Vec3<f32>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<f32>) -> Self::Output
[src]
impl Mul<Vec3<f64>> for f64
[src]
type Output = Vec3<f64>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<f64>) -> Self::Output
[src]
impl Mul<Vec3<i128>> for i128
[src]
type Output = Vec3<i128>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<i128>) -> Self::Output
[src]
impl Mul<Vec3<i16>> for i16
[src]
type Output = Vec3<i16>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<i16>) -> Self::Output
[src]
impl Mul<Vec3<i32>> for i32
[src]
type Output = Vec3<i32>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<i32>) -> Self::Output
[src]
impl Mul<Vec3<i64>> for i64
[src]
type Output = Vec3<i64>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<i64>) -> Self::Output
[src]
impl Mul<Vec3<i8>> for i8
[src]
type Output = Vec3<i8>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<i8>) -> Self::Output
[src]
impl Mul<Vec3<u128>> for u128
[src]
type Output = Vec3<u128>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<u128>) -> Self::Output
[src]
impl Mul<Vec3<u16>> for u16
[src]
type Output = Vec3<u16>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<u16>) -> Self::Output
[src]
impl Mul<Vec3<u32>> for u32
[src]
type Output = Vec3<u32>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<u32>) -> Self::Output
[src]
impl Mul<Vec3<u64>> for u64
[src]
type Output = Vec3<u64>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<u64>) -> Self::Output
[src]
impl Mul<Vec3<u8>> for u8
[src]
type Output = Vec3<u8>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec3<u8>) -> Self::Output
[src]
impl<T> MulAssign<T> for Vec3<T> where
T: Copy,
T: Copy + MulAssign,
[src]
T: Copy,
T: Copy + MulAssign,
fn mul_assign(&mut self, rhs: T)
[src]
impl<T> MulAssign<Vec3<T>> for Vec3<T> where
T: Copy,
T: MulAssign<T>,
[src]
T: Copy,
T: MulAssign<T>,
fn mul_assign(&mut self, rhs: Self)
[src]
impl<T> Neg for Vec3<T> where
T: Copy,
T: Neg<Output = T>,
[src]
T: Copy,
T: Neg<Output = T>,
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl<T: PartialEq> PartialEq<Vec3<T>> for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> StructuralPartialEq for Vec3<T> where
T: Copy,
[src]
T: Copy,
impl<T> Sub<Vec3<T>> for Vec3<T> where
T: Copy,
T: Sub<T, Output = T>,
[src]
T: Copy,
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<Vec3<T>> for Vec3<T> where
T: Copy,
T: SubAssign<T>,
[src]
T: Copy,
T: SubAssign<T>,
fn sub_assign(&mut self, rhs: Self)
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Vec3<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Vec3<T> where
T: Send,
T: Send,
impl<T> Sync for Vec3<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Vec3<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Vec3<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>,