Trait vector2math::Vector2

source ·
pub trait Vector2: Copy {
    type Scalar: Scalar;

Show 28 methods fn x(&self) -> Self::Scalar; fn y(&self) -> Self::Scalar; fn new(x: Self::Scalar, y: Self::Scalar) -> Self; 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§

The scalar type

Required Methods§

Get the x component

Get the y component

Create a new vector from an x and y component

Provided Methods§

Set the x component

Set the y component

Get this vector with a different x component

Get this vector with a different y component

Create a new square vector

Map this vector to a vector of another type

Map this vector to a [Self::Scalar; 2]

This is an alias for Vector2::map_into::<[Self::Scalar; 2]>() that is more concise

Map the individual components of this vector

Map this vector to a vector of another type using a function

Negate the vector

Add this vector to another

Subtract another vector from this one

Multiply this vector by a scalar

Multiply this vector component-wise by another

Divide this vector by a scalar

Divide this vector component-wise by another

Add another vector into this one

Subtract another vector into this one

Multiply a scalar into this vector

Multiply another vector component-wise into this one

Divide a scalar into this vector

Divide another vector component-wise into this one

Get the value of the dimension with the higher magnitude

Get the value of the dimension with the lower magnitude

Get the dot product of this vector and another

Implementors§