[−][src]Trait vector2math::Vector2
Trait for manipulating 2D vectors
Associated Types
Loading content...Required methods
fn x(self) -> Self::Scalar
Get the x component
fn y(self) -> Self::Scalar
Get the y component
fn new(x: Self::Scalar, y: Self::Scalar) -> Self
Create a new vector from an x and y component
Provided methods
fn set_x(&mut self, x: Self::Scalar)
Set the x component
fn set_y(&mut self, y: Self::Scalar)
Set the y component
fn square(s: Self::Scalar) -> Self
Create a new square vector
fn map<V>(self) -> V where
V: Vector2,
V::Scalar: From<Self::Scalar>,
V: Vector2,
V::Scalar: From<Self::Scalar>,
Map this vector to a vector of another type
fn map_f32(self) -> [f32; 2] where
f32: From<Self::Scalar>,
f32: From<Self::Scalar>,
Map this vector to a [f32;2]
This is an alias for Vector2::map::<[f32;2]>() that is more concise
fn map_f64(self) -> [f64; 2] where
f64: From<Self::Scalar>,
f64: From<Self::Scalar>,
Map this vector to a [f64;2]
This is an alias for Vector2::map::<[f64;2]>() that is more concise
fn map_with<V, F>(self, f: F) -> V where
V: Vector2,
F: FnMut(Self::Scalar) -> V::Scalar,
V: Vector2,
F: FnMut(Self::Scalar) -> V::Scalar,
Map this vector to a vector of another type using a function
fn neg(self) -> Self where
Self::Scalar: Neg<Output = Self::Scalar>,
Self::Scalar: Neg<Output = Self::Scalar>,
Negate the vector
fn add<V>(self, other: V) -> Self where
V: Vector2<Scalar = Self::Scalar>,
V: Vector2<Scalar = Self::Scalar>,
Add the vector to another
fn sub<V>(self, other: V) -> Self where
V: Vector2<Scalar = Self::Scalar>,
V: Vector2<Scalar = Self::Scalar>,
Subtract another vector from this one
fn mul(self, by: Self::Scalar) -> Self
Multiply this vector by a scalar
fn mul2<V>(self, other: V) -> Self where
V: Vector2<Scalar = Self::Scalar>,
V: Vector2<Scalar = Self::Scalar>,
Multiply this vector component-wise by another
fn div(self, by: Self::Scalar) -> Self
Divide this vector by a scalar
fn div2<V>(self, other: V) -> Self where
V: Vector2<Scalar = Self::Scalar>,
V: Vector2<Scalar = Self::Scalar>,
Divide this vector component-wise by another
fn max_dim(self) -> Self::Scalar
Get the value of the dimension with the higher magnitude
fn min_dim(self) -> Self::Scalar
Get the value of the dimension with the lower magnitude
fn dot<V>(self, other: V) -> Self::Scalar where
V: Vector2<Scalar = Self::Scalar>,
V: Vector2<Scalar = Self::Scalar>,
Get the dot product of this vector and another