|
| 1 | +coord(const coord2d &c, uint16_t _z) : x(c.x), y(c.y), z(_z) {} |
| 2 | +coord(uint16_t _x, uint16_t _y, uint16_t _z) : x(_x), y(_y), z(_z) {} |
| 3 | + |
| 4 | +operator coord2d() const { return coord2d(x,y); } |
| 5 | + |
| 6 | +bool isValid() const { return x != -30000; } |
| 7 | +void clear() { x = y = z = -30000; } |
| 8 | + |
| 9 | +bool operator==(const coord &other) const |
| 10 | +{ |
| 11 | + return (x == other.x) && (y == other.y) && (z == other.z); |
| 12 | +} |
| 13 | +bool operator!=(const coord &other) const |
| 14 | +{ |
| 15 | + return (x != other.x) || (y != other.y) || (z != other.z); |
| 16 | +} |
| 17 | + |
| 18 | +bool operator<(const coord &other) const |
| 19 | +{ |
| 20 | + if (x != other.x) return (x < other.x); |
| 21 | + if (y != other.y) return (y < other.y); |
| 22 | + return z < other.z; |
| 23 | +} |
| 24 | + |
| 25 | +coord operator/(int number) const |
| 26 | +{ |
| 27 | + return coord(x/number, y/number, z); |
| 28 | +} |
| 29 | +coord operator*(int number) const |
| 30 | +{ |
| 31 | + return coord(x*number, y*number, z); |
| 32 | +} |
| 33 | +coord operator%(int number) const |
| 34 | +{ |
| 35 | + return coord(x%number, y%number, z); |
| 36 | +} |
| 37 | + |
| 38 | +coord operator-(int number) const |
| 39 | +{ |
| 40 | + return coord(x,y,z-number); |
| 41 | +} |
| 42 | +coord operator+(int number) const |
| 43 | +{ |
| 44 | + return coord(x,y,z+number); |
| 45 | +} |
0 commit comments