[][src]Trait gridly::prelude::VectorLike

pub trait VectorLike: Sized {
    fn rows(&self) -> Rows;
fn columns(&self) -> Columns;
fn as_vector(&self) -> Vector; fn manhattan_length(&self) -> isize { ... }
fn checked_manhattan_length(&self) -> Option<isize> { ... }
fn clockwise(&self) -> Vector { ... }
fn anticlockwise(&self) -> Vector { ... }
fn reverse(&self) -> Vector { ... }
fn get_component<T: Component>(&self) -> T { ... }
fn transpose(&self) -> Vector { ... }
fn direction(&self) -> Option<Direction> { ... } }

Required methods

fn rows(&self) -> Rows

fn columns(&self) -> Columns

fn as_vector(&self) -> Vector

Loading content...

Provided methods

fn manhattan_length(&self) -> isize

Return the manhattan length of the vector. The manhattan length of a vector is the sum of the absolute values of its components.

fn checked_manhattan_length(&self) -> Option<isize>

Return the manhatten length of the vector, or None if there are any overflows.

fn clockwise(&self) -> Vector

Return a new vector, rotated 90 degrees clockwise.

fn anticlockwise(&self) -> Vector

Return a new vector, rotated 90 degrees counterclockwise.

fn reverse(&self) -> Vector

fn get_component<T: Component>(&self) -> T

Generically get either the Rows or Columns of a vector

fn transpose(&self) -> Vector

Swap the rows and columns of this Vector

fn direction(&self) -> Option<Direction>

If the vector is pointing in an orthogonal direction, return that direction

Loading content...

Implementations on Foreign Types

impl VectorLike for (Rows, Columns)[src]

impl VectorLike for (Columns, Rows)[src]

impl VectorLike for (isize, isize)[src]

impl<'_, T: VectorLike> VectorLike for &'_ T[src]

Loading content...

Implementors

impl VectorLike for Direction[src]

A Direction acts like a unit vector in the given direction. This allows it to be used in things like Vector arithmetic.

Example:

use gridly::prelude::*;

assert_eq!(Vector::new(1, 1) + Up, Vector::new(0, 1));
assert_eq!(Location::new(3, 4) - Left, Location::new(3, 5));

impl VectorLike for Columns[src]

A Rows or a Columns value can be treated as a Vector where the converse component is 0.

impl VectorLike for Rows[src]

A Rows or a Columns value can be treated as a Vector where the converse component is 0.

impl VectorLike for Vector[src]

Loading content...