[][src]Struct rgx::math::algebra::Vector2

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

2D vector.

Fields

x: Sy: S

Methods

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

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

pub fn normalize(self) -> Self where
    S: One + Float + Div + Mul
[src]

Returns a vector with the same direction and a given magnitude.

pub fn magnitude(self) -> S where
    S: Float
[src]

The distance from the tail to the tip of the vector.

pub fn dot(a: Self, b: Self) -> <S as Add>::Output where
    S: Mul<Output = S> + Add
[src]

Dot product of two vectors.

use rgx::math::*;

let v1 = Vector4::new(1, 3, -5, 4);
let v2 = Vector4::new(4, -2, -1, 3);

assert_eq!(v1 * v2, 15);

pub fn distance(self, other: Self) -> S where
    S: Float
[src]

Distance between two vectors.

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

Extend vector to three dimensions.

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

Trait Implementations

impl<S> Add<Vector2<S>> for Vector2<S> where
    S: Add<Output = S> + Copy
[src]

type Output = Self

The resulting type after applying the + operator.

impl<S> Add<Vector2<S>> for Point2<S> where
    S: Add<Output = S> + Copy
[src]

type Output = Self

The resulting type after applying the + operator.

impl<T> Add<Vector2<T>> for Rect<T> where
    T: Add<Output = T> + Copy
[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<Vector2<f32>> for Line[src]

type Output = Self

The resulting type after applying the + operator.

impl<T> AddAssign<Vector2<T>> for Rect<T> where
    T: AddAssign<T> + Copy
[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<S: Eq> Eq for Vector2<S>[src]

impl<T: Copy> From<[T; 2]> for Vector2<T>[src]

impl<S> From<Point2<S>> for Vector2<S>[src]

impl<S> From<Vector2<S>> for Point2<S>[src]

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

impl<S> Mul<S> for Vector2<S> where
    S: Mul<Output = S> + Copy
[src]

type Output = Self

The resulting type after applying the * operator.

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

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

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

impl<S> Sub<Vector2<S>> for Vector2<S> where
    S: Sub<Output = S> + Copy
[src]

type Output = Self

The resulting type after applying the - operator.

impl<S> Sub<Vector2<S>> for Point2<S> where
    S: Sub<Output = S> + Copy
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T> Sub<Vector2<T>> for Rect<T> where
    T: Sub<Output = T> + Copy
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T> SubAssign<Vector2<T>> for Rect<T> where
    T: SubAssign<T> + Copy
[src]

impl<S: Zero + Copy + PartialEq> Zero for Vector2<S>[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for Vector2<S> where
    S: RefUnwindSafe

impl<S> Send for Vector2<S> where
    S: Send

impl<S> Sync for Vector2<S> where
    S: Sync

impl<S> Unpin for Vector2<S> where
    S: Unpin

impl<S> UnwindSafe for Vector2<S> where
    S: UnwindSafe

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> 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.