[][src]Struct cgmath::Vector2

#[repr(C)]pub struct Vector2<S> {
    pub x: S,
    pub y: S,
}

A 2-dimensional vector.

This type is marked as #[repr(C)].

Fields

x: S

The x component of the vector.

y: S

The y component of the vector.

Implementations

impl<S> Vector2<S>[src]

pub const fn new(x: S, y: S) -> Vector2<S>[src]

Construct a new vector, using the provided values.

pub fn map<U, F>(self, f: F) -> Vector2<U> where
    F: FnMut(S) -> U, 
[src]

Perform the given operation on each field in the vector, returning a new point constructed from the operations.

pub fn zip<S2, S3, F>(self, v2: Vector2<S2>, f: F) -> Vector2<S3> where
    F: FnMut(S, S2) -> S3, 
[src]

Construct a new vector where each component is the result of applying the given operation to each pair of components of the given vectors.

impl<S: NumCast + Copy> Vector2<S>[src]

pub fn cast<T: NumCast>(&self) -> Option<Vector2<T>>[src]

Component-wise casting to another type.

impl<S: BaseNum> Vector2<S>[src]

pub fn unit_x() -> Vector2<S>[src]

A unit vector in the x direction.

pub fn unit_y() -> Vector2<S>[src]

A unit vector in the y direction.

pub fn perp_dot(self, other: Vector2<S>) -> S[src]

The perpendicular dot product of the vector and other.

pub fn extend(self, z: S) -> Vector3<S>[src]

Create a Vector3, using the x and y values from this vector, and the provided z.

Trait Implementations

impl<S: BaseFloat> AbsDiffEq<Vector2<S>> for Vector2<S>[src]

type Epsilon = S::Epsilon

Used for specifying relative comparisons.

impl<'a, S: BaseNum> Add<&'a Vector2<S>> for Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the + operator.

impl<'a, 'b, S: BaseNum> Add<&'a Vector2<S>> for &'b Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the + operator.

impl<'a, S: BaseNum> Add<&'a Vector2<S>> for Point2<S>[src]

type Output = Point2<S>

The resulting type after applying the + operator.

impl<'a, 'b, S: BaseNum> Add<&'a Vector2<S>> for &'b Point2<S>[src]

type Output = Point2<S>

The resulting type after applying the + operator.

impl<S: BaseNum> Add<Vector2<S>> for Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the + operator.

impl<'a, S: BaseNum> Add<Vector2<S>> for &'a Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the + operator.

impl<S: BaseNum> Add<Vector2<S>> for Point2<S>[src]

type Output = Point2<S>

The resulting type after applying the + operator.

impl<'a, S: BaseNum> Add<Vector2<S>> for &'a Point2<S>[src]

type Output = Point2<S>

The resulting type after applying the + operator.

impl<S: BaseNum + AddAssign<S>> AddAssign<Vector2<S>> for Vector2<S>[src]

impl<S: BaseNum + AddAssign<S>> AddAssign<Vector2<S>> for Point2<S>[src]

impl<S: Copy> Array for Vector2<S>[src]

type Element = S

impl<S> AsMut<[S; 2]> for Vector2<S>[src]

impl<S> AsMut<(S, S)> for Vector2<S>[src]

impl<S> AsRef<[S; 2]> for Vector2<S>[src]

impl<S> AsRef<(S, S)> for Vector2<S>[src]

impl<S: Bounded> Bounded for Vector2<S>[src]

impl<S: Clone> Clone for Vector2<S>[src]

impl<S: Copy> Copy for Vector2<S>[src]

impl<S: Debug> Debug for Vector2<S>[src]

impl<'a> Div<&'a Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<f64>> for f64[src]

type Output = Vector2<f64>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<i16>> for i16[src]

type Output = Vector2<i16>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<i64>> for i64[src]

type Output = Vector2<i64>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<i8>> for i8[src]

type Output = Vector2<i8>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<isize>> for isize[src]

type Output = Vector2<isize>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<u16>> for u16[src]

type Output = Vector2<u16>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<u64>> for u64[src]

type Output = Vector2<u64>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<u8>> for u8[src]

type Output = Vector2<u8>

The resulting type after applying the / operator.

impl<'a> Div<&'a Vector2<usize>> for usize[src]

type Output = Vector2<usize>

The resulting type after applying the / operator.

impl<S: BaseNum> Div<S> for Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the / operator.

impl<'a, S: BaseNum> Div<S> for &'a Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the / operator.

impl Div<Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the / operator.

impl Div<Vector2<f64>> for f64[src]

type Output = Vector2<f64>

The resulting type after applying the / operator.

impl Div<Vector2<i16>> for i16[src]

type Output = Vector2<i16>

The resulting type after applying the / operator.

impl Div<Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the / operator.

impl Div<Vector2<i64>> for i64[src]

type Output = Vector2<i64>

The resulting type after applying the / operator.

impl Div<Vector2<i8>> for i8[src]

type Output = Vector2<i8>

The resulting type after applying the / operator.

impl Div<Vector2<isize>> for isize[src]

type Output = Vector2<isize>

The resulting type after applying the / operator.

impl Div<Vector2<u16>> for u16[src]

type Output = Vector2<u16>

The resulting type after applying the / operator.

impl Div<Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the / operator.

impl Div<Vector2<u64>> for u64[src]

type Output = Vector2<u64>

The resulting type after applying the / operator.

impl Div<Vector2<u8>> for u8[src]

type Output = Vector2<u8>

The resulting type after applying the / operator.

impl Div<Vector2<usize>> for usize[src]

type Output = Vector2<usize>

The resulting type after applying the / operator.

impl<S: BaseNum + DivAssign<S>> DivAssign<S> for Vector2<S>[src]

impl<S: BaseNum> ElementWise<S> for Vector2<S>[src]

impl<S: BaseNum> ElementWise<Vector2<S>> for Vector2<S>[src]

impl<S: Eq> Eq for Vector2<S>[src]

impl<'a, S> From<&'a [S; 2]> for &'a Vector2<S>[src]

impl<'a, S> From<&'a (S, S)> for &'a Vector2<S>[src]

impl<'a, S> From<&'a mut [S; 2]> for &'a mut Vector2<S>[src]

impl<'a, S> From<&'a mut (S, S)> for &'a mut Vector2<S>[src]

impl<S: Clone> From<[S; 2]> for Vector2<S>[src]

impl<S> From<(S, S)> for Vector2<S>[src]

impl<S: Hash> Hash for Vector2<S>[src]

impl<S> Index<Range<usize>> for Vector2<S>[src]

type Output = [S]

The returned type after indexing.

impl<S> Index<RangeFrom<usize>> for Vector2<S>[src]

type Output = [S]

The returned type after indexing.

impl<S> Index<RangeFull> for Vector2<S>[src]

type Output = [S]

The returned type after indexing.

impl<S> Index<RangeTo<usize>> for Vector2<S>[src]

type Output = [S]

The returned type after indexing.

impl<S> Index<usize> for Vector2<S>[src]

type Output = S

The returned type after indexing.

impl<S> IndexMut<Range<usize>> for Vector2<S>[src]

impl<S> IndexMut<RangeFrom<usize>> for Vector2<S>[src]

impl<S> IndexMut<RangeFull> for Vector2<S>[src]

impl<S> IndexMut<RangeTo<usize>> for Vector2<S>[src]

impl<S> IndexMut<usize> for Vector2<S>[src]

impl<S: BaseNum> InnerSpace for Vector2<S>[src]

impl<S> Into<[S; 2]> for Vector2<S>[src]

impl<S> Into<(S, S)> for Vector2<S>[src]

impl<S: BaseNum> MetricSpace for Vector2<S>[src]

type Metric = S

The metric to be returned by the distance function.

impl<'a, S: BaseFloat> Mul<&'a Vector2<S>> for Matrix2<S>[src]

type Output = Vector2<S>

The resulting type after applying the * operator.

impl<'a, 'b, S: BaseFloat> Mul<&'a Vector2<S>> for &'b Matrix2<S>[src]

type Output = Vector2<S>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<f64>> for f64[src]

type Output = Vector2<f64>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<i16>> for i16[src]

type Output = Vector2<i16>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<i64>> for i64[src]

type Output = Vector2<i64>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<i8>> for i8[src]

type Output = Vector2<i8>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<isize>> for isize[src]

type Output = Vector2<isize>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<u16>> for u16[src]

type Output = Vector2<u16>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<u64>> for u64[src]

type Output = Vector2<u64>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<u8>> for u8[src]

type Output = Vector2<u8>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Vector2<usize>> for usize[src]

type Output = Vector2<usize>

The resulting type after applying the * operator.

impl<S: BaseNum> Mul<S> for Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the * operator.

impl<'a, S: BaseNum> Mul<S> for &'a Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the * operator.

impl<S: BaseFloat> Mul<Vector2<S>> for Matrix2<S>[src]

type Output = Vector2<S>

The resulting type after applying the * operator.

impl<'a, S: BaseFloat> Mul<Vector2<S>> for &'a Matrix2<S>[src]

type Output = Vector2<S>

The resulting type after applying the * operator.

impl Mul<Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the * operator.

impl Mul<Vector2<f64>> for f64[src]

type Output = Vector2<f64>

The resulting type after applying the * operator.

impl Mul<Vector2<i16>> for i16[src]

type Output = Vector2<i16>

The resulting type after applying the * operator.

impl Mul<Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the * operator.

impl Mul<Vector2<i64>> for i64[src]

type Output = Vector2<i64>

The resulting type after applying the * operator.

impl Mul<Vector2<i8>> for i8[src]

type Output = Vector2<i8>

The resulting type after applying the * operator.

impl Mul<Vector2<isize>> for isize[src]

type Output = Vector2<isize>

The resulting type after applying the * operator.

impl Mul<Vector2<u16>> for u16[src]

type Output = Vector2<u16>

The resulting type after applying the * operator.

impl Mul<Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the * operator.

impl Mul<Vector2<u64>> for u64[src]

type Output = Vector2<u64>

The resulting type after applying the * operator.

impl Mul<Vector2<u8>> for u8[src]

type Output = Vector2<u8>

The resulting type after applying the * operator.

impl Mul<Vector2<usize>> for usize[src]

type Output = Vector2<usize>

The resulting type after applying the * operator.

impl<S: BaseNum + MulAssign<S>> MulAssign<S> for Vector2<S>[src]

impl<S: Neg<Output = S>> Neg for Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the - operator.

impl<S: PartialEq> PartialEq<Vector2<S>> for Vector2<S>[src]

impl<S: BaseFloat> RelativeEq<Vector2<S>> for Vector2<S>[src]

impl<'a> Rem<&'a Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<f64>> for f64[src]

type Output = Vector2<f64>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<i16>> for i16[src]

type Output = Vector2<i16>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<i64>> for i64[src]

type Output = Vector2<i64>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<i8>> for i8[src]

type Output = Vector2<i8>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<isize>> for isize[src]

type Output = Vector2<isize>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<u16>> for u16[src]

type Output = Vector2<u16>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<u64>> for u64[src]

type Output = Vector2<u64>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<u8>> for u8[src]

type Output = Vector2<u8>

The resulting type after applying the % operator.

impl<'a> Rem<&'a Vector2<usize>> for usize[src]

type Output = Vector2<usize>

The resulting type after applying the % operator.

impl<S: BaseNum> Rem<S> for Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the % operator.

impl<'a, S: BaseNum> Rem<S> for &'a Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the % operator.

impl Rem<Vector2<f32>> for f32[src]

type Output = Vector2<f32>

The resulting type after applying the % operator.

impl Rem<Vector2<f64>> for f64[src]

type Output = Vector2<f64>

The resulting type after applying the % operator.

impl Rem<Vector2<i16>> for i16[src]

type Output = Vector2<i16>

The resulting type after applying the % operator.

impl Rem<Vector2<i32>> for i32[src]

type Output = Vector2<i32>

The resulting type after applying the % operator.

impl Rem<Vector2<i64>> for i64[src]

type Output = Vector2<i64>

The resulting type after applying the % operator.

impl Rem<Vector2<i8>> for i8[src]

type Output = Vector2<i8>

The resulting type after applying the % operator.

impl Rem<Vector2<isize>> for isize[src]

type Output = Vector2<isize>

The resulting type after applying the % operator.

impl Rem<Vector2<u16>> for u16[src]

type Output = Vector2<u16>

The resulting type after applying the % operator.

impl Rem<Vector2<u32>> for u32[src]

type Output = Vector2<u32>

The resulting type after applying the % operator.

impl Rem<Vector2<u64>> for u64[src]

type Output = Vector2<u64>

The resulting type after applying the % operator.

impl Rem<Vector2<u8>> for u8[src]

type Output = Vector2<u8>

The resulting type after applying the % operator.

impl Rem<Vector2<usize>> for usize[src]

type Output = Vector2<usize>

The resulting type after applying the % operator.

impl<S: BaseNum + RemAssign<S>> RemAssign<S> for Vector2<S>[src]

impl<S> StructuralEq for Vector2<S>[src]

impl<S> StructuralPartialEq for Vector2<S>[src]

impl<'a, S: BaseNum> Sub<&'a Vector2<S>> for Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the - operator.

impl<'a, 'b, S: BaseNum> Sub<&'a Vector2<S>> for &'b Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the - operator.

impl<'a, S: BaseNum> Sub<&'a Vector2<S>> for Point2<S>[src]

type Output = Point2<S>

The resulting type after applying the - operator.

impl<'a, 'b, S: BaseNum> Sub<&'a Vector2<S>> for &'b Point2<S>[src]

type Output = Point2<S>

The resulting type after applying the - operator.

impl<S: BaseNum> Sub<Vector2<S>> for Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the - operator.

impl<'a, S: BaseNum> Sub<Vector2<S>> for &'a Vector2<S>[src]

type Output = Vector2<S>

The resulting type after applying the - operator.

impl<S: BaseNum> Sub<Vector2<S>> for Point2<S>[src]

type Output = Point2<S>

The resulting type after applying the - operator.

impl<'a, S: BaseNum> Sub<Vector2<S>> for &'a Point2<S>[src]

type Output = Point2<S>

The resulting type after applying the - operator.

impl<S: BaseNum + SubAssign<S>> SubAssign<Vector2<S>> for Vector2<S>[src]

impl<S: BaseNum + SubAssign<S>> SubAssign<Vector2<S>> for Point2<S>[src]

impl<'a, S: 'a + BaseNum> Sum<&'a Vector2<S>> for Vector2<S>[src]

impl<S: BaseNum> Sum<Vector2<S>> for Vector2<S>[src]

impl<S: BaseFloat> UlpsEq<Vector2<S>> for Vector2<S>[src]

impl<S: BaseNum> VectorSpace for Vector2<S>[src]

type Scalar = S

The associated scalar.

impl<S: BaseNum> Zero for Vector2<S>[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for Vector2<S> where
    S: RefUnwindSafe
[src]

impl<S> Send for Vector2<S> where
    S: Send
[src]

impl<S> Sync for Vector2<S> where
    S: Sync
[src]

impl<S> Unpin for Vector2<S> where
    S: Unpin
[src]

impl<S> UnwindSafe for Vector2<S> where
    S: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, Rhs> NumAssignOps<Rhs> for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[src]

impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
    T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.