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

@@ -8,26 +8,25 @@ struct Vector2f final
// -------------------------
Vector2f( );
explicit Vector2f( float x, float y );
explicit Vector2f( const Point2f& fromPoint, const Point2f& tillPoint );
explicit Vector2f( const Point2f& point );
explicit Vector2f( const Vector2f& fromPoint, const Vector2f& tillPoint );
// explicit Vector2f( const Vector2f& point );
// -------------------------
// Member operators
// -------------------------
Vector2f operator-( ) const;
Vector2f operator+( ) const;
Vector2f& operator*=( float rhs);
Vector2f& operator/=( float rhs);
Vector2f& operator+=( const Vector2f& rhs);
Vector2f& operator-=( const Vector2f& rhs);
explicit operator Point2f();
Vector2f& operator*=( float rhs);
Vector2f& operator/=( float rhs);
// -------------------------
// Methods
// -------------------------
// Convert to Point2f
Point2f ToPoint2f( ) const;
// Are two vectors equal within a threshold?
// u.Equals(v)
bool Equals( const Vector2f& other, float epsilon = 0.001f ) const;
@@ -75,6 +74,7 @@ struct Vector2f final
// Sets the values of x and y
void Set( float newX, float newY );
Vector2f operator*(const Vector2f& vector2_f) const;
// -------------------------
// Datamembers
@@ -88,6 +88,8 @@ struct Vector2f final
Vector2f operator*( float lhs, Vector2f rhs );
Vector2f operator*( Vector2f lhs, float rhs );
Vector2f operator/( Vector2f lhs, float rhs );
Vector2f operator/(float lhs, const Vector2f& rhs);
Vector2f operator+( Vector2f lhs, const Vector2f& rhs );
Vector2f operator-( Vector2f lhs, const Vector2f& rhs );
@@ -95,15 +97,4 @@ Vector2f operator-( Vector2f lhs, const Vector2f& rhs );
bool operator==( const Vector2f& lhs, const Vector2f& rhs );
bool operator!=( const Vector2f& lhs, const Vector2f& rhs );
std::ostream& operator<< ( std::ostream& lhs, const Vector2f& rhs );
// Translating a point by a vector
Point2f& operator+=(Point2f& lhs, const Vector2f& rhs);
Point2f operator+(Point2f lhs, const Vector2f& rhs);
Point2f& operator-=(Point2f& lhs, const Vector2f& rhs);
Point2f operator-(Point2f lhs, const Vector2f& rhs);
// The difference vector between 2 points
Vector2f operator-( const Point2f& lhs, const Point2f& rhs);
std::ostream& operator<< ( std::ostream& lhs, const Vector2f& rhs );