[−][src]Struct gridly::vector::Vector
A measurement of distance between two [Location]s
A vector is the measurement of distance between two [Location]s. It
supports arithmetic operations with itself, as well as anything which can
be converted into a Vector. Currently, Rows, Columns, and Direction
all have this property, as well as a tuple of (Into
Fields
rows: Rowscolumns: ColumnsMethods
impl Vector[src]
pub fn new(rows: impl Into<Rows>, columns: impl Into<Columns>) -> Self[src]
Create a new Vector
pub fn zero() -> Vector[src]
Create a zero Vector
pub fn upward(size: isize) -> Vector[src]
Create an upward pointing vector of the given size
pub fn downward(size: isize) -> Vector[src]
Create a downward pointing vector of the given size
pub fn leftward(size: isize) -> Vector[src]
Create a leftward pointing vector of the given size
pub fn rightward(size: isize) -> Vector[src]
Create a rightward pointing vector of the given size
pub fn in_direction(direction: Direction, length: isize) -> Vector[src]
Create a vector of the given size in the given direction
pub fn manhattan_length(&self) -> isize[src]
Return the Manhattan length of the vector
The Manhattan length of a vector is the sum of the absolute values of its components
pub fn clockwise(&self) -> Vector[src]
Return a new vector, rotated 90 degrees clockwise.
pub fn counterclockwise(&self) -> Vector[src]
Return a new vector, rotated 90 degrees counterclockwise.
pub fn reverse(&self) -> Vector[src]
pub fn get_component<T: Component>(&self) -> T[src]
Generically get either the Rows or Columns of a vector
pub fn transpose(&self) -> Vector[src]
Swap the rows and columns of this Vector
Trait Implementations
impl Copy for Vector[src]
impl PartialEq<Vector> for Vector[src]
impl Eq for Vector[src]
impl Clone for Vector[src]
fn clone(&self) -> Vector[src]
default fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Default for Vector[src]
impl<C: Component> From<C> for Vector[src]
Convert a Rows or Columns into an equivelent Vector
impl From<Direction> for Vector[src]
Convert a Direction into a unit vector pointing in that direction
impl<R: Into<Rows>, C: Into<Columns>> From<(R, C)> for Vector[src]
impl Hash for Vector[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
default fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl<T: Into<Vector>> Add<T> for Vector[src]
type Output = Vector
The resulting type after applying the + operator.
fn add(self, rhs: T) -> Vector[src]
impl<T: Into<Vector>> Sub<T> for Vector[src]
type Output = Vector
The resulting type after applying the - operator.
fn sub(self, rhs: T) -> Vector[src]
impl<T: Copy> Mul<T> for Vector where
isize: Mul<T, Output = isize>, [src]
isize: Mul<T, Output = isize>,
Multiply a vector's components by a constant factor
type Output = Vector
The resulting type after applying the * operator.
fn mul(self, factor: T) -> Vector[src]
impl Neg for Vector[src]
impl<T: Into<Vector>> AddAssign<T> for Vector[src]
fn add_assign(&mut self, rhs: T)[src]
impl<T: Into<Vector>> SubAssign<T> for Vector[src]
fn sub_assign(&mut self, rhs: T)[src]
impl<T: Copy> MulAssign<T> for Vector where
isize: MulAssign<T>, [src]
isize: MulAssign<T>,
Multiply a vector's components by a constant factor in-place
fn mul_assign(&mut self, factor: T)[src]
impl Debug for Vector[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,