[][src]Struct gridly::vector::Vector

pub struct Vector {
    pub rows: Rows,
    pub columns: Columns,
}

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, Into).

Fields

rows: Rowscolumns: Columns

Methods

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 Clone for Vector[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for Vector[src]

impl Copy for Vector[src]

impl PartialEq<Vector> for Vector[src]

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 Debug for Vector[src]

impl Hash for Vector[src]

default fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

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.

impl<T: Into<Vector>> Sub<T> for Vector[src]

type Output = Vector

The resulting type after applying the - operator.

impl<T: Copy> Mul<T> for Vector where
    isize: Mul<T, Output = isize>, 
[src]

Multiply a vector's components by a constant factor

type Output = Vector

The resulting type after applying the * operator.

impl Neg for Vector[src]

type Output = Vector

The resulting type after applying the - operator.

impl<T: Into<Vector>> AddAssign<T> for Vector[src]

impl<T: Into<Vector>> SubAssign<T> for Vector[src]

impl<T: Copy> MulAssign<T> for Vector where
    isize: MulAssign<T>, 
[src]

Multiply a vector's components by a constant factor in-place

Auto Trait Implementations

impl Send for Vector

impl Sync for Vector

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]