pub trait Vector2: Sized {
type Scalar: Scalar;
Show 14 methods
fn x(&self) -> Self::Scalar;
fn y(&self) -> Self::Scalar;
fn new(x: Self::Scalar, y: Self::Scalar) -> Self;
fn map<V>(&self) -> V
where
V: Vector2,
V::Scalar: From<Self::Scalar>,
{ ... }
fn neg(self) -> Self { ... }
fn add<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self { ... }
fn sub<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self { ... }
fn mul(self, by: Self::Scalar) -> Self { ... }
fn mul2<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self { ... }
fn div(self, by: Self::Scalar) -> Self { ... }
fn div2<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self { ... }
fn dist<V: Vector2<Scalar = Self::Scalar>>(self, to: V) -> Self::Scalar { ... }
fn mag(self) -> Self::Scalar { ... }
fn rotate_about<V: Vector2<Scalar = Self::Scalar> + Clone>(
self,
pivot: V,
radians: Self::Scalar
) -> Self { ... }
}
Expand description
Trait for manipulating 2D vectors
Required Associated Types
Required Methods
Provided Methods
sourcefn map<V>(&self) -> Vwhere
V: Vector2,
V::Scalar: From<Self::Scalar>,
fn map<V>(&self) -> Vwhere
V: Vector2,
V::Scalar: From<Self::Scalar>,
Map this vector to a vector of another type
sourcefn sub<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self
fn sub<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self
Subtract another vector from this one
sourcefn mul2<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self
fn mul2<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self
Multiply this vector component-wise by another
sourcefn div2<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self
fn div2<V: Vector2<Scalar = Self::Scalar>>(self, other: V) -> Self
Divide this vector component-wise by another