Trait vector2math::Vector2
source · pub trait Vector2: Copy {
type Scalar: Scalar;
Show 28 methods
// Required methods
fn x(&self) -> Self::Scalar;
fn y(&self) -> Self::Scalar;
fn new(x: Self::Scalar, y: Self::Scalar) -> Self;
// Provided methods
fn set_x(&mut self, x: Self::Scalar) { ... }
fn set_y(&mut self, y: Self::Scalar) { ... }
fn with_x(self, x: Self::Scalar) -> Self { ... }
fn with_y(self, y: Self::Scalar) -> Self { ... }
fn square(s: Self::Scalar) -> Self { ... }
fn map_into<V>(self) -> V
where V: Vector2,
V::Scalar: From<Self::Scalar> { ... }
fn map_vec2(self) -> [Self::Scalar; 2] { ... }
fn map_dims<F>(self, f: F) -> Self
where F: FnMut(Self::Scalar) -> Self::Scalar { ... }
fn map_with<V, F>(self, f: F) -> V
where V: Vector2,
F: FnMut(Self::Scalar) -> V::Scalar { ... }
fn neg(self) -> Self
where Self::Scalar: Neg<Output = Self::Scalar> { ... }
fn add(self, other: Self) -> Self { ... }
fn sub(self, other: Self) -> Self { ... }
fn mul(self, by: Self::Scalar) -> Self { ... }
fn mul2(self, other: Self) -> Self { ... }
fn div(self, by: Self::Scalar) -> Self { ... }
fn div2(self, other: Self) -> Self { ... }
fn add_assign(&mut self, other: Self) { ... }
fn sub_assign(&mut self, other: Self) { ... }
fn mul_assign(&mut self, by: Self::Scalar) { ... }
fn mul2_assign(&mut self, other: Self) { ... }
fn div_assign(&mut self, by: Self::Scalar) { ... }
fn div2_assign(&mut self, other: Self) { ... }
fn max_dim(self) -> Self::Scalar { ... }
fn min_dim(self) -> Self::Scalar { ... }
fn dot(self, other: Self) -> Self::Scalar { ... }
}
Expand description
Trait for manipulating 2D vectors
Required Associated Types§
Required Methods§
Provided Methods§
sourcefn map_into<V>(self) -> Vwhere
V: Vector2,
V::Scalar: From<Self::Scalar>,
fn map_into<V>(self) -> Vwhere V: Vector2, V::Scalar: From<Self::Scalar>,
Map this vector to a vector of another type
sourcefn map_vec2(self) -> [Self::Scalar; 2]
fn map_vec2(self) -> [Self::Scalar; 2]
Map this vector to a [Self::Scalar; 2]
This is an alias for Vector2::map_into::<[Self::Scalar; 2]>()
that is more concise
sourcefn map_dims<F>(self, f: F) -> Selfwhere
F: FnMut(Self::Scalar) -> Self::Scalar,
fn map_dims<F>(self, f: F) -> Selfwhere F: FnMut(Self::Scalar) -> Self::Scalar,
Map the individual components of this vector
sourcefn map_with<V, F>(self, f: F) -> Vwhere
V: Vector2,
F: FnMut(Self::Scalar) -> V::Scalar,
fn map_with<V, F>(self, f: F) -> Vwhere V: Vector2, F: FnMut(Self::Scalar) -> V::Scalar,
Map this vector to a vector of another type using a function
sourcefn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Add another vector into this one
sourcefn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Subtract another vector into this one
sourcefn mul_assign(&mut self, by: Self::Scalar)
fn mul_assign(&mut self, by: Self::Scalar)
Multiply a scalar into this vector
sourcefn mul2_assign(&mut self, other: Self)
fn mul2_assign(&mut self, other: Self)
Multiply another vector component-wise into this one
sourcefn div_assign(&mut self, by: Self::Scalar)
fn div_assign(&mut self, by: Self::Scalar)
Divide a scalar into this vector
sourcefn div2_assign(&mut self, other: Self)
fn div2_assign(&mut self, other: Self)
Divide another vector component-wise into this one