#[repr(C)]pub struct Vec2<F>where
F: Float,{
pub x: F,
pub y: F,
}Expand description
2D Euclidian vector with X and Y components.
Fields§
§x: F§y: FImplementations§
Source§impl<F> Vec2<F>where
F: Float,
impl<F> Vec2<F>where
F: Float,
Sourcepub fn into_basis(self) -> (Self, Self)
pub fn into_basis(self) -> (Self, Self)
Split vector into it’s basic vectors i, j.
Sourcepub fn dot_normalized(&self, other: Self) -> F
pub fn dot_normalized(&self, other: Self) -> F
Computes dot product between two normalized copies of the vectors.
Sourcepub fn sqrt_magnitude(&self) -> F
pub fn sqrt_magnitude(&self) -> F
Computes the squared magnitude of the vector.
Sourcepub fn distance_to(&self, other: Self) -> F
pub fn distance_to(&self, other: Self) -> F
Computes the distance between two vectors.
Sourcepub fn normalized(&self) -> Self
pub fn normalized(&self) -> Self
Returns the normalized version of the vector.
Trait Implementations§
Source§impl<F> AddAssign for Vec2<F>where
F: Float,
impl<F> AddAssign for Vec2<F>where
F: Float,
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreimpl<F> Copy for Vec2<F>
Source§impl<F> DivAssign<F> for Vec2<F>where
F: Float,
impl<F> DivAssign<F> for Vec2<F>where
F: Float,
Source§fn div_assign(&mut self, rhs: F)
fn div_assign(&mut self, rhs: F)
Performs the
/= operation. Read moreSource§impl<F> MulAssign<F> for Vec2<F>where
F: Float,
impl<F> MulAssign<F> for Vec2<F>where
F: Float,
Source§fn mul_assign(&mut self, rhs: F)
fn mul_assign(&mut self, rhs: F)
Performs the
*= operation. Read moreSource§impl<F> PartialOrd for Vec2<F>where
F: Float + PartialOrd,
impl<F> PartialOrd for Vec2<F>where
F: Float + PartialOrd,
impl<F> StructuralPartialEq for Vec2<F>
Source§impl<F> SubAssign for Vec2<F>where
F: Float,
impl<F> SubAssign for Vec2<F>where
F: Float,
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreAuto Trait Implementations§
impl<F> Freeze for Vec2<F>where
F: Freeze,
impl<F> RefUnwindSafe for Vec2<F>where
F: RefUnwindSafe,
impl<F> Send for Vec2<F>where
F: Send,
impl<F> Sync for Vec2<F>where
F: Sync,
impl<F> Unpin for Vec2<F>where
F: Unpin,
impl<F> UnsafeUnpin for Vec2<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for Vec2<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more