pub struct Vec2 { /* private fields */ }Expand description
A 2D vector used for world-space and screen-space coordinates.
The type is intentionally unitless. Callers should document whether a value is in simulation world units, logical screen pixels, physical surface pixels, or another coordinate space.
Implementations§
Source§impl Vec2
impl Vec2
Sourcepub fn length_squared(self) -> f32
pub fn length_squared(self) -> f32
Returns the squared vector length.
Use this instead of Vec2::length when only relative distance matters.
Sourcepub fn normalized(self) -> Self
pub fn normalized(self) -> Self
Returns a unit-length vector with the same direction.
Zero-length and near-zero vectors return Vec2::ZERO instead of NaN.
Trait Implementations§
Source§impl AddAssign for Vec2
impl AddAssign for Vec2
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreimpl Copy for Vec2
Source§impl DivAssign<f32> for Vec2
impl DivAssign<f32> for Vec2
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
Performs the
/= operation. Read moreSource§impl Interpolate for Vec2
impl Interpolate for Vec2
Source§fn interpolate(self, end: Self, amount: f32) -> Self
fn interpolate(self, end: Self, amount: f32) -> Self
Interpolates between
self and end.Source§impl MulAssign<f32> for Vec2
impl MulAssign<f32> for Vec2
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
Performs the
*= operation. Read moreimpl StructuralPartialEq for Vec2
Auto Trait Implementations§
impl Freeze for Vec2
impl RefUnwindSafe for Vec2
impl Send for Vec2
impl Sync for Vec2
impl Unpin for Vec2
impl UnsafeUnpin for Vec2
impl UnwindSafe for Vec2
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