Go to the documentation of this file.
117 std::vector<Position> positions;
122 positions.push_back(lastPos);
124 for(
auto dir : dirs) {
128 positions.push_back(lastPos);
136 int dx = toPos.
x - fromPos.
x;
137 int dy = toPos.
y - fromPos.
y;
138 if(dx == 0 && dy == 0)
141 float angle = std::atan2(dy * -1, dx);
157 if(angle >= 360 - 22.5 || angle < 0 + 22.5)
159 else if(angle >= 45 - 22.5 && angle < 45 + 22.5)
161 else if(angle >= 90 - 22.5 && angle < 90 + 22.5)
163 else if(angle >= 135 - 22.5 && angle < 135 + 22.5)
165 else if(angle >= 180 - 22.5 && angle < 180 + 22.5)
167 else if(angle >= 225 - 22.5 && angle < 225 + 22.5)
169 else if(angle >= 270 - 22.5 && angle < 270 + 22.5)
171 else if(angle >= 315 - 22.5 && angle < 315 + 22.5)
182 bool isValid()
const {
return !(
x == 65535 &&
y == 65535 &&
z == 255); }
186 void translate(
int dx,
int dy,
short dz = 0) {
x += dx;
y += dy;
z += dz; }
200 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; }
201 bool isInRange(
const Position& pos,
int minXRange,
int maxXRange,
int minYRange,
int maxYRange)
const {
202 return (pos.
x >=
x-minXRange && pos.
x <=
x+maxXRange && pos.
y >=
y-minYRange && pos.
y <=
y+maxYRange && pos.
z ==
z);
226 int nx =
x+n, ny =
y+n, nz =
z-n;
227 if(nx >= 0 && nx <= 65535 && ny >= 0 && ny <= 65535 && nz >= 0 && nz <=
Otc::MAX_Z) {
228 x = nx;
y = ny;
z = nz;
235 int nx =
x-n, ny =
y-n, nz =
z+n;
236 if(nx >= 0 && nx <= 65535 && ny >= 0 && ny <= 65535 && nz >= 0 && nz <=
Otc::MAX_Z) {
237 x = nx;
y = ny;
z = nz;
250 return (((pos.
x * 8192) + pos.
y) * 16) + pos.
z;
256 out << (int)pos.
x <<
" " << (
int)pos.
y <<
" " << (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
Position & operator+=(const Point &other)
int manhattanDistance(const Position &pos) const
Position & operator-=(const Position &other)
Position & operator=(const Position &other)