mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 19:05:59 -04:00
Add Point memberwise division/multiplication
This commit is contained in:
parent
ca505369f3
commit
f4823de989
@ -88,6 +88,14 @@ Point Point::operator-(const Point& other) const {
|
||||
return Point(x - other.x, y - other.y);
|
||||
}
|
||||
|
||||
Point Point::operator/(int value) const {
|
||||
return Point(x / value, y / value);
|
||||
}
|
||||
|
||||
Point Point::operator*(int value) const {
|
||||
return Point(x * value, y * value);
|
||||
}
|
||||
|
||||
Point& Point::operator+=(const Point& other) {
|
||||
x += other.x;
|
||||
y += other.y;
|
||||
@ -102,4 +110,18 @@ Point& Point::operator-=(const Point& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point& Point::operator/=(int value) {
|
||||
x /= value;
|
||||
y /= value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Point& Point::operator*=(int value) {
|
||||
x *= value;
|
||||
y *= value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -159,27 +159,47 @@ public:
|
||||
void SetY(int ny);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get sum of two points
|
||||
/// \brief Get point's memberwise addition with another point
|
||||
///
|
||||
/// \param other Point to add
|
||||
///
|
||||
/// \returns New Point representing memberwise addition of two points
|
||||
/// \returns New Point representing memberwise addition with another point
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Point operator+(const Point& other) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get subtraction of two points
|
||||
/// \brief Get point's memberwise subtraction with another point
|
||||
///
|
||||
/// \param other Point to subtract
|
||||
///
|
||||
/// \returns New Point representing memberwise subtraction of two points
|
||||
/// \returns New Point representing memberwise subtraction of another point
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Point operator-(const Point& other) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Add another point
|
||||
/// \brief Get point's memberwise division by an integer
|
||||
///
|
||||
/// \param value Divisor
|
||||
///
|
||||
/// \returns New Point representing memberwise division of point by and integer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Point operator/(int value) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get point's memberwise multiplication by an integer
|
||||
///
|
||||
/// \param value Multiplier
|
||||
///
|
||||
/// \returns New Point representing memberwise multiplication of point by an integer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Point operator*(int value) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Memberwise add another point
|
||||
///
|
||||
/// \param other Point to add to the current one
|
||||
///
|
||||
@ -189,7 +209,7 @@ public:
|
||||
Point& operator+=(const Point& other);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Substact another point
|
||||
/// \brief Memberwise subtract another point
|
||||
///
|
||||
/// \param other Point to subtract from the current one
|
||||
///
|
||||
@ -197,6 +217,26 @@ public:
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Point& operator-=(const Point& other);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Memberwise divide by an inteher
|
||||
///
|
||||
/// \param value Divisor
|
||||
///
|
||||
/// \returns Reference to self
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Point& operator/=(int value);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Memberwise multiply by an integer
|
||||
///
|
||||
/// \param value Multiplier
|
||||
///
|
||||
/// \returns Reference to self
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Point& operator*=(int value);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user