Remove Point2f, replace with Vector2f

This commit is contained in:
Bram Verhulst
2024-04-17 13:54:48 +02:00
parent 64e96ab209
commit db83ae5e13
42 changed files with 494 additions and 634 deletions

View File

@@ -14,50 +14,50 @@ Window::Window(const std::string& title, float width, float height, bool isVSync
}
//-----------------------------------------------------------------
// Point2f Constructors
// Vector2f Constructors
//-----------------------------------------------------------------
Point2f::Point2f()
: Point2f { 0.0f, 0.0f } {
}
Point2f::Point2f(float x, float y)
: x { x }, y { y } {
}
Point2f Point2f::operator+(const Point2f& other) const {
return Point2f { x + other.x, y + other.y };
}
Point2f Point2f::operator+=(const Point2f& other) const {
return Point2f { x + other.x, y + other.y };
}
Point2f Point2f::operator*(float other) const {
return Point2f { x * other, y * other };
}
Point2f Point2f::operator*(const Point2f& other) const {
return Point2f { x * other.x, y * other.y };
}
Point2f Point2f::operator*(int other) const {
return Point2f { x * float(other), y * float(other) };
}
Point2f Point2f::operator/(float other) const {
return Point2f { x / other, y / other };
}
Point2f Point2f::operator-(const Point2f& other) const {
return Point2f { x - other.x, y - other.y };
}
// Vector2f::Vector2f()
// : Vector2f { 0.0f, 0.0f } {
// }
// Vector2f::Vector2f(float x, float y)
// : x { x }, y { y } {
// }
// Vector2f Vector2f::operator+(const Vector2f& other) const {
// return Vector2f { x + other.x, y + other.y };
// }
// Vector2f Vector2f::operator+=(const Vector2f& other) const {
// return Vector2f { x + other.x, y + other.y };
// }
// Vector2f Vector2f::operator*(float other) const {
// return Vector2f { x * other, y * other };
// }
// Vector2f Vector2f::operator*(const Vector2f& other) const {
// return Vector2f { x * other.x, y * other.y };
// }
// Vector2f Vector2f::operator*(int other) const {
// return Vector2f { x * float(other), y * float(other) };
// }
// Vector2f Vector2f::operator/(float other) const {
// return Vector2f { x / other, y / other };
// }
// Vector2f Vector2f::operator-(const Vector2f& other) const {
// return Vector2f { x - other.x, y - other.y };
// }
// Point2f::Point2f(int x, int y)
// Vector2f::Vector2f(int x, int y)
// : x { (float)x }, y { (float)y } {
// }
Point2f operator/(float right, const Point2f& left) {
return Point2f { right / left.x, right / left.y };
}
Point2f operator*(float right, const Point2f& left) {
return Point2f{ right * left.x, right * left.y };
}
std::ostream& operator<<(std::ostream& os, const Point2f& p) {
os << "Point2f( " << p.x << ", " << p.y << " )" << std::endl;
return os;
}
// Vector2f operator/(float right, const Vector2f& left) {
// return Vector2f { right / left.x, right / left.y };
// }
// Vector2f operator*(float right, const Vector2f& left) {
// return Vector2f{ right * left.x, right * left.y };
// }
// std::ostream& operator<<(std::ostream& os, const Vector2f& p) {
// os << "Vector2f( " << p.x << ", " << p.y << " )" << std::endl;
// return os;
// }
//-----------------------------------------------------------------
// Rectf Constructors
//-----------------------------------------------------------------
@@ -71,7 +71,7 @@ Rectf::Rectf(float left, float bottom, float width, float height)
, width { width }
, height { height } {
}
Rectf::Rectf(Point2f pos, Point2f size): left(pos.x), bottom(pos.y), width(size.x), height(size.y) {}
Rectf::Rectf(Vector2f pos, Vector2f size): left(pos.x), bottom(pos.y), width(size.x), height(size.y) {}
// Rectf::Rectf(int left, int bottom, int width, int height) : left { (float)left }, bottom { (float)bottom }, width { (float)width }, height { (float)height } {
// }
@@ -97,10 +97,10 @@ Circlef::Circlef()
}
Circlef::Circlef(float centerX, float centerY, float radius)
: Circlef { Point2f { centerX, centerY }, radius } {
: Circlef { Vector2f { centerX, centerY }, radius } {
}
Circlef::Circlef(const Point2f& center, float radius)
Circlef::Circlef(const Vector2f& center, float radius)
: center { center }
, radius { radius } {
}
@@ -113,12 +113,12 @@ Ellipsef::Ellipsef()
}
Ellipsef::Ellipsef(const Point2f& center, float radiusX, float radiusY)
Ellipsef::Ellipsef(const Vector2f& center, float radiusX, float radiusY)
: center { center }
, radiusX { radiusX }
, radiusY { radiusY } {
}
Ellipsef::Ellipsef(float centerX, float centerY, float radiusX, float radiusY)
: Ellipsef { Point2f { centerX, centerY }, radiusX, radiusY } {
: Ellipsef { Vector2f { centerX, centerY }, radiusX, radiusY } {
}