pub struct Vec2<T> {
pub x: T,
pub y: T,
}
Expand description
A generic 2D vector.
Fields§
§x: T
§y: T
Implementations§
source§impl<T> Vec2<T>
impl<T> Vec2<T>
pub fn zero() -> Self
pub fn up() -> Self
pub fn down() -> Self
pub fn left() -> Self
pub fn right() -> Self
pub fn horiz(&self) -> Self
pub fn vert(&self) -> Self
pub fn len(&self) -> T
pub fn is_longer_than_zero(&self) -> bool
pub fn floor(&self) -> Self
pub fn normalize(&self) -> Self
pub fn clamp_to_length(self, max_length: T) -> Vec2<T>
pub fn clamp_to_rect(self, rect: Rect<T>) -> Vec2<T>
pub fn dot(&self, other: &Self) -> T
pub fn scale(&self, factor: T) -> Self
pub fn subtract(&self, other: &Self) -> Self
pub fn rotate(&self, angle: T) -> Self
pub fn distance_to(&self, other: Self) -> T
Trait Implementations§
source§impl<T> AddAssign for Vec2<T>
impl<T> AddAssign for Vec2<T>
source§fn add_assign(&mut self, other: Vec2<T>)
fn add_assign(&mut self, other: Vec2<T>)
Performs the
+=
operation. Read moresource§impl<T: PartialEq> PartialEq for Vec2<T>
impl<T: PartialEq> PartialEq for Vec2<T>
source§impl<T> SubAssign for Vec2<T>
impl<T> SubAssign for Vec2<T>
source§fn sub_assign(&mut self, other: Vec2<T>)
fn sub_assign(&mut self, other: Vec2<T>)
Performs the
-=
operation. Read moreimpl<T: Copy> Copy for Vec2<T>
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> 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