Skip to main content

TyVector3

Struct TyVector3 

Source
pub struct TyVector3<T = f64> {
    pub x: T,
    pub y: T,
    pub z: T,
}
Expand description

A 3D vector generic over its component type T.

The component type defaults to f64, so TyVector3 is the f64 vector; see TyVector3F32, TyVector3F64, and TyVector3U32 for the common instantiations.

Fields§

§x: T

The x component.

§y: T

The y component.

§z: T

The z component.

Implementations§

Source§

impl<T> TyVector3<T>

Source

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

Creates a new vector from x, y, and z components.

Source§

impl<T: Add<Output = T> + Copy + Mul<Output = T> + Sub<Output = T>> TyVector3<T>

Source

pub fn cross(&self, other: &Self) -> Self

Returns the cross product of self and other.

Source

pub fn dot(&self, other: &Self) -> T

Returns the dot product of self and other.

Source§

impl TyVector3<f32>

Source

pub fn magnitude(&self) -> f32

Returns the Euclidean length of this vector.

Source§

impl TyVector3<f64>

Source

pub fn magnitude(&self) -> f64

Returns the Euclidean length of this vector.

Trait Implementations§

Source§

impl<T: Add<Output = T>> Add for TyVector3<T>

Source§

type Output = TyVector3<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for TyVector3<T>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for TyVector3<T>

Source§

impl<T: Debug> Debug for TyVector3<T>

Source§

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

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

impl<T: Default> Default for TyVector3<T>

Source§

fn default() -> TyVector3<T>

Returns the “default value” for a type. Read more
Source§

impl<T: Copy + Mul<Output = T>> Mul<T> for TyVector3<T>

Source§

type Output = TyVector3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self

Performs the * operation. Read more
Source§

impl Mul<TyVector3<f32>> for f32

Source§

type Output = TyVector3<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: TyVector3<f32>) -> TyVector3<f32>

Performs the * operation. Read more
Source§

impl Mul<TyVector3> for f64

Source§

type Output = TyVector3

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: TyVector3<f64>) -> TyVector3<f64>

Performs the * operation. Read more
Source§

impl<T: PartialEq> PartialEq for TyVector3<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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: PartialEq> StructuralPartialEq for TyVector3<T>

Source§

impl<T: Sub<Output = T>> Sub for TyVector3<T>

Source§

type Output = TyVector3<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for TyVector3<T>
where T: UnsafeUnpin,

§

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