Struct Vector3

Source
pub struct Vector3<T> {
    pub x: T,
    pub y: T,
    pub z: T,
}

Fields§

§x: T§y: T§z: T

Implementations§

Source§

impl<T> Vector3<T>

Source

pub fn new(x: T, y: T, z: T) -> Self

Source

pub fn scaled<U, O>(self, scalar: U) -> Vector3<O>
where T: Mul<U, Output = O>, U: Clone,

Multiplies the vector with a scalar

Source

pub fn cross_product<U, O>(self, other: Vector3<U>) -> Vector3<O>
where T: Mul<U, Output = O> + Clone, U: Clone, O: Sub<Output = O>,

Source

pub fn homogenous(self) -> Vector4<T>
where T: MatrixElement,

Creates a Vector4 where the w coordinate is 1. For more info, see Homogeneous Coordinates

Source

pub fn normalize_homogeneous(self) -> Vector3<T>
where T: Div<Output = T> + Clone + MatrixElement,

Normalizes self so the z coordinate is 1. For more info, see Homogeneous Coordinates

Source

pub fn map<F, U>(self, f: F) -> Vector3<U>
where F: Fn(T) -> U,

Applies a function to every element of the vector

Trait Implementations§

Source§

impl<T, U, O> Add<Vector3<U>> for Vector3<T>
where T: Add<U, Output = O>,

Adds two vectors element by element

Source§

type Output = Vector3<O>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector3<U>) -> Vector3<O>

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for Vector3<T>

Source§

fn clone(&self) -> Vector3<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Vector3<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Display for Vector3<T>
where T: Display + Clone,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> From<(T, T, T)> for Vector3<T>

Source§

fn from(t: (T, T, T)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Matrix<T>> for Vector3<T>
where T: Clone,

Source§

fn from(mat: Matrix<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vector<T>> for Vector3<T>

Source§

fn from(vec: Vector<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> Into<(T, T, T)> for Vector3<T>

Source§

fn into(self) -> (T, T, T)

Converts this type into the (usually inferred) input type.
Source§

impl<T> Into<Matrix<T>> for Vector3<T>

Source§

fn into(self) -> Matrix<T>

Converts this type into the (usually inferred) input type.
Source§

impl<T> Into<Vector<T>> for Vector3<T>

Source§

fn into(self) -> Vector<T>

Converts this type into the (usually inferred) input type.
Source§

impl<T, O> Neg for Vector3<T>
where T: Neg<Output = O>,

Source§

type Output = Vector3<O>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Vector3<O>

Performs the unary - operation. Read more
Source§

impl<T: PartialEq> PartialEq for Vector3<T>

Source§

fn eq(&self, other: &Vector3<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, U, O> Sub<Vector3<U>> for Vector3<T>
where T: Sub<U, Output = O>,

Subtracts two vectors element by element

Source§

type Output = Vector3<O>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vector3<U>) -> Vector3<O>

Performs the - operation. Read more
Source§

impl<T: Eq> Eq for Vector3<T>

Source§

impl<T> StructuralPartialEq for Vector3<T>

Auto Trait Implementations§

§

impl<T> Freeze for Vector3<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vector3<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vector3<T>
where T: Send,

§

impl<T> Sync for Vector3<T>
where T: Sync,

§

impl<T> Unpin for Vector3<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vector3<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.