diff --git a/Vector2.cpp b/Vector2.cpp index 5a1495a..6a1a03a 100644 --- a/Vector2.cpp +++ b/Vector2.cpp @@ -53,6 +53,10 @@ const Vector2 Vector2::down = Vector2(0, -1); const Vector2 Vector2::forward = Vector2(0, 1); const Vector2 Vector2::back = Vector2(0, -1); +bool Vector2::operator==(const Vector2 &v) { + return (this->x == v.x && this->y == v.y); +} + float Vector2::Magnitude(const Vector2 &a) { return sqrtf(a.x * a.x + a.y * a.y); } @@ -104,10 +108,6 @@ float Vector2::Dot(const Vector2 &v1, const Vector2 &v2) { return v1.x * v2.x + v1.y * v2.y; } -bool Vector2::operator==(const Vector2 &v) { - return (this->x == v.x && this->y == v.y); -} - float Vector2::Distance(const Vector2 &p1, const Vector2 &p2) { return Magnitude(p1 - p2); } diff --git a/Vector2.h b/Vector2.h index 19daeb1..7fd361c 100644 --- a/Vector2.h +++ b/Vector2.h @@ -98,6 +98,13 @@ public: /// const static Vector2 back; + /// @brief Check if this vector to the given vector + /// @param vector The vector to check against + /// @return true if it is identical to the given vector + /// @note This uses float comparison to check equality which may + /// have strange effects. Equality on floats should be avoided. + bool operator==(const Vector2 &vector); + /// /// The length of a vector /// @@ -189,15 +196,6 @@ public: /// The dot product of the two vectors static float Dot(const Vector2 &vector1, const Vector2 &vector2); - /// - /// Check is this vector is equal to the given vector - /// - /// The vector to check against - /// True if it is identical to the given vector - /// Note this uses float comparison to check equality which - /// may have strange effects. Equality on float should be avoided. - bool operator==(const Vector2 &vector); - /// /// The distance between two vectors ///