Struct simple_vector2d::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/length of the vector
fn length_squared(self) -> T
Returns the magnitude/length of the vector squared
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 distance_to_squared(self, other: Self) -> T
Returns the distance betweens two vectors
fn is_any_nan(&self) -> bool
Returns true
if either component is NaN
.
fn is_any_infinite(&self) -> bool
Returns true
if either component is positive or negative infinity.
fn is_all_finite(&self) -> bool
Returns true
if both components are neither infinite nor NaN
.
fn is_all_normal(&self) -> bool
Returns true
if both components are neither zero, infinite, subnormal nor NaN
.
impl<T> Vector2<T>
[src]
fn dot(self, other: Self) -> <<T as Mul>::Output as Add>::Output where
T: Mul,
<T as Mul>::Output: Add,
T: Mul,
<T as Mul>::Output: Add,
Returns the dot product of two vectors
Trait Implementations
impl<T: Copy> Copy for Vector2<T>
[src]
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: Debug> Debug 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: Eq> Eq for Vector2<T>
[src]
impl<T: Default> Default 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