Struct korome::Vector2 [] [src]

pub struct Vector2<T>(pub T, pub T);

Representation of a mathematical vector e.g. a position or velocity

Methods

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

fn unit_vector(direction: T) -> Self

Creates a new unit vector in a specific direction

fn normalise(self) -> Self

Normalises the vector

fn length(self) -> T

Returns the magnitude or the length of the vector

fn direction(self) -> T

Returns direction the vector is pointing

fn direction_to(self, other: Self) -> T

Returns direction towards another vector

fn distance_to(self, other: Self) -> T

Returns the distance betweens two vectors

fn is_nan(&self) -> bool

Returns true if either component is NaN.

fn is_infinite(&self) -> bool

Returns true if either component is positive or negative infinity.

fn is_finite(&self) -> bool

Returns true if either component is neither infinite nor NaN.

fn is_normal(&self) -> bool

Returns true if either component is neither zero, inifnite, subnormal nor NaN.

impl<T> Vector2<T>
[src]

fn dot(self, other: Self) -> T::Output::Output where T: Mul, T::Output: Add

Returns the dot product of two vectors

Trait Implementations

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

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

fn eq(&self, __arg_0: &Vector2<T>) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Vector2<T>) -> bool

This method tests for !=.

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

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

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

fn clone(&self) -> Vector2<T>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

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

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

type Output = Vector2<T::Output>

The resulting type after applying the + operator

fn add(self, rhs: Self) -> Self::Output

The method for the + operator

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

type Output = Vector2<T::Output>

The resulting type after applying the - operator

fn sub(self, rhs: Self) -> Self::Output

The method for the - operator

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

fn add_assign(&mut self, rhs: Self)

The method for the += operator

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

fn sub_assign(&mut self, rhs: Self)

The method for the -= operator

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

fn mul_assign(&mut self, rhs: T)

The method for the *= operator

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

fn div_assign(&mut self, rhs: T)

The method for the /= operator

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

type Output = Vector2<T::Output>

The resulting type after applying the * operator

fn mul(self, rhs: T) -> Self::Output

The method for the * operator

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

type Output = Vector2<T::Output>

The resulting type after applying the / operator

fn div(self, rhs: T) -> Self::Output

The method for the / operator

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

type Output = Vector2<T::Output>

The resulting type after applying the - operator

fn neg(self) -> Self::Output

The method for the unary - operator

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

fn into(self) -> [T; 2]

Performs the conversion.

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

fn from(array: [T; 2]) -> Self

Performs the conversion.

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

fn into(self) -> (T, T)

Performs the conversion.

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

fn from(tuple: (T, T)) -> Self

Performs the conversion.