Go to the documentation of this file.
120 std::vector<Position> positions;
125 positions.push_back(lastPos);
127 for(
auto dir : dirs) {
131 positions.push_back(lastPos);
142 const int dx = toPos.
x - fromPos.
x;
143 const int dy = toPos.
y - fromPos.
y;
144 if(dx == 0 && dy == 0)
147 float angle = std::atan2(dy * -1, dx);
163 if(angle >= 360 - 22.5 || angle < 0 + 22.5)
166 if(angle >= 45 - 22.5 && angle < 45 + 22.5)
169 if(angle >= 90 - 22.5 && angle < 90 + 22.5)
172 if(angle >= 135 - 22.5 && angle < 135 + 22.5)
175 if(angle >= 180 - 22.5 && angle < 180 + 22.5)
178 if(angle >= 225 - 22.5 && angle < 225 + 22.5)
181 if(angle >= 270 - 22.5 && angle < 270 + 22.5)
184 if(angle >= 315 - 22.5 && angle < 315 + 22.5)
196 bool isValid()
const {
return !(
x == 65535 &&
y == 65535 &&
z == 255); }
200 void translate(
int dx,
int dy,
short dz = 0) {
x += dx;
y += dy;
z += dz; }
214 bool isInRange(
const Position& pos,
int xRange,
int yRange)
const {
return std::abs(
x - pos.
x) <= xRange && std::abs(
y - pos.
y) <= yRange &&
z == pos.
z; }
215 bool isInRange(
const Position& pos,
int minXRange,
int maxXRange,
int minYRange,
int maxYRange)
const
217 return pos.
x >=
x - minXRange && pos.
x <=
x + maxXRange && pos.
y >=
y - minYRange && pos.
y <=
y + maxYRange && pos.
z ==
z;
224 const int nz =
z - n;
234 const int nz =
z + n;
245 const int nx =
x + n, ny =
y + n, nz =
z - n;
246 if(nx >= 0 && nx <= 65535 && ny >= 0 && ny <= 65535 && nz >= 0 && nz <=
Otc::MAX_Z) {
247 x = nx;
y = ny;
z = nz;
256 const int nx =
x - n, ny =
y - n, nz =
z + n;
257 if(nx >= 0 && nx <= 65535 && ny >= 0 && ny <= 65535 && nz >= 0 && nz <=
Otc::MAX_Z) {
258 x = nx;
y = ny;
z = nz;
273 return (pos.
x * 8192 + pos.
y) * 16 + pos.
z;
279 out << static_cast<int>(pos.
x) <<
" " <<
static_cast<int>(pos.
y) <<
" " <<
static_cast<int>(pos.
z);
Position translatedToDirection(Otc::Direction direction)
bool isInRange(const Position &pos, int xRange, int yRange) const
Position operator+(const Point &other) const
float distance(const Position &pos) const
Position operator-(const Position &other) const
std::vector< Position > translatedToDirections(const std::vector< Otc::Direction > &dirs) const
void translate(int dx, int dy, short dz=0)
std::istream & operator>>(std::istream &in, Position &pos)
Position translatedToReverseDirection(Otc::Direction direction)
Position(uint16 x, uint16 y, uint8 z)
Position & operator+=(const Position &other)
bool operator==(const Position &other) const
Position translated(int dx, int dy, short dz=0) const
static Otc::Direction getDirectionFromPositions(const Position &fromPos, const Position &toPos)
bool isMapPosition() const
std::ostream & operator<<(std::ostream &out, const Position &pos)
static double getAngleFromPositions(const Position &fromPos, const Position &toPos)
Otc::Direction getDirectionFromPosition(const Position &position) const
double getAngleFromPosition(const Position &position) const
std::size_t operator()(const Position &pos) const
bool coveredDown(int n=1)
bool operator<(const Position &other) const
Position operator+(const Position &other) const
bool operator!=(const Position &other) const
bool isInRange(const Position &pos, int minXRange, int maxXRange, int minYRange, int maxYRange) const
static bool isDiagonal(const Otc::Direction dir)
Position & operator+=(const Point &other)
int manhattanDistance(const Position &pos) const
Position & operator-=(const Position &other)
Position & operator=(const Position &other)