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]
pub fn unit_vector(direction: T) -> Self
[src]
Creates a new unit vector in a specific direction
pub fn normalise(self) -> Self
[src]
Normalises the vector
pub fn length(self) -> T
[src]
Returns the magnitude/length of the vector
pub fn length_squared(self) -> T
[src]
Returns the magnitude/length of the vector squared
pub fn direction(self) -> T
[src]
Returns direction the vector is pointing
pub fn direction_to(self, other: Self) -> T
[src]
Returns direction towards another vector
pub fn distance_to(self, other: Self) -> T
[src]
Returns the distance betweens two vectors
pub fn distance_to_squared(self, other: Self) -> T
[src]
Returns the distance betweens two vectors
pub fn is_any_nan(&self) -> bool
[src]
Returns true
if either component is NaN
.
pub fn is_any_infinite(&self) -> bool
[src]
Returns true
if either component is positive or negative infinity.
pub fn is_all_finite(&self) -> bool
[src]
Returns true
if both components are neither infinite nor NaN
.
pub fn is_all_normal(&self) -> bool
[src]
Returns true
if both components are neither zero, infinite, subnormal nor NaN
.
impl<T> Vector2<T>
[src]
pub fn normal(self) -> Self where
T: Neg<Output = T>,
[src]
T: Neg<Output = T>,
Returns the normal vector (aka. hat vector) of this vector i.e. a perpendicular vector
Not to be confused with normalise
which returns a unit vector
Defined as (-y, x)
pub fn dot(self, other: Self) -> <<T as Mul>::Output as Add>::Output where
T: Mul,
<T as Mul>::Output: Add,
[src]
T: Mul,
<T as Mul>::Output: Add,
Returns the dot product of two vectors
pub fn det(self, other: Self) -> <<T as Mul>::Output as Sub>::Output where
T: Mul,
<T as Mul>::Output: Sub,
[src]
T: Mul,
<T as Mul>::Output: Sub,
Returns the determinant 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>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Vector2<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: PartialEq> PartialEq for Vector2<T>
[src]
fn eq(&self, __arg_0: &Vector2<T>) -> bool
[src]
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
[src]
This method tests for !=
.
impl<T: Eq> Eq for Vector2<T>
[src]
impl<T: Default> Default for Vector2<T>
[src]
impl Mul<Vector2<f32>> for f32
[src]
type Output = Vector2<f32>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vector2<f32>) -> Vector2<f32>
[src]
Performs the *
operation.
impl Div<Vector2<f32>> for f32
[src]
type Output = Vector2<f32>
The resulting type after applying the /
operator.
fn div(self, rhs: Vector2<f32>) -> Vector2<f32>
[src]
Performs the /
operation.
impl Mul<Vector2<f64>> for f64
[src]
type Output = Vector2<f64>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vector2<f64>) -> Vector2<f64>
[src]
Performs the *
operation.
impl Div<Vector2<f64>> for f64
[src]
type Output = Vector2<f64>
The resulting type after applying the /
operator.
fn div(self, rhs: Vector2<f64>) -> Vector2<f64>
[src]
Performs the /
operation.
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
[src]
Performs the +
operation.
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
[src]
Performs the -
operation.
impl<T: AddAssign> AddAssign for Vector2<T>
[src]
fn add_assign(&mut self, rhs: Self)
[src]
Performs the +=
operation.
impl<T: SubAssign> SubAssign for Vector2<T>
[src]
fn sub_assign(&mut self, rhs: Self)
[src]
Performs the -=
operation.
impl<T: MulAssign + Copy> MulAssign<T> for Vector2<T>
[src]
fn mul_assign(&mut self, rhs: T)
[src]
Performs the *=
operation.
impl<T: DivAssign + Copy> DivAssign<T> for Vector2<T>
[src]
fn div_assign(&mut self, rhs: T)
[src]
Performs the /=
operation.
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
[src]
Performs the *
operation.
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
[src]
Performs the /
operation.
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
[src]
Performs the unary -
operation.