Update code to accomodate the new coord/coord2d/coord_path structs.
Also replicate the methods of DFCoord.develop
parent
d75292acc7
commit
7db467a740
@ -1,3 +1,3 @@
|
||||
*.h
|
||||
*.inc
|
||||
static*.inc
|
||||
*.xml
|
||||
|
@ -0,0 +1,45 @@
|
||||
coord(const coord2d &c, uint16_t _z) : x(c.x), y(c.y), z(_z) {}
|
||||
coord(uint16_t _x, uint16_t _y, uint16_t _z) : x(_x), y(_y), z(_z) {}
|
||||
|
||||
operator coord2d() const { return coord2d(x,y); }
|
||||
|
||||
bool isValid() const { return x != -30000; }
|
||||
void clear() { x = y = z = -30000; }
|
||||
|
||||
bool operator==(const coord &other) const
|
||||
{
|
||||
return (x == other.x) && (y == other.y) && (z == other.z);
|
||||
}
|
||||
bool operator!=(const coord &other) const
|
||||
{
|
||||
return (x != other.x) || (y != other.y) || (z != other.z);
|
||||
}
|
||||
|
||||
bool operator<(const coord &other) const
|
||||
{
|
||||
if (x != other.x) return (x < other.x);
|
||||
if (y != other.y) return (y < other.y);
|
||||
return z < other.z;
|
||||
}
|
||||
|
||||
coord operator/(int number) const
|
||||
{
|
||||
return coord(x/number, y/number, z);
|
||||
}
|
||||
coord operator*(int number) const
|
||||
{
|
||||
return coord(x*number, y*number, z);
|
||||
}
|
||||
coord operator%(int number) const
|
||||
{
|
||||
return coord(x%number, y%number, z);
|
||||
}
|
||||
|
||||
coord operator-(int number) const
|
||||
{
|
||||
return coord(x,y,z-number);
|
||||
}
|
||||
coord operator+(int number) const
|
||||
{
|
||||
return coord(x,y,z+number);
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
coord2d(uint16_t _x, uint16_t _y) : x(_x), y(_y) {}
|
||||
|
||||
bool isValid() const { return x != -30000; }
|
||||
void clear() { x = y = -30000; }
|
||||
|
||||
bool operator==(const coord2d &other) const
|
||||
{
|
||||
return (x == other.x) && (y == other.y);
|
||||
}
|
||||
bool operator!=(const coord2d &other) const
|
||||
{
|
||||
return (x != other.x) || (y != other.y);
|
||||
}
|
||||
|
||||
bool operator<(const coord2d &other) const
|
||||
{
|
||||
if (x != other.x) return (x < other.x);
|
||||
return y < other.y;
|
||||
}
|
||||
|
||||
coord2d operator/(int number) const
|
||||
{
|
||||
return coord2d(x/number, y/number);
|
||||
}
|
||||
coord2d operator*(int number) const
|
||||
{
|
||||
return coord2d(x*number, y*number);
|
||||
}
|
||||
coord2d operator%(int number) const
|
||||
{
|
||||
return coord2d(x%number, y%number);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
unsigned size() const { return x.size(); }
|
||||
|
||||
coord operator[] (unsigned idx) const {
|
||||
if (idx >= x.size() || idx >= y.size() || idx >= z.size())
|
||||
return coord();
|
||||
else
|
||||
return coord(x[idx], y[idx], z[idx]);
|
||||
}
|
Loading…
Reference in New Issue