pub struct Vector2 {
pub x: f64,
pub y: f64,
}Expand description
A 2D vector / point in a single, untyped coordinate space.
Fields§
§x: f64§y: f64Implementations§
Source§impl Vector2
impl Vector2
pub const ZERO: Vector2
pub const fn new(x: f64, y: f64) -> Self
Sourcepub const fn splat(v: f64) -> Self
pub const fn splat(v: f64) -> Self
Both components set to the same value (mirrors Vector2(double val)).
pub fn squared_length(self) -> f64
pub fn length(self) -> f64
Sourcepub fn normalize(self, allow_zero: bool) -> Vector2
pub fn normalize(self, allow_zero: bool) -> Vector2
Returns the unit-length vector in the same direction.
For a zero vector, returns (0, 0) when allow_zero is true, otherwise
(0, 1) — matching the original’s Vector2(0, !allowZero) behaviour.
Sourcepub fn orthogonal(self, polarity: bool) -> Vector2
pub fn orthogonal(self, polarity: bool) -> Vector2
A vector of the same length orthogonal to this one.
Sourcepub fn orthonormal(self, polarity: bool, allow_zero: bool) -> Vector2
pub fn orthonormal(self, polarity: bool, allow_zero: bool) -> Vector2
A unit-length vector orthogonal to this one.
Sourcepub fn is_nonzero(self) -> bool
pub fn is_nonzero(self) -> bool
True when the vector is non-zero (mirrors operator bool).
Trait Implementations§
impl Copy for Vector2
impl StructuralPartialEq for Vector2
Auto Trait Implementations§
impl Freeze for Vector2
impl RefUnwindSafe for Vector2
impl Send for Vector2
impl Sync for Vector2
impl Unpin for Vector2
impl UnsafeUnpin for Vector2
impl UnwindSafe for Vector2
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more