diff --git a/src/cgmath/vector.rs b/src/cgmath/vector.rs index a4cddd9..d5c6d0d 100644 --- a/src/cgmath/vector.rs +++ b/src/cgmath/vector.rs @@ -65,6 +65,24 @@ vec!(impl Vec2 { x, y }) vec!(impl Vec3 { x, y, z }) vec!(impl Vec4 { x, y, z, w }) +impl Vec2 { + #[inline] pub fn unit_x() -> Vec2 { Vec2::new(one(), zero()) } + #[inline] pub fn unit_y() -> Vec2 { Vec2::new(zero(), one()) } +} + +impl Vec3 { + #[inline] pub fn unit_x() -> Vec3 { Vec3::new(one(), zero(), zero()) } + #[inline] pub fn unit_y() -> Vec3 { Vec3::new(zero(), one(), zero()) } + #[inline] pub fn unit_z() -> Vec3 { Vec3::new(zero(), zero(), one()) } +} + +impl Vec4 { + #[inline] pub fn unit_x() -> Vec4 { Vec4::new(one(), zero(), zero(), zero()) } + #[inline] pub fn unit_y() -> Vec4 { Vec4::new(zero(), one(), zero(), zero()) } + #[inline] pub fn unit_z() -> Vec4 { Vec4::new(zero(), zero(), one(), zero()) } + #[inline] pub fn unit_w() -> Vec4 { Vec4::new(zero(), zero(), zero(), one()) } +} + array!(impl Vec2 -> [S, ..2]) array!(impl Vec3 -> [S, ..3]) array!(impl Vec4 -> [S, ..4])