[][src]Type Definition semeion::space::Location

type Location = Point<i32>;

Represents the location of an entity within the environment as pair of coordinate that identify the environment grid tile.

Implementations

impl Location[src]

pub const fn origin() -> Self[src]

Gets the origin coordinates in (0, 0).

pub fn distance(self, other: Self, representation: Distance) -> usize[src]

Gets the distance between self and the given location according to a specific representation.

pub fn to_pixel_coords(self, side: f32) -> Coordinate[src]

Converts the Point into a point expressed as pixel coordinates, according to the length of each grid square side.

pub fn one_dimensional(self, dimension: impl Into<Dimension>) -> usize[src]

Maps a 2-dimensional coordinate in a Torus of the given dimension, to a 1-dimensional index.

pub fn from_one_dimensional(
    index: usize,
    dimension: impl Into<Dimension>
) -> Self
[src]

Maps a 1-dimensional index to a 2-dimensional Location in a Torus of the given dimension.

pub fn translate(
    &mut self,
    offset: impl Into<Offset>,
    dimension: impl Into<Dimension>
) -> &mut Self
[src]

Translates the Location coordinates by the given Offset, while keeping the final Location within a Torus with the given dimension.

Returns a reference to the final location.

pub fn translate_towards(
    &mut self,
    destination: impl Into<Self>,
    dimension: impl Into<Dimension>
) -> &mut Self
[src]

Translates the Location coordinates towards the given destination, offsetting the current values by a single unit (both abscissa and ordinate), while keeping the final Location within a Torus with the given dimension.

Between all the possible paths to the final destination, the shortest one is chosen. Returns a reference to the final location.

Trait Implementations

impl From<(i32, i32)> for Location[src]