pub struct Vector2 {
pub x: f64,
pub y: f64,
}Expand description
A displacement or direction, distinct from a Point position.
Fields§
§x: f64Horizontal displacement.
y: f64Vertical displacement.
Implementations§
Source§impl Vector2
impl Vector2
Sourcepub const fn new(horizontal: f64, vertical: f64) -> Self
pub const fn new(horizontal: f64, vertical: f64) -> Self
Preserves the supplied components; validation belongs to the consumer.
Sourcepub fn from_angle(radians: f64) -> Self
pub fn from_angle(radians: f64) -> Self
Returns a unit vector at clockwise radians from the positive horizontal axis. Principal quarter-turn angles preserve exact axis alignment.
Sourcepub fn normalize(self) -> Self
pub fn normalize(self) -> Self
Returns a unit direction, or zero for a zero vector. Finite very large or very small components are scaled before normalization. Nonfinite input does not become a finite zero vector.
Sourcepub fn rotate(self, radians: f64) -> Self
pub fn rotate(self, radians: f64) -> Self
Rotates clockwise in the downward-positive coordinate system.
Sourcepub fn interpolate(&self, target: &Self, progress: f64) -> Self
pub fn interpolate(&self, target: &Self, progress: f64) -> Self
Linearly interpolates or extrapolates with double-precision progress.
Trait Implementations§
impl Copy for Vector2
Source§impl Interpolate for Vector2
impl Interpolate for Vector2
Source§fn interpolate(&self, target: &Self, progress: f64) -> Self
fn interpolate(&self, target: &Self, progress: f64) -> Self
Blends toward
target with nominal progress zero at self and one at target. Read moreimpl StructuralPartialEq for Vector2
Auto Trait Implementations§
impl Forget for Vector2
impl Freeze for Vector2
impl Move 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