pub struct Vec2 {
pub x: f32,
pub y: f32,
}
Fields§
§x: f32
§y: f32
Implementations§
Source§impl Vec2
impl Vec2
Sourcepub fn new(x: f32, y: f32) -> Vec2
pub fn new(x: f32, y: f32) -> Vec2
§Create a new instance of Vec2
use ck::Vec2;
let v = Vec2::new(1.0, 2.0);
assert_eq!(v.x, 1.0);
assert_eq!(v.y, 2.0);
Sourcepub fn len(&self) -> f32
pub fn len(&self) -> f32
§Get the length of a Vec2
use ck::Vec2;
let v = Vec2::new(3.0, 4.0);
assert_eq!(v.len(), 5.0);
Sourcepub fn len_squared(&self) -> f32
pub fn len_squared(&self) -> f32
§Get the squared length of a Vec2
use ck::Vec2;
let v = Vec2::new(3.0, 4.0);
assert_eq!(v.len_squared(), 25.0);
Sourcepub fn normalize(&self) -> Vec2
pub fn normalize(&self) -> Vec2
§Get a new normalized version of a Vec2
use ck::Vec2;
let v = Vec2::new(3.0, 4.0);
let vn = v.normalize();
assert_eq!(vn.x, 3.0/5.0);
assert_eq!(vn.y, 4.0/5.0);
Trait Implementations§
Source§impl Add for Vec2
impl Add 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