Vec2

Struct Vec2 

Source
#[repr(C)]
pub struct Vec2<T> { pub x: T, pub y: T, }

Fields§

§x: T§y: T

Implementations§

Source§

impl<T> Vec2<T>
where T: Copy,

Source

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

Creates a new Vec2 from multiple components

Source

pub fn len() -> usize

return the length of element

Source

pub fn to_tuple(&self) -> (T, T)

Source

pub fn xx(&self) -> Self

Source

pub fn xy(&self) -> Self

Source

pub fn yx(&self) -> Self

Source

pub fn yy(&self) -> Self

Source

pub fn xxx(&self) -> Vec3<T>

Source

pub fn xxy(&self) -> Vec3<T>

Source

pub fn xyx(&self) -> Vec3<T>

Source

pub fn xyy(&self) -> Vec3<T>

Source

pub fn yxx(&self) -> Vec3<T>

Source

pub fn yxy(&self) -> Vec3<T>

Source

pub fn yyx(&self) -> Vec3<T>

Source

pub fn yyy(&self) -> Vec3<T>

Source

pub fn xxxx(&self) -> Vec4<T>

Source

pub fn xxyx(&self) -> Vec4<T>

Source

pub fn xyxx(&self) -> Vec4<T>

Source

pub fn xyyx(&self) -> Vec4<T>

Source

pub fn xxxy(&self) -> Vec4<T>

Source

pub fn xxyy(&self) -> Vec4<T>

Source

pub fn xyxy(&self) -> Vec4<T>

Source

pub fn xyyy(&self) -> Vec4<T>

Source

pub fn yxxx(&self) -> Vec4<T>

Source

pub fn yxyx(&self) -> Vec4<T>

Source

pub fn yyxx(&self) -> Vec4<T>

Source

pub fn yyyx(&self) -> Vec4<T>

Source

pub fn yxxy(&self) -> Vec4<T>

Source

pub fn yxyy(&self) -> Vec4<T>

Source

pub fn yyxy(&self) -> Vec4<T>

Source

pub fn yyyy(&self) -> Vec4<T>

Source§

impl<T> Vec2<T>
where T: Vec + Math,

Source

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

Source

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

Source

pub fn length2(&self) -> T

Source

pub fn length(&self) -> T

Source

pub fn distance(&self, b: Self) -> T

Source

pub fn normalize(&self) -> Self

Trait Implementations§

Source§

impl<T> Add for Vec2<T>
where T: Add<Output = T>,

Source§

type Output = Vec2<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T> AddAssign for Vec2<T>
where T: AddAssign<T>,

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl<T> AsMut<Vec2<T>> for Vec2<T>

Source§

fn as_mut(&mut self) -> &mut Vec2<T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsRef<Vec2<T>> for Vec2<T>

Source§

fn as_ref(&self) -> &Vec2<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> Binary for Vec2<T>
where T: Vec + Math,

Source§

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

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

impl<T: Clone> Clone for Vec2<T>

Source§

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

Returns a duplicate 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 Vec2<T>

Source§

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

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

impl<T: Default> Default for Vec2<T>

Source§

fn default() -> Vec2<T>

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

impl<T> Display for Vec2<T>
where T: Debug,

Source§

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

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

impl<T> Div<T> for Vec2<T>
where T: Div<Output = T> + Copy,

Source§

type Output = Vec2<T>

The resulting type after applying the / operator.
Source§

fn div(self, s: T) -> Self

Performs the / operation. Read more
Source§

impl<T> Div for Vec2<T>
where T: Div<Output = T>,

Source§

type Output = Vec2<T>

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
Source§

impl<'a, T> DivAssign<&'a T> for Vec2<T>
where T: DivAssign<T> + Copy,

Source§

fn div_assign(&mut self, s: &'a T)

Performs the /= operation. Read more
Source§

impl<T> DivAssign<T> for Vec2<T>
where T: DivAssign<T> + Copy,

Source§

fn div_assign(&mut self, s: T)

Performs the /= operation. Read more
Source§

impl<T> DivAssign for Vec2<T>
where T: DivAssign<T>,

Source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
Source§

impl<T> From<[T; 2]> for Vec2<T>
where T: Copy,

Source§

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

Converts to this type from the input type.
Source§

impl<T> From<(T, T)> for Vec2<T>
where T: Copy,

Source§

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

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Vec2<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Interpolation<T> for Vec2<T>
where T: Copy + One + Mul<Output = T> + Add<Output = T> + Sub<Output = T>,

Source§

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

Source§

impl<T> Math for Vec2<T>
where T: Copy + Math,

Source§

fn abs(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

fn rsqrt(self) -> Self

Source§

fn sin(self) -> Self

Source§

fn cos(self) -> Self

Source§

fn tan(self) -> Self

Source§

fn sincos(self) -> (Self, Self)

Source§

fn acos(self) -> Self

Source§

fn asin(self) -> Self

Source§

fn atan(self) -> Self

Source§

fn exp(self) -> Self

Source§

fn exp2(self) -> Self

Source§

fn log(self, _rhs: Self) -> Self

Source§

fn log2(self) -> Self

Source§

fn log10(self) -> Self

Source§

fn to_radians(self) -> Self

Source§

fn to_degrees(self) -> Self

Source§

fn min(self, _rhs: Self) -> Self

Source§

fn max(self, _rhs: Self) -> Self

Source§

fn saturate(self) -> Self

Source§

fn snorm2unorm(self) -> Self

Source§

fn unorm2snorm(self) -> Self

Source§

fn clamp(self, minval: Self, maxval: Self) -> Self

Source§

impl<T> Mul<T> for Vec2<T>
where T: Mul<Output = T> + Copy,

Source§

type Output = Vec2<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T> Mul for Vec2<T>
where T: Mul<Output = T>,

Source§

type Output = Vec2<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

impl<'a, T> MulAssign<&'a T> for Vec2<T>
where T: MulAssign<T> + Copy,

Source§

fn mul_assign(&mut self, other: &'a T)

Performs the *= operation. Read more
Source§

impl<T> MulAssign<T> for Vec2<T>
where T: MulAssign<T> + Copy,

Source§

fn mul_assign(&mut self, s: T)

Performs the *= operation. Read more
Source§

impl<T> MulAssign for Vec2<T>
where T: MulAssign<T>,

Source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
Source§

impl<T> Neg for Vec2<T>
where T: Neg<Output = T>,

Source§

type Output = Vec2<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T> One for Vec2<T>
where T: One,

Source§

fn one() -> Self

Source§

impl<T: PartialEq> PartialEq for Vec2<T>

Source§

fn eq(&self, other: &Vec2<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> Sub for Vec2<T>
where T: Sub<Output = T>,

Source§

type Output = Vec2<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T> SubAssign for Vec2<T>
where T: SubAssign<T>,

Source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
Source§

impl<T> TypeSize<Vec2<T>> for Vec2<T>

Source§

impl<T> UnitX for Vec2<T>
where T: One + Zero,

Source§

fn unit_x() -> Self

Source§

impl<T> UnitY for Vec2<T>
where T: One + Zero,

Source§

fn unit_y() -> Self

Source§

impl<T> Zero for Vec2<T>
where T: Zero,

Source§

fn zero() -> Self

Source§

impl<T: Copy> Copy for Vec2<T>

Source§

impl<T: Eq> Eq for Vec2<T>

Source§

impl<T> StructuralPartialEq for Vec2<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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