#[repr(C)]pub struct Vec2 {
pub x: f32,
pub y: f32,
}Expand description
A record representing a 2D vector with an x and y component.
Fields§
§x: f32§y: f32Implementations§
Source§impl Vec2
impl Vec2
pub fn new(x: f32, y: f32) -> Vec2
pub fn zero() -> Vec2
pub fn is_zero(&self) -> bool
pub fn distance(&self, other: &Vec2) -> f32
pub fn distance_squared(&self, other: &Vec2) -> f32
pub fn length(&self) -> f32
pub fn angle(&self) -> f32
pub fn normalize(&self) -> Vec2
pub fn perp(&self) -> Vec2
pub fn dot(&self, other: &Vec2) -> f32
pub fn clamp(&self, from: &Vec2, to: &Vec2) -> Vec2
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 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