#include <PointFunctions.hxx>
|
static std::vector< Point > | getLine (Point isoCoordinatesStart, Point isoCoordinatesEnd) |
| Creates a line between two points using the Bresenham Line algorithm. More...
|
|
static std::vector< Point > | getStraightLine (const Point &isoCoordinatesStart, const Point &isoCoordinatesEnd) |
| Gets all nodes in a straight line from start and end point. More...
|
|
static std::vector< Point > | getArea (const Point &isoCoordinatesStart, const Point &isoCoordinatesEnd) |
| Gets all nodes in a rectangular area between start and end point. More...
|
|
static std::vector< Point > | getNeighbors (const Point &isoCoordinates, const bool includeCentralNode, int distance=1) |
| Get all neighboring coordinates from provided map node isocoordinate. More...
|
|
static NeighborNodesPosition | getNeighborPositionToOrigin (const Point &neighboringPoint, const Point &originPoint) |
| Get the position of the neighboring node to the originpoint (center of the neighborgroup). More...
|
|
Definition at line 12 of file PointFunctions.hxx.
◆ getArea()
std::vector< Point > PointFunctions::getArea |
( |
const Point & |
isoCoordinatesStart, |
|
|
const Point & |
isoCoordinatesEnd |
|
) |
| |
|
static |
Gets all nodes in a rectangular area between start and end point.
- Parameters
-
isoCoordinatesStart | start coordinates |
isoCoordinatesEnd | end coordinates |
- Returns
- std::vector<Point>() containing coordinates for each tile between start and end coordinates, including start and end
Definition at line 156 of file PointFunctions.cxx.
158 std::vector<Point> rectangle;
161 std::tie(startRect.x, endRect.x) = std::minmax(isoCoordinatesStart.
x, isoCoordinatesEnd.
x);
162 std::tie(startRect.y, endRect.y) = std::minmax(isoCoordinatesStart.
y, isoCoordinatesEnd.
y);
164 for (
int x = startRect.x; x <= endRect.x; x++)
166 for (
int y = startRect.y; y <= endRect.y; y++)
168 rectangle.push_back(
Point{x, y});
◆ getLine()
std::vector< Point > PointFunctions::getLine |
( |
Point |
isoCoordinatesStart, |
|
|
Point |
isoCoordinatesEnd |
|
) |
| |
|
static |
Creates a line between two points using the Bresenham Line algorithm.
- Parameters
-
isoCoordinatesStart | start coordinates |
isoCoordinatesEnd | end coordinates |
- Returns
- std::vector<Point>() containing coordinates for each tile between start and end coordinates, including start and end
Definition at line 10 of file PointFunctions.cxx.
12 std::vector<Point> line;
13 int x0 = isoCoordinatesStart.
x;
14 int x1 = isoCoordinatesEnd.
x;
15 int y0 = isoCoordinatesStart.
y;
16 int y1 = isoCoordinatesEnd.
y;
23 if (x0 != x1 || y0 != y1)
57 int fraction = dy - (dx >> 1);
71 if (0 <= x0 && 0 <= y0)
81 int fraction = dx - (dy >> 1);
95 if (0 <= x0 && 0 <= y0)
◆ getNeighborPositionToOrigin()
NeighborNodesPosition PointFunctions::getNeighborPositionToOrigin |
( |
const Point & |
neighboringPoint, |
|
|
const Point & |
originPoint |
|
) |
| |
|
static |
Get the position of the neighboring node to the originpoint (center of the neighborgroup).
- Parameters
-
neighboringPoint | the neighboring point |
originPoint | the center of the neighbor group we want to get the direction to |
- Returns
- An enum representing the Direction from the neighboring point to the origin point
Definition at line 202 of file PointFunctions.cxx.
204 int neighborOffsetX = neighboringPoint.
x - originPoint.
x;
205 int neighborOffsetY = neighboringPoint.
y - originPoint.
y;
207 switch (neighborOffsetX)
210 switch (neighborOffsetY)
213 return NeighborNodesPosition::CENTER;
215 return NeighborNodesPosition::TOP;
217 return NeighborNodesPosition::BOTTOM;
221 switch (neighborOffsetY)
224 return NeighborNodesPosition::RIGHT;
226 return NeighborNodesPosition::TOP_RIGHT;
228 return NeighborNodesPosition::BOTTOM_RIGHT;
232 switch (neighborOffsetY)
235 return NeighborNodesPosition::LEFT;
237 return NeighborNodesPosition::TOP_LEFT;
239 return NeighborNodesPosition::BOTTOM_LEFT;
244 return NeighborNodesPosition::CENTER;
◆ getNeighbors()
std::vector< Point > PointFunctions::getNeighbors |
( |
const Point & |
isoCoordinates, |
|
|
const bool |
includeCentralNode, |
|
|
int |
distance = 1 |
|
) |
| |
|
static |
Get all neighboring coordinates from provided map node isocoordinate.
- Parameters
-
isoCoordinates | point to get neighbors of |
includeCentralNode | if set to true include the central node in the result. |
- Returns
- std::vector<Point>() of all neighboring node coordinates.
Definition at line 175 of file PointFunctions.cxx.
177 std::vector<Point> neighbors;
179 for (
int xOffset = -distance; xOffset <= distance; ++xOffset)
181 for (
int yOffset = -distance; yOffset <= distance; ++yOffset)
183 if (!includeCentralNode && (xOffset == 0) && (yOffset == 0))
189 neighbor.
x = isoCoordinates.
x + xOffset;
190 neighbor.
y = isoCoordinates.
y + yOffset;
194 neighbors.push_back(neighbor);
◆ getStraightLine()
std::vector< Point > PointFunctions::getStraightLine |
( |
const Point & |
isoCoordinatesStart, |
|
|
const Point & |
isoCoordinatesEnd |
|
) |
| |
|
static |
Gets all nodes in a straight line from start and end point.
- Parameters
-
isoCoordinatesStart | start coordinates |
isoCoordinatesEnd | end coordinates |
- Returns
- std::vector<Point>() containing coordinates for each tile between start and end coordinates, including start and end
Definition at line 108 of file PointFunctions.cxx.
110 std::vector<Point> rectangle;
111 int directionX = isoCoordinatesStart.
x < isoCoordinatesEnd.
x ? 1 : -1;
112 int directionY = isoCoordinatesStart.
y < isoCoordinatesEnd.
y ? 1 : -1;
113 int staticX, staticY;
116 uint32_t xDist = std::abs(isoCoordinatesStart.
x - isoCoordinatesEnd.
x);
117 uint32_t yDist = std::abs(isoCoordinatesStart.
y - isoCoordinatesEnd.
y);
119 if (xDist == 0 && yDist == 1)
123 else if (xDist == 1 && yDist == 0)
127 else if (xDist == 0 && yDist == 0)
129 rectangle.push_back(
Point{isoCoordinatesStart.
x, isoCoordinatesStart.
y});
134 staticX = isoCoordinatesStart.
x;
135 staticY = isoCoordinatesEnd.
y;
139 staticX = isoCoordinatesEnd.
x;
140 staticY = isoCoordinatesStart.
y;
143 for (
int x = isoCoordinatesStart.
x; x != isoCoordinatesEnd.
x; x += directionX)
145 rectangle.push_back(
Point{x, staticY});
148 for (
int y = isoCoordinatesStart.
y; y != isoCoordinatesEnd.
y; y += directionY)
150 rectangle.push_back(
Point{staticX, y});
The documentation for this class was generated from the following files: