Add multiply and divide to coordinate components

This commit is contained in:
Matt committed 2021-02-21 09:52:32 +02:00
1 parent e7adf19f62
commit a2ebec8676
1 file changed
+24
+24
View File
@@ -139,6 +139,20 @@ struct CoordsXY
return *this;
}
constexpr CoordsXY& operator*=(const int32_t rhs)
{
x *= rhs;
y *= rhs;
return *this;
}
constexpr CoordsXY& operator/=(const int32_t rhs)
{
x /= rhs;
y /= rhs;
return *this;
}
constexpr bool operator>=(const CoordsXY& rhs) const
{
return x >= rhs.x && y >= rhs.y;
@@ -159,6 +173,16 @@ struct CoordsXY
return { x - rhs.x, y - rhs.y };
}
constexpr const CoordsXY operator*(const int32_t rhs) const
{
return { x * rhs, y * rhs };
}
constexpr const CoordsXY operator/(const int32_t rhs) const
{
return { x / rhs, y / rhs };
}
constexpr CoordsXY Rotate(int32_t direction) const
{
CoordsXY rotatedCoords;