Skip to content

Commit

Permalink
Vector4 comparison operators are now non-members
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mott committed Sep 15, 2021
1 parent 87a8eb6 commit f664726
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions libs/math/Vector4.h
Expand Up @@ -87,19 +87,6 @@ class BasicVector4
return ss.str();
}

/// Compare this BasicVector4 against another for equality.
bool operator== (const BasicVector4& other) const {
return (other.x() == x()
&& other.y() == y()
&& other.z() == z()
&& other.w() == w());
}

/// Compare this BasicVector4 against another for inequality.
bool operator!= (const BasicVector4& other) const {
return !(*this == other);
}

/// Dot product this BasicVector4 with another vector
Element dot(const BasicVector4<Element>& other) const {
return x() * other.x()
Expand Down Expand Up @@ -139,6 +126,23 @@ class BasicVector4
}
}; // BasicVector4

/// Equality comparison for BasicVector4
template<typename T>
bool operator== (const BasicVector4<T>& v1, const BasicVector4<T>& v2)
{
return (v1.x() == v2.x()
&& v1.y() == v2.y()
&& v1.z() == v2.z()
&& v1.w() == v2.w());
}

/// Inequality comparison for BasicVector4
template<typename T>
bool operator!= (const BasicVector4<T>& v1, const BasicVector4<T>& v2)
{
return !(v1 == v2);
}

/// Componentwise addition of two vectors
template <typename T>
BasicVector4<T> operator+(const BasicVector4<T>& v1, const BasicVector4<T>& v2)
Expand Down

0 comments on commit f664726

Please sign in to comment.