20 template<
typename TCoordinate>
27 template<
typename TCoordinate>
54template<
typename TCoordinate>
60 TCoordinate x = b.first - a.first;
61 TCoordinate y = b.second - a.second;
63 if (x < 0 && y == 0)
return direction_type::north;
64 else if (x > 0 && y == 0)
return direction_type::south;
65 else if (x == 0 && y < 0)
return direction_type::west;
66 else if (x == 0 && y > 0)
return direction_type::east;
67 else if (x < 0 && y < 0)
return direction_type::north_west;
68 else if (x > 0 && y < 0)
return direction_type::south_west;
69 else if (x < 0 && y > 0)
return direction_type::north_east;
70 else if (x > 0 && y > 0)
return direction_type::south_east;
71 else return direction_type::none;
76template<
typename TCoordinate>
83 case direction_type::north:
return node_type(-1, 0);
84 case direction_type::south:
return node_type(1, 0);
85 case direction_type::west:
return node_type(0, -1);
86 case direction_type::east:
return node_type(0, 1);
87 case direction_type::north_west:
return node_type(-1, -1);
88 case direction_type::south_west:
return node_type(1, -1);
89 case direction_type::north_east:
return node_type(-1, 1);
90 case direction_type::south_east:
return node_type(1, 1);
91 default:
return node_type(0, 0);
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Definition: GridFunction.hpp:16
static bool sqaureGridDirectionIsDiagonal(grid::SquareGridDirections direction)
Definition: GridFunction.cpp:40
static ext::pair< TCoordinate, TCoordinate > squareGridDirectionVector(grid::SquareGridDirections direction)
Definition: GridFunction.hpp:78
static ext::set< grid::SquareGridDirections > squareGridDirectionDecompose(grid::SquareGridDirections direction)
Definition: GridFunction.cpp:15
static bool sqaureGridDirectionIsCardinal(grid::SquareGridDirections direction)
Definition: GridFunction.cpp:50
static grid::SquareGridDirections squareGridDirection(const ext::pair< TCoordinate, TCoordinate > &a, const ext::pair< TCoordinate, TCoordinate > &b)
Definition: GridFunction.hpp:56
Definition: GridDirection.hpp:12
SquareGridDirections
Definition: GridDirection.hpp:16