Implement additional operators for the vector class
This commit is contained in:
committed by
Peter Barnes
parent
6f42c72d77
commit
e906cde580
@@ -122,6 +122,30 @@ bool operator < (const Vector3D &a, const Vector3D &b)
|
||||
return std::tie (a.x, a.y, a.z) <
|
||||
std::tie (b.x, b.y, b.z);
|
||||
}
|
||||
bool operator <= (const Vector3D &a, const Vector3D &b)
|
||||
{
|
||||
return std::tie (a.x, a.y, a.z) <=
|
||||
std::tie (b.x, b.y, b.z);
|
||||
}
|
||||
bool operator > (const Vector3D &a, const Vector3D &b)
|
||||
{
|
||||
return std::tie (a.x, a.y, a.z) >
|
||||
std::tie (b.x, b.y, b.z);
|
||||
}
|
||||
bool operator >= (const Vector3D &a, const Vector3D &b)
|
||||
{
|
||||
return std::tie (a.x, a.y, a.z) >=
|
||||
std::tie (b.x, b.y, b.z);
|
||||
}
|
||||
bool operator == (const Vector3D &a, const Vector3D &b)
|
||||
{
|
||||
return std::tie (a.x, a.y, a.z) ==
|
||||
std::tie (b.x, b.y, b.z);
|
||||
}
|
||||
bool operator != (const Vector3D &a, const Vector3D &b)
|
||||
{
|
||||
return ! (a == b);
|
||||
}
|
||||
Vector3D
|
||||
operator + (const Vector3D &a, const Vector3D &b)
|
||||
{
|
||||
@@ -152,6 +176,30 @@ bool operator < (const Vector2D &a, const Vector2D &b)
|
||||
return std::tie (a.x, a.y) <
|
||||
std::tie (b.x, b.y);
|
||||
}
|
||||
bool operator <= (const Vector2D &a, const Vector2D &b)
|
||||
{
|
||||
return std::tie (a.x, a.y) <=
|
||||
std::tie (b.x, b.y);
|
||||
}
|
||||
bool operator > (const Vector2D &a, const Vector2D &b)
|
||||
{
|
||||
return std::tie (a.x, a.y) >
|
||||
std::tie (b.x, b.y);
|
||||
}
|
||||
bool operator >= (const Vector2D &a, const Vector2D &b)
|
||||
{
|
||||
return std::tie (a.x, a.y) >=
|
||||
std::tie (b.x, b.y);
|
||||
}
|
||||
bool operator == (const Vector2D &a, const Vector2D &b)
|
||||
{
|
||||
return std::tie (a.x, a.y) ==
|
||||
std::tie (b.x, b.y);
|
||||
}
|
||||
bool operator != (const Vector2D &a, const Vector2D &b)
|
||||
{
|
||||
return ! (a == b);
|
||||
}
|
||||
Vector2D
|
||||
operator + (const Vector2D &a, const Vector2D &b)
|
||||
{
|
||||
|
||||
@@ -103,6 +103,46 @@ public:
|
||||
*/
|
||||
friend bool operator < (const Vector3D &a, const Vector3D &b);
|
||||
|
||||
/**
|
||||
* Less than or equal to comparison operator
|
||||
* \param [in] a lhs vector
|
||||
* \param [in] b rhs vector
|
||||
* \returns \c true if \p a is less than or equal to \p b.
|
||||
*/
|
||||
friend bool operator <= (const Vector3D &a, const Vector3D &b);
|
||||
|
||||
/**
|
||||
* Greater than comparison operator
|
||||
* \param [in] a lhs vector
|
||||
* \param [in] b rhs vector
|
||||
* \returns \c true if \p a is greater than \p b.
|
||||
*/
|
||||
friend bool operator > (const Vector3D &a, const Vector3D &b);
|
||||
|
||||
/**
|
||||
* Greater than or equal to comparison operator
|
||||
* \param [in] a lhs vector
|
||||
* \param [in] b rhs vector
|
||||
* \returns \c true if \p a is greater than or equal to \p b.
|
||||
*/
|
||||
friend bool operator >= (const Vector3D &a, const Vector3D &b);
|
||||
|
||||
/**
|
||||
* Equality operator.
|
||||
* \param [in] a lhs vector.
|
||||
* \param [in] b rhs vector.
|
||||
* \returns \c true if \p a is equal to \p b.
|
||||
*/
|
||||
friend bool operator == (const Vector3D &a, const Vector3D &b);
|
||||
|
||||
/**
|
||||
* Inequality operator.
|
||||
* \param [in] a lhs vector.
|
||||
* \param [in] b rhs vector.
|
||||
* \returns \c true if \p a is not equal to \p b.
|
||||
*/
|
||||
friend bool operator != (const Vector3D &a, const Vector3D &b);
|
||||
|
||||
/**
|
||||
* Addition operator.
|
||||
* \param [in] a lhs vector.
|
||||
@@ -181,6 +221,46 @@ public:
|
||||
*/
|
||||
friend bool operator < (const Vector2D &a, const Vector2D &b);
|
||||
|
||||
/**
|
||||
* Less than or equal to comparison operator
|
||||
* \param [in] a lhs vector
|
||||
* \param [in] b rhs vector
|
||||
* \returns \c true if \p a is less than or equal to \p b.
|
||||
*/
|
||||
friend bool operator <= (const Vector2D &a, const Vector2D &b);
|
||||
|
||||
/**
|
||||
* Greater than comparison operator
|
||||
* \param [in] a lhs vector
|
||||
* \param [in] b rhs vector
|
||||
* \returns \c true if \p a is greater than \p b.
|
||||
*/
|
||||
friend bool operator > (const Vector2D &a, const Vector2D &b);
|
||||
|
||||
/**
|
||||
* Greater than or equal to comparison operator
|
||||
* \param [in] a lhs vector
|
||||
* \param [in] b rhs vector
|
||||
* \returns \c true if \p a is greater than or equal to \p b.
|
||||
*/
|
||||
friend bool operator >= (const Vector2D &a, const Vector2D &b);
|
||||
|
||||
/**
|
||||
* Equality operator.
|
||||
* \param [in] a lhs vector.
|
||||
* \param [in] b rhs vector.
|
||||
* \returns \c true if \p a is equal to \p b.
|
||||
*/
|
||||
friend bool operator == (const Vector2D &a, const Vector2D &b);
|
||||
|
||||
/**
|
||||
* Inequality operator.
|
||||
* \param [in] a lhs vector.
|
||||
* \param [in] b rhs vector.
|
||||
* \returns \c true if \p a is not equal to \p b.
|
||||
*/
|
||||
friend bool operator != (const Vector2D &a, const Vector2D &b);
|
||||
|
||||
/**
|
||||
* Addition operator.
|
||||
* \param [in] a lhs vector.
|
||||
|
||||
Reference in New Issue
Block a user