GamesEngine.Grid.Coordinate (games_engine v0.2.0)
Coordinate Component - represents a square within a grid
Currently also provides functions for handling coordinate transformations.
Summary
Functions
Converts a coordinate's linear index to row/col subscript
Creates a new %Coordinate{}
struct
Converts a coordinate's row/col subscript into a linear index
Types
Functions
Link to this function
ind2sub(ind, rows, cols)
@spec ind2sub(non_neg_integer(), non_neg_integer(), non_neg_integer()) :: {non_neg_integer(), non_neg_integer()}
Converts a coordinate's linear index to row/col subscript
0 | 3 | 6 | 0,0 | 0,1 | 0,2 | |
1 | 4 | 7 | --> | 1,0 | 1,1 | 1,2 |
2 | 5 | 8 | 2,0 | 2,1 | 2,2 |
Link to this function
new(arg)
@spec new({non_neg_integer(), non_neg_integer()}) :: t()
Creates a new %Coordinate{}
struct
Link to this function
new(arg, attributes)
@spec new( {non_neg_integer(), non_neg_integer()}, map() ) :: t()
Link to this function
sub2ind(arg, rows, cols)
Converts a coordinate's row/col subscript into a linear index
0,0 | 0,1 | 0,2 | 0 | 3 | 6 | |
1,0 | 1,1 | 1,2 | --> | 1 | 4 | 7 |
2,0 | 2,1 | 2,2 | 2 | 5 | 8 |