Struct gfxmath_vec2::Vec2 [−][src]
Fields
x: Ty: TImplementations
impl<T> Vec2<T>[src]
pub fn new(x: T, y: T) -> Self[src]
pub fn as_ptr(&self) -> *const T[src]
pub fn as_mut_ptr(&mut self) -> *mut T[src]
pub fn as_slice(&self) -> &[T][src]
use gfxmath_vec2::Vec2; let a = Vec2::<f32>::new(1.0, 2.0); let a_slice = a.as_slice(); assert_eq!(1.0, a_slice[0]); assert_eq!(2.0, a_slice[1]);
pub fn as_mut_slice(&mut self) -> &mut [T][src]
use gfxmath_vec2::Vec2; let mut a = Vec2::<f32>::new(1.0, 2.0); { let a_slice = a.as_mut_slice(); assert_eq!(1.0, a_slice[0]); assert_eq!(2.0, a_slice[1]); a_slice[1] = 108.0; assert_eq!(108.0, a_slice[1]); } a.x = 4.5; assert_eq!(4.5, a.x); let a_slice = a.as_mut_slice(); assert_eq!(4.5, a_slice[0]); assert_eq!(108.0, a_slice[1]);
impl<T> Vec2<T> where
T: Clone, [src]
T: Clone,
pub fn all(val: T) -> Self[src]
use gfxmath_vec2::Vec2; let v = Vec2::<f32>::all(2.5); assert_eq!(2.5, v.x); assert_eq!(2.5, v.y);
Trait Implementations
impl<T> Add<&'_ Vec2<T>> for &Vec2<T> where
T: Add<Output = T> + Clone, [src]
T: Add<Output = T> + Clone,
type Output = Vec2<T>
The resulting type after applying the + operator.
fn add(self, rhs: &Vec2<T>) -> Self::Output[src]
impl<T> Add<&'_ Vec2<T>> for Vec2<T> where
T: Add<Output = T> + Clone, [src]
T: Add<Output = T> + Clone,
type Output = Vec2<T>
The resulting type after applying the + operator.
fn add(self, rhs: &Vec2<T>) -> Self::Output[src]
impl<T> Add<T> for Vec2<T> where
T: Add<Output = T> + Clone, [src]
T: Add<Output = T> + Clone,
type Output = Vec2<T>
The resulting type after applying the + operator.
fn add(self, rhs: T) -> Self::Output[src]
use gfxmath_vec2::Vec2; let v = Vec2::<f32>::new(1.0, 2.0); let res: Vec2<f32> = (v + 3.0).into(); assert_eq!(4.0, res.x); assert_eq!(5.0, res.y);
impl<T> Add<T> for &Vec2<T> where
T: Add<Output = T> + Clone, [src]
T: Add<Output = T> + Clone,
type Output = Vec2<T>
The resulting type after applying the + operator.
fn add(self, rhs: T) -> Self::Output[src]
impl<T> Add<Vec2<T>> for Vec2<T> where
T: Add<Output = T> + Clone, [src]
T: Add<Output = T> + Clone,
type Output = Vec2<T>
The resulting type after applying the + operator.
fn add(self, rhs: Vec2<T>) -> Self::Output[src]
use gfxmath_vec2::Vec2; let a = Vec2::new(1.0, 2.0); let b = Vec2::new(3.0, 4.0); let res = &a + &b; assert_eq!(1.0, a.x); assert_eq!(2.0, a.y); assert_eq!(3.0, b.x); assert_eq!(4.0, b.y); assert_eq!(4.0, res.x); assert_eq!(6.0, res.y);
impl<T> Add<Vec2<T>> for &Vec2<T> where
T: Add<Output = T> + Clone, [src]
T: Add<Output = T> + Clone,
type Output = Vec2<T>
The resulting type after applying the + operator.
fn add(self, rhs: Vec2<T>) -> Self::Output[src]
impl<T: Clone> Clone for Vec2<T>[src]
impl<T: Debug> Debug for Vec2<T>[src]
impl<T> Div<T> for Vec2<T> where
T: Div<Output = T> + Copy, [src]
T: Div<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the / operator.
fn div(self, rhs: T) -> Self::Output[src]
Scalar division with vector
use gfxmath_vec2::Vec2; let a = Vec2::<f32>::new(0.5, 2.5); let b = a / 2.0; assert_eq!( 0.25, b.x); assert_eq!( 1.25, b.y);
impl<T> Div<T> for &Vec2<T> where
T: Div<Output = T> + Copy, [src]
T: Div<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the / operator.
fn div(self, rhs: T) -> Self::Output[src]
impl<T> From<&'_ (T, T)> for Vec2<T> where
T: Clone, [src]
T: Clone,
use gfxmath_vec2::Vec2; let v0 = (3.0, 2.0); let v: Vec2<f32> = (&v0).into(); assert_eq!(3.0, v.x); assert_eq!(2.0, v.y);
impl<T> From<(T, T)> for Vec2<T>[src]
use gfxmath_vec2::Vec2; let v: Vec2<f32> = (3.0, 2.0).into(); assert_eq!(3.0, v.x); assert_eq!(2.0, v.y);
impl<T: Hash> Hash for Vec2<T>[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<T> Mul<&'_ Vec2<T>> for &Vec2<T> where
T: Mul<Output = T> + Copy, [src]
T: Mul<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the * operator.
fn mul(self, rhs: &Vec2<T>) -> Self::Output[src]
impl<T> Mul<&'_ Vec2<T>> for Vec2<T> where
T: Mul<Output = T> + Copy, [src]
T: Mul<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the * operator.
fn mul(self, rhs: &Vec2<T>) -> Self::Output[src]
impl<T> Mul<T> for Vec2<T> where
T: Mul<Output = T> + Copy, [src]
T: Mul<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the * operator.
fn mul(self, rhs: T) -> Self::Output[src]
Scalar multiplication with vector
use gfxmath_vec2::Vec2; let a = Vec2::<f32>::new(0.5, 2.5); let b = Vec2::from(a * 2.0); assert_eq!( 1.0, b.x); assert_eq!( 5.0, b.y);
impl<T> Mul<T> for &Vec2<T> where
T: Mul<Output = T> + Copy, [src]
T: Mul<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the * operator.
fn mul(self, rhs: T) -> Self::Output[src]
impl<T> Mul<Vec2<T>> for Vec2<T> where
T: Mul<Output = T> + Copy, [src]
T: Mul<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the * operator.
fn mul(self, rhs: Vec2<T>) -> Self::Output[src]
use gfxmath_vec2::Vec2; let mut a = Vec2::<f32>::new(1.5, 2.5); let b = Vec2::<f32>::new(4.0, 2.0); let c = &a * &b; a.x = 2.0; assert_eq!( 6.0, c.x); assert_eq!( 5.0, c.y); let c = a * b; assert_eq!( 8.0, c.x); assert_eq!( 5.0, c.y);
impl<T> Mul<Vec2<T>> for &Vec2<T> where
T: Mul<Output = T> + Copy, [src]
T: Mul<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the * operator.
fn mul(self, rhs: Vec2<T>) -> Self::Output[src]
impl<T> Neg for Vec2<T> where
T: Neg<Output = T> + Copy, [src]
T: Neg<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the - operator.
fn neg(self) -> Self::Output[src]
Scalar multiplication with vector
use gfxmath_vec2::Vec2; let a = Vec2::<f32>::new(2.0, 6.0); let res = -a; assert_eq!(-2.0, res.x); assert_eq!(-6.0, res.y);
impl<T> Neg for &Vec2<T> where
T: Neg<Output = T> + Copy, [src]
T: Neg<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the - operator.
fn neg(self) -> Self::Output[src]
impl Norm for Vec2<f32>[src]
type Output = Option<Vec2<f32>>
fn norm(self) -> Self::Output[src]
use gfxmath_vec2::ops::Norm; use gfxmath_vec2::Vec2; let a = Vec2::<f32>::new(3.0, 4.0); let an = a.norm().unwrap(); assert_eq!(3.0/5.0, an.x); assert_eq!(4.0/5.0, an.y);
impl Norm for &Vec2<f32>[src]
impl Norm for Vec2<f64>[src]
type Output = Option<Vec2<f64>>
fn norm(self) -> Self::Output[src]
use gfxmath_vec2::ops::Norm; use gfxmath_vec2::Vec2; let a = Vec2::<f64>::new(3.0, 4.0); let an = a.norm().unwrap(); assert_eq!(3.0/5.0, an.x); assert_eq!(4.0/5.0, an.y);
impl Norm for &Vec2<f64>[src]
impl<T: PartialEq> PartialEq<Vec2<T>> for Vec2<T>[src]
impl<T> StructuralPartialEq for Vec2<T>[src]
impl<T: Sub<Output = T> + Copy> Sub<&'_ Vec2<T>> for &Vec2<T>[src]
type Output = Vec2<T>
The resulting type after applying the - operator.
fn sub(self, rhs: &Vec2<T>) -> Self::Output[src]
impl<T: Sub<Output = T> + Copy> Sub<&'_ Vec2<T>> for Vec2<T>[src]
type Output = Vec2<T>
The resulting type after applying the - operator.
fn sub(self, rhs: &Vec2<T>) -> Self::Output[src]
impl<T> Sub<T> for Vec2<T> where
T: Sub<Output = T> + Copy, [src]
T: Sub<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the - operator.
fn sub(self, rhs: T) -> Self::Output[src]
use gfxmath_vec2::Vec2; let v = Vec2::new(1.0, 2.0); let res: Vec2<f32> = (v - 3.0).into(); assert_eq!(-2.0, res.x); assert_eq!(-1.0, res.y);
impl<T> Sub<T> for &Vec2<T> where
T: Sub<Output = T> + Copy, [src]
T: Sub<Output = T> + Copy,
type Output = Vec2<T>
The resulting type after applying the - operator.
fn sub(self, rhs: T) -> Self::Output[src]
impl<T: Sub<Output = T> + Copy> Sub<Vec2<T>> for Vec2<T>[src]
type Output = Vec2<T>
The resulting type after applying the - operator.
fn sub(self, rhs: Vec2<T>) -> Self::Output[src]
use gfxmath_vec2::Vec2; let mut a = Vec2::<f32>::new(0.5, 2.5); let b = Vec2::<f32>::new(1.5, 2.5); let c = Vec2::from(&a - &b); a.x = 1.0; assert_eq!(-1.0, c.x); assert_eq!( 0.0, c.y); let c2 = Vec2::from(a - b); assert_eq!(-0.5, c2.x); assert_eq!( 0.0, c2.y);
impl<T: Sub<Output = T> + Copy> Sub<Vec2<T>> for &Vec2<T>[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Vec2<T> where
T: RefUnwindSafe, [src]
T: RefUnwindSafe,
impl<T> Send for Vec2<T> where
T: Send, [src]
T: Send,
impl<T> Sync for Vec2<T> where
T: Sync, [src]
T: Sync,
impl<T> Unpin for Vec2<T> where
T: Unpin, [src]
T: Unpin,
impl<T> UnwindSafe for Vec2<T> where
T: UnwindSafe, [src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,