Struct TVec2

Source
#[repr(align(16))]
pub struct TVec2<T: Real> { /* private fields */ }
Expand description

A generic 2 component vector

Implementations§

Source§

impl<T: Real> TVec2<T>

Source

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

Construct a new Vec2

Source

pub fn zero() -> Self

Return a vector with all zeroes

Source

pub fn one() -> Self

Return a vector with all ones

Source

pub fn up() -> Self

Return a unit vector that points in the up direction

Source

pub fn down() -> Self

Return a unit vector that points in the down direction

Source

pub fn right() -> Self

Return a unit vector that points in the right direction

Source

pub fn left() -> Self

Return a unit vector that points in the left direction

Trait Implementations§

Source§

impl<T: Real> Add<T> for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: Real> Add for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: TVec2<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Real> AddAssign<T> for TVec2<T>

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<T: Real> AddAssign for TVec2<T>

Source§

fn add_assign(&mut self, rhs: TVec2<T>)

Performs the += operation. Read more
Source§

impl<T: Clone + Real> Clone for TVec2<T>

Source§

fn clone(&self) -> TVec2<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 + Real> Debug for TVec2<T>

Source§

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

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

impl<T: Real> Display for TVec2<T>

Source§

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

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

impl<T: Real> Div<T> for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Real> Div for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: TVec2<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Real> DivAssign<T> for TVec2<T>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T: Real> DivAssign for TVec2<T>

Source§

fn div_assign(&mut self, rhs: TVec2<T>)

Performs the /= operation. Read more
Source§

impl<T: Real> DotProduct<T> for TVec2<T>

Source§

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

Produce the dot product of self and rhs
Source§

impl<T: Real> From<[T; 2]> for TVec2<T>

Source§

fn from(other: [T; 2]) -> Self

Take the array as a vector

Source§

impl<T: Real> From<(T, T)> for TVec2<T>

Source§

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

Take the array as a vector

Source§

impl<T: Real> From<T> for TVec2<T>

Source§

fn from(other: T) -> Self

Take a value as the x component of a Vec2 and leave the y component as 0

Source§

impl<T: Real> From<TVec2<T>> for TVec2P<T>

Source§

fn from(other: TVec2<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Real> From<TVec2<T>> for TVec3<T>

Source§

fn from(other: TVec2<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Real> From<TVec2<T>> for TVec4<T>

Source§

fn from(other: TVec2<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Real> From<TVec3<T>> for TVec2<T>

Source§

fn from(other: TVec3<T>) -> Self

Take the xy components of a Vec3 and produce a Vec2

Source§

impl<T: Real> From<TVec4<T>> for TVec2<T>

Source§

fn from(other: TVec4<T>) -> Self

Take the xy components of a Vec4 and produce a Vec2

Source§

impl<T: Real> Index<usize> for TVec2<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: Real> IndexMut<usize> for TVec2<T>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: Real> Into<[T; 2]> for TVec2<T>

Source§

fn into(self) -> [T; 2]

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

impl<T: Real> Into<(T, T)> for TVec2<T>

Source§

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

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

impl<T: Real> IntoSTD140 for TVec2<T>

Source§

type Output = TVec2P<T>

Source§

fn into_std140(self) -> Self::Output

Source§

impl<T: Real> Length for TVec2<T>

Source§

type Output = T

Source§

fn length(&self) -> Self::Output

Source§

impl<T: Real> LengthSquared for TVec2<T>

Source§

type Output = T

Source§

fn length_squared(&self) -> Self::Output

Source§

impl<T: Real> Lerp<T> for TVec2<T>

Source§

fn lerp(&self, b: &Self, factor: T) -> Self

Return the result of interpolating between self and b with factor factor
Source§

impl<T: Real> Mul<T> for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Real> Mul for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Real> MulAssign<T> for TVec2<T>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: Real> MulAssign for TVec2<T>

Source§

fn mul_assign(&mut self, rhs: TVec2<T>)

Performs the *= operation. Read more
Source§

impl<T: Real> Neg for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T: Real> Normalize for TVec2<T>

Source§

fn normalize(self) -> Self

Source§

impl<T: Real> NormalizeAssign for TVec2<T>

Source§

impl<T: Real> PartialEq for TVec2<T>

Source§

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

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

fn ne(&self, other: &TVec2<T>) -> bool

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

impl<T: Real> Sub<T> for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T: Real> Sub for TVec2<T>

Source§

type Output = TVec2<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: TVec2<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: Real> SubAssign<T> for TVec2<T>

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl<T: Real> SubAssign for TVec2<T>

Source§

fn sub_assign(&mut self, rhs: TVec2<T>)

Performs the -= operation. Read more
Source§

impl<T: Copy + Real> Copy for TVec2<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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