mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-17 07:11:48 +01:00
Remove Point2f, replace with Vector2f
This commit is contained in:
@@ -19,16 +19,14 @@ Vector2f::Vector2f( float x, float y )
|
||||
, y{ y }
|
||||
{
|
||||
}
|
||||
|
||||
Vector2f::Vector2f( const Point2f& fromPoint, const Point2f& tillPoint )
|
||||
Vector2f::Vector2f( const Vector2f& fromPoint, const Vector2f& tillPoint )
|
||||
: Vector2f{ tillPoint.x - fromPoint.x, tillPoint.y - fromPoint.y }
|
||||
{
|
||||
}
|
||||
|
||||
Vector2f::Vector2f(const Point2f & point)
|
||||
: Vector2f{ Point2f{ 0.0f, 0.0f }, point }
|
||||
{
|
||||
}
|
||||
// Vector2f::Vector2f(const Vector2f & point)
|
||||
// : Vector2f{ Vector2f{ 0.0f, 0.0f }, point }
|
||||
// {
|
||||
// }
|
||||
|
||||
// -------------------------
|
||||
// Methods
|
||||
@@ -38,11 +36,6 @@ bool Vector2f::Equals(const Vector2f& other, float epsilon) const
|
||||
return ( abs(x - other.x) < epsilon ) && ( abs(y - other.y) < epsilon );
|
||||
}
|
||||
|
||||
Point2f Vector2f::ToPoint2f() const
|
||||
{
|
||||
return Point2f{ x, y };
|
||||
}
|
||||
|
||||
float Vector2f::DotProduct(const Vector2f& other) const
|
||||
{
|
||||
return x * other.x + y * other.y;
|
||||
@@ -113,6 +106,9 @@ void Vector2f::Set(float newX, float newY)
|
||||
x = newX;
|
||||
y = newY;
|
||||
}
|
||||
Vector2f Vector2f::operator*(const Vector2f& vector2_f) const {
|
||||
return Vector2f{ x * vector2_f.x, y * vector2_f.y };
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// Member operators
|
||||
@@ -151,12 +147,6 @@ Vector2f& Vector2f::operator-=(const Vector2f& rhs)
|
||||
*this += -rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2f::operator Point2f()
|
||||
{
|
||||
return Point2f{ x,y };
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
// Non-member operators
|
||||
// -------------------------
|
||||
@@ -174,6 +164,9 @@ Vector2f operator/( Vector2f lhs, float rhs )
|
||||
{
|
||||
return lhs *= (1 / rhs);
|
||||
}
|
||||
Vector2f operator/(float lhs, const Vector2f& rhs) {
|
||||
return Vector2f{ lhs / rhs.x, lhs / rhs.y };
|
||||
}
|
||||
|
||||
Vector2f operator+( Vector2f lhs, const Vector2f& rhs )
|
||||
{
|
||||
@@ -199,38 +192,4 @@ std::ostream& operator<< ( std::ostream& lhs, const Vector2f& rhs )
|
||||
{
|
||||
lhs << rhs.ToString( );
|
||||
return lhs;
|
||||
}
|
||||
|
||||
// Point2f related operators
|
||||
Point2f& operator+=(Point2f& lhs, const Vector2f& rhs)
|
||||
{
|
||||
lhs.x += rhs.x;
|
||||
lhs.y += rhs.y;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
Point2f operator+(Point2f lhs, const Vector2f& rhs)
|
||||
{
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
Point2f& operator-=(Point2f& lhs, const Vector2f& rhs)
|
||||
{
|
||||
lhs.x -= rhs.x;
|
||||
lhs.y -= rhs.y;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
Point2f operator-(Point2f lhs, const Vector2f& rhs)
|
||||
{
|
||||
lhs -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
||||
Vector2f operator-(const Point2f& lhs, const Point2f& rhs)
|
||||
{
|
||||
Vector2f v{ lhs.x - rhs.x, lhs.y - rhs.y };
|
||||
return v;
|
||||
}
|
||||
Reference in New Issue
Block a user