pub struct Vec2 {
pub dx: f64,
pub dy: f64,
}Expand description
A 2D vector (displacement) in logical pixels.
Distinct from Point: a Vec2 is a difference between
points, not a position. Subtracting two points yields a Vec2; adding a
Vec2 to a point yields a point.
Fields§
§dx: f64§dy: f64Implementations§
Source§impl Vec2
impl Vec2
pub const ZERO: Self
pub const fn new(dx: f64, dy: f64) -> Self
pub fn length(self) -> f64
pub fn length_squared(self) -> f64
pub fn dot(self, other: Self) -> f64
Sourcepub fn normalized(self) -> Self
pub fn normalized(self) -> Self
Returns the unit vector in the same direction, or Vec2::ZERO if the
length is zero.
Trait Implementations§
impl Copy for Vec2
impl 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