Struct speedy2d::dimen::Vector2[][src]

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

A vector containing two numeric values. This may represent a size or position.

Fields

x: T

The horizontal component of the vector.

y: T

The vertical component of the vector.

Implementations

impl<T> Vector2<T>[src]

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

Instantiates a new Vector2 from the specified horizontal and vertical components.

impl<T: PrimitiveZero> Vector2<T>[src]

pub const ZERO: Vector2<T>[src]

A constant representing a vector of zero magnitude. Each component is set to zero.

impl Vector2<f32>[src]

#[must_use]pub fn magnitude_squared(&self) -> f32[src]

Returns the magnitude of the vector, squared.

#[must_use]pub fn magnitude(&self) -> f32[src]

Returns the magnitude of the vector.

#[must_use]pub fn normalize(&self) -> Option<Vector2<f32>>[src]

Normalizes the vector so that the magnitude is 1.0. If the current magnitude of the vector is 0.0, then None is returned to avoid a division by zero.

impl<T: Neg<Output = T> + Copy> Vector2<T>[src]

#[must_use]pub fn rotate_90_degrees_clockwise(&self) -> Vector2<T>[src]

Rotates the vector by 90 degrees in the clockwise direction.

#[must_use]pub fn rotate_90_degrees_anticlockwise(&self) -> Vector2<T>[src]

Rotates the vector by 90 degrees in the anti-clockwise direction.

impl<T: AsPrimitive<f32>> Vector2<T>[src]

#[must_use]pub fn into_f32(self) -> Vector2<f32>[src]

Returns a new vector with each element cast to f32, using the as operator.

impl<T: AsPrimitive<i32>> Vector2<T>[src]

#[must_use]pub fn into_i32(self) -> Vector2<i32>[src]

Returns a new vector with each element cast to i32, using the as operator.

impl<T: TryInto<i32>> Vector2<T>[src]

pub fn try_into_i32(self) -> Result<Vector2<i32>, T::Error>[src]

Attempts to convert each element of this vector to an i32, returning an error if this fails.

Trait Implementations

impl<T: Copy + Add<Output = T>> Add<&'_ Vector2<T>> for Vector2<T>[src]

type Output = Vector2<T>

The resulting type after applying the + operator.

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

type Output = Vector2<T>

The resulting type after applying the + operator.

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

type Output = Vector2<T>

The resulting type after applying the + operator.

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

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

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

impl<T: Copy + Div<Output = T>> Div<T> for &Vector2<T>[src]

type Output = Vector2<T>

The resulting type after applying the / operator.

impl<T: Copy + Div<Output = T>> Div<T> for Vector2<T>[src]

type Output = Vector2<T>

The resulting type after applying the / operator.

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

impl<T> From<(T, T)> for Vector2<T> where
    T: Copy
[src]

impl From<PhysicalSize<u32>> for Vector2<u32>[src]

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

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

impl<T: Copy + Mul<Output = T>> Mul<T> for &Vector2<T>[src]

type Output = Vector2<T>

The resulting type after applying the * operator.

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

type Output = Vector2<T>

The resulting type after applying the * operator.

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

impl<T: RoundFloat> RoundFloat for Vector2<T>[src]

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

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

impl<T: Copy + Sub<Output = T>> Sub<&'_ Vector2<T>> for Vector2<T>[src]

type Output = Vector2<T>

The resulting type after applying the - operator.

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

type Output = Vector2<T>

The resulting type after applying the - operator.

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

type Output = Vector2<T>

The resulting type after applying the - operator.

Auto Trait Implementations

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

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

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

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

impl<T> UnwindSafe for Vector2<T> where
    T: 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.