Browse Source

Clean up math namespace

master
C. J. Howard 3 years ago
parent
commit
10c4e44130
14 changed files with 95 additions and 237 deletions
  1. +0
    -30
      src/math/math.hpp
  2. +0
    -5
      src/math/matrix-functions.hpp
  3. +18
    -32
      src/math/matrix-operators.hpp
  4. +0
    -5
      src/math/matrix-type.hpp
  5. +0
    -5
      src/math/quaternion-functions.hpp
  6. +21
    -35
      src/math/quaternion-operators.hpp
  7. +0
    -5
      src/math/quaternion-type.hpp
  8. +12
    -26
      src/math/stream-operators.hpp
  9. +0
    -5
      src/math/transform-functions.hpp
  10. +8
    -22
      src/math/transform-operators.hpp
  11. +0
    -5
      src/math/transform-type.hpp
  12. +0
    -5
      src/math/vector-functions.hpp
  13. +36
    -50
      src/math/vector-operators.hpp
  14. +0
    -7
      src/math/vector-type.hpp

+ 0
- 30
src/math/math.hpp View File

@ -23,54 +23,24 @@
/// Mathematical functions and data types.
namespace math {}
/**
* @defgroup vector Vector
*
* Vector type, functions, and operators.
*/
#include "math/vector-type.hpp"
#include "math/vector-functions.hpp"
#include "math/vector-operators.hpp"
/**
* @defgroup matrix Matrix
*
* Matrix type, functions, and operators.
*/
#include "math/matrix-type.hpp"
#include "math/matrix-functions.hpp"
#include "math/matrix-operators.hpp"
/**
* @defgroup quaternion Quaternion
*
* Quaternion type, functions, and operators.
*/
#include "math/quaternion-type.hpp"
#include "math/quaternion-functions.hpp"
#include "math/quaternion-operators.hpp"
/**
* @defgroup transform Transform
*
* TRS transform type, functions, and operators.
*/
#include "math/transform-type.hpp"
#include "math/transform-functions.hpp"
#include "math/transform-operators.hpp"
/**
* @defgroup io I/O
*
* Functions and operators that read/write vectors, matrices, or quaternions from/to streams.
*/
#include "math/stream-operators.hpp"
/**
* @defgroup utility Utility constants and functions
*
* Commonly used utilities.
*/
#include "math/angles.hpp"
#include "math/constants.hpp"
#include "math/interpolation.hpp"

+ 0
- 5
src/math/matrix-functions.hpp View File

@ -27,9 +27,6 @@
namespace math {
/// @addtogroup matrix
/// @{
/**
* Adds two matrices.
*
@ -867,8 +864,6 @@ matrix type_cast(const matrix& m)
return type_cast<T2>(m, std::make_index_sequence<N>{});
}
/// @}
} // namespace math
#endif // ANTKEEPER_MATH_MATRIX_FUNCTIONS_HPP

+ 18
- 32
src/math/matrix-operators.hpp View File

@ -23,78 +23,64 @@
#include "math/matrix-type.hpp"
#include "math/matrix-functions.hpp"
namespace math {
namespace matrix_operators {
/// @addtogroup matrix
/// @{
/// @copydoc add(const matrix<T, 2, 2>&, const matrix<T, 2, 2>&)
/// @copydoc math::add(const math::matrix<T, 2, 2>&, const math::matrix<T, 2, 2>&)
template <class T, std::size_t N, std::size_t M>
matrix<T, N, M> operator+(const matrix<T, N, M>& x, const matrix<T, N, M>& y);
math::matrix<T, N, M> operator+(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y);
/// @copydoc mul(const matrix<T, 2, 2>&, const matrix<T, 2, 2>&)
/// @copydoc math::mul(const math::matrix<T, 2, 2>&, const math::matrix<T, 2, 2>&)
template <class T, std::size_t N, std::size_t M>
matrix<T, N, M> operator*(const matrix<T, N, M>& x, const matrix<T, N, M>& y);
math::matrix<T, N, M> operator*(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y);
/// @copydoc mul(const matrix<T, N, M>&, T)
/// @copydoc math::mul(const math::matrix<T, N, M>&, T)
template <class T, std::size_t N, std::size_t M>
matrix<T, N, M> operator*(const matrix<T, N, M>& m, T s);
math::matrix<T, N, M> operator*(const math::matrix<T, N, M>& m, T s);
/// @copydoc mul(const matrix<T, N, M>&, T)
/// @copydoc math::mul(const math::matrix<T, N, M>&, T)
template <class T, std::size_t N, std::size_t M>
matrix<T, N, M> operator*(T s, const matrix<T, N, M>& m);
math::matrix<T, N, M> operator*(T s, const math::matrix<T, N, M>& m);
/// @copydoc mul(const matrix<T, 2, 2>&, const vector<T, 2>&)
/// @copydoc math::mul(const math::matrix<T, 2, 2>&, const math::vector<T, 2>&)
template <class T, std::size_t N>
vector<T, N> operator*(const matrix<T, N, N>& m, const vector<T, N>& v);
math::vector<T, N> operator*(const math::matrix<T, N, N>& m, const math::vector<T, N>& v);
/// @copydoc sub(const matrix<T, 2, 2>&, const matrix<T, 2, 2>&)
/// @copydoc math::sub(const math::matrix<T, 2, 2>&, const math::matrix<T, 2, 2>&)
template <class T, std::size_t N, std::size_t M>
matrix<T, N, M> operator-(const matrix<T, N, M>& x, const matrix<T, N, M>& y);
math::matrix<T, N, M> operator-(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y);
template <class T, std::size_t N, std::size_t M>
inline matrix<T, N, M> operator+(const matrix<T, N, M>& x, const matrix<T, N, M>& y)
inline math::matrix<T, N, M> operator+(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y)
{
return add(x, y);
}
template <class T, std::size_t N, std::size_t M>
inline matrix<T, N, M> operator*(const matrix<T, N, M>& x, const matrix<T, N, M>& y)
inline math::matrix<T, N, M> operator*(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y)
{
return mul(x, y);
}
template <class T, std::size_t N, std::size_t M>
inline matrix<T, N, M> operator*(const matrix<T, N, M>& m, T s)
inline math::matrix<T, N, M> operator*(const math::matrix<T, N, M>& m, T s)
{
return mul(m, s);
}
template <class T, std::size_t N, std::size_t M>
inline matrix<T, N, M> operator*(T s, const matrix<T, N, M>& m)
inline math::matrix<T, N, M> operator*(T s, const math::matrix<T, N, M>& m)
{
return mul(m, s);
}
template <class T, std::size_t N>
inline vector<T, N> operator*(const matrix<T, N, N>& m, const vector<T, N>& v)
inline math::vector<T, N> operator*(const math::matrix<T, N, N>& m, const math::vector<T, N>& v)
{
return mul(m, v);
}
template <class T, std::size_t N, std::size_t M>
inline matrix<T, N, M> operator-(const matrix<T, N, M>& x, const matrix<T, N, M>& y)
inline math::matrix<T, N, M> operator-(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y)
{
return sub(x, y);
}
/// @}
} // namespace matrix_operators
} // namespace math
// Bring matrix operators into global namespace
using namespace math::matrix_operators;
#endif // ANTKEEPER_MATH_MATRIX_OPERATORS_HPP

+ 0
- 5
src/math/matrix-type.hpp View File

@ -25,9 +25,6 @@
namespace math {
/// @addtogroup matrix
/// @{
/**
* An NxM matrix.
*
@ -46,8 +43,6 @@ struct matrix
inline constexpr const row_type& operator[](std::size_t i) const noexcept { return columns[i]; }
};
/// @}
} // namespace math
#endif // ANTKEEPER_MATH_MATRIX_TYPE_HPP

+ 0
- 5
src/math/quaternion-functions.hpp View File

@ -28,9 +28,6 @@
namespace math {
/// @addtogroup quaternion
/// @{
/**
* Adds two quaternions.
*
@ -482,8 +479,6 @@ inline quaternion type_cast(const quaternion& q)
};
}
/// @}
} // namespace math
#endif // ANTKEEPER_MATH_QUATERNION_FUNCTIONS_HPP

+ 21
- 35
src/math/quaternion-operators.hpp View File

@ -23,89 +23,75 @@
#include "math/quaternion-type.hpp"
#include "math/quaternion-functions.hpp"
namespace math {
namespace quaternion_operators {
/// @addtogroup quaternion
/// @{
/// @copydoc add(const quaternion<T>&, const quaternion<T>&)
/// @copydoc math::add(const math::quaternion<T>&, const math::quaternion<T>&)
template <class T>
quaternion<T> operator+(const quaternion<T>& x, const quaternion<T>& y);
math::quaternion<T> operator+(const math::quaternion<T>& x, const math::quaternion<T>& y);
/// @copydoc div(const quaternion<T>&, T)
/// @copydoc math::div(const math::quaternion<T>&, T)
template <class T>
quaternion<T> operator/(const quaternion<T>& q, T s);
math::quaternion<T> operator/(const math::quaternion<T>& q, T s);
/// @copydoc mul(const quaternion<T>&, const quaternion<T>&)
/// @copydoc math::mul(const math::quaternion<T>&, const math::quaternion<T>&)
template <class T>
quaternion<T> operator*(const quaternion<T>& x, const quaternion<T>& y);
math::quaternion<T> operator*(const math::quaternion<T>& x, const math::quaternion<T>& y);
/// @copydoc mul(const quaternion<T>&, T)
/// @copydoc math::mul(const math::quaternion<T>&, T)
template <class T>
quaternion<T> operator*(const quaternion<T>& q, T s);
math::quaternion<T> operator*(const math::quaternion<T>& q, T s);
/// @copydoc mul(const quaternion<T>&, const vector<T, 3>&)
/// @copydoc math::mul(const math::quaternion<T>&, const math::vector<T, 3>&)
template <class T>
vector<T, 3> operator*(const quaternion<T>& q, const vector<T, 3>& v);
math::vector<T, 3> operator*(const math::quaternion<T>& q, const math::vector<T, 3>& v);
/// @copydoc sub(const quaternion<T>&, const quaternion<T>&)
/// @copydoc math::sub(const math::quaternion<T>&, const math::quaternion<T>&)
template <class T>
quaternion<T> operator-(const quaternion<T>& x, const quaternion<T>& y);
math::quaternion<T> operator-(const math::quaternion<T>& x, const math::quaternion<T>& y);
/// @copydoc negate(const quaternion<T>&)
/// @copydoc math::negate(const math::quaternion<T>&)
template <class T, std::size_t N>
quaternion<T> operator-(const quaternion<T>& x);
math::quaternion<T> operator-(const math::quaternion<T>& x);
template <class T>
inline quaternion<T> operator+(const quaternion<T>& x, const quaternion<T>& y)
inline math::quaternion<T> operator+(const math::quaternion<T>& x, const math::quaternion<T>& y)
{
return add(x, y);
}
template <class T>
inline quaternion<T> operator/(const quaternion<T>& q, T s)
inline math::quaternion<T> operator/(const math::quaternion<T>& q, T s)
{
return div(q, s);
}
template <class T>
inline quaternion<T> operator*(const quaternion<T>& x, const quaternion<T>& y)
inline math::quaternion<T> operator*(const math::quaternion<T>& x, const math::quaternion<T>& y)
{
return mul(x, y);
}
template <class T>
inline quaternion<T> operator*(const quaternion<T>& q, T s)
inline math::quaternion<T> operator*(const math::quaternion<T>& q, T s)
{
return mul(q, s);
}
template <class T>
inline vector<T, 3> operator*(const quaternion<T>& q, const vector<T, 3>& v)
inline math::vector<T, 3> operator*(const math::quaternion<T>& q, const math::vector<T, 3>& v)
{
return mul(q, v);
}
template <class T>
inline quaternion<T> operator-(const quaternion<T>& x, const quaternion<T>& y)
inline math::quaternion<T> operator-(const math::quaternion<T>& x, const math::quaternion<T>& y)
{
return sub(x, y);
}
template <class T, std::size_t N>
inline quaternion<T> operator-(const quaternion<T>& x)
inline math::quaternion<T> operator-(const math::quaternion<T>& x)
{
return negate(x);
}
/// @}
} // namespace quaternion_operators
} // namespace math
/// Bring quaternion operators into global namespace
using namespace math::quaternion_operators;
#endif // ANTKEEPER_MATH_QUATERNION_OPERATORS_HPP

+ 0
- 5
src/math/quaternion-type.hpp View File

@ -22,9 +22,6 @@
namespace math {
/// @addtogroup quaternion
/// @{
/**
* A quaternion type is a tuple made of a scalar (real) part and vector (imaginary) part.
*
@ -40,8 +37,6 @@ struct quaternion
scalar_type z;
};
/// @}
} // namespace math
#endif // ANTKEEPER_MATH_QUATERNION_TYPE_HPP

+ 12
- 26
src/math/stream-operators.hpp View File

@ -25,12 +25,6 @@
#include "math/quaternion-type.hpp"
#include <ostream>
namespace math {
namespace stream_operators {
/// @addtogroup io
/// @{
/**
* Writes the elements of a vector to an output stream, with each element delimeted by a space.
*
@ -39,7 +33,7 @@ namespace stream_operators {
* @return Output stream.
*/
template <class T, std::size_t N>
std::ostream& operator<<(std::ostream& os, const vector<T, N>& v);
std::ostream& operator<<(std::ostream& os, const math::vector<T, N>& v);
/**
* Writes the elements of a matrix to an output stream, with each element delimeted by a space.
@ -49,7 +43,7 @@ std::ostream& operator<<(std::ostream& os, const vector& v);
* @return Output stream.
*/
template <class T, std::size_t N, std::size_t M>
std::ostream& operator<<(std::ostream& os, const matrix<T, N, M>& m);
std::ostream& operator<<(std::ostream& os, const math::matrix<T, N, M>& m);
/**
* Writes the real and imaginary parts of a quaternion to an output stream, with each number delimeted by a space.
@ -59,7 +53,7 @@ std::ostream& operator<<(std::ostream& os, const matrix& m);
* @return Output stream.
*/
template <class T>
std::ostream& operator<<(std::ostream& os, const quaternion<T>& q);
std::ostream& operator<<(std::ostream& os, const math::quaternion<T>& q);
/**
* Reads the elements of a vector from an input stream, with each element delimeted by a space.
@ -69,7 +63,7 @@ std::ostream& operator<<(std::ostream& os, const quaternion& q);
* @return Input stream.
*/
template <class T, std::size_t N>
std::istream& operator>>(std::istream& is, vector<T, N>& v);
std::istream& operator>>(std::istream& is, math::vector<T, N>& v);
/**
* Reads the elements of a matrix from an input stream, with each element delimeted by a space.
@ -79,7 +73,7 @@ std::istream& operator>>(std::istream& is, vector& v);
* @return Input stream.
*/
template <class T, std::size_t N, std::size_t M>
std::istream& operator>>(std::istream& is, matrix<T, N, M>& m);
std::istream& operator>>(std::istream& is, math::matrix<T, N, M>& m);
/**
* Reads the real and imaginary parts of a quaternion from an input stream, with each number delimeted by a space.
@ -89,10 +83,10 @@ std::istream& operator>>(std::istream& is, matrix& m);
* @return Input stream.
*/
template <class T>
std::istream& operator>>(std::istream& is, const quaternion<T>& q);
std::istream& operator>>(std::istream& is, const math::quaternion<T>& q);
template <class T, std::size_t N>
std::ostream& operator<<(std::ostream& os, const vector<T, N>& v)
std::ostream& operator<<(std::ostream& os, const math::vector<T, N>& v)
{
for (std::size_t i = 0; i < N; ++i)
{
@ -108,7 +102,7 @@ std::ostream& operator<<(std::ostream& os, const vector& v)
}
template <class T, std::size_t N, std::size_t M>
std::ostream& operator<<(std::ostream& os, const matrix<T, N, M>& m)
std::ostream& operator<<(std::ostream& os, const math::matrix<T, N, M>& m)
{
for (std::size_t i = 0; i < N; ++i)
{
@ -127,14 +121,14 @@ std::ostream& operator<<(std::ostream& os, const matrix& m)
}
template <class T>
std::ostream& operator<<(std::ostream& os, const quaternion<T>& q)
std::ostream& operator<<(std::ostream& os, const math::quaternion<T>& q)
{
os << q.w << ' ' << q.x << ' ' << q.y << ' ' << q.z;
return os;
}
template <class T, std::size_t N>
std::istream& operator>>(std::istream& is, vector<T, N>& v)
std::istream& operator>>(std::istream& is, math::vector<T, N>& v)
{
for (std::size_t i = 0; i < N; ++i)
is >> v[i];
@ -143,7 +137,7 @@ std::istream& operator>>(std::istream& is, vector& v)
}
template <class T, std::size_t N, std::size_t M>
std::istream& operator>>(std::istream& is, matrix<T, N, M>& m)
std::istream& operator>>(std::istream& is, math::matrix<T, N, M>& m)
{
for (std::size_t i = 0; i < N * M; ++i)
{
@ -156,7 +150,7 @@ std::istream& operator>>(std::istream& is, matrix& m)
}
template <class T>
std::istream& operator>>(std::istream& is, const quaternion<T>& q)
std::istream& operator>>(std::istream& is, const math::quaternion<T>& q)
{
is >> q.w;
is >> q.x;
@ -166,12 +160,4 @@ std::istream& operator>>(std::istream& is, const quaternion& q)
return is;
}
/// @}
} // namespace stream_operators
} // namespace math
// Bring stream operators into global namespace
using namespace math::stream_operators;
#endif // ANTKEEPER_MATH_STREAM_OPERATORS_HPP

+ 0
- 5
src/math/transform-functions.hpp View File

@ -27,9 +27,6 @@
namespace math {
/// @addtogroup transform
/// @{
/**
* Calculates the inverse of a transform.
*
@ -102,8 +99,6 @@ vector mul(const transform& t, const vector& v)
return t.translation + (t.rotation * (v * t.scale));
}
/// @}
} // namespace math
#endif // ANTKEEPER_MATH_TRANSFORM_FUNCTIONS_HPP

+ 8
- 22
src/math/transform-operators.hpp View File

@ -23,19 +23,13 @@
#include "math/transform-type.hpp"
#include "math/transform-functions.hpp"
namespace math {
namespace transform_operators {
/// @addtogroup transform
/// @{
/// @copydoc mul(const transform<T>&, const transform<T>&)
/// @copydoc math::mul(const math::transform<T>&, const math::transform<T>&)
template <class T>
transform<T> operator*(const transform<T>& x, const transform<T>& y);
math::transform<T> operator*(const math::transform<T>& x, const math::transform<T>& y);
/// @copydoc mul(const transform<T>&, const vector<T, 3>&)
/// @copydoc math::mul(const math::transform<T>&, const math::vector<T, 3>&)
template <class T>
vector<T, 3> operator*(const transform<T>& t, const vector<T, 3>& v);
math::vector<T, 3> operator*(const math::transform<T>& t, const math::vector<T, 3>& v);
/**
* Multiplies two transforms and stores the result in the first transform.
@ -45,33 +39,25 @@ vector operator*(const transform& t, const vector& v);
* @return Reference to the first transform.
*/
template <class T>
transform<T>& operator*=(transform<T>& x, const transform<T>& y);
math::transform<T>& operator*=(math::transform<T>& x, const math::transform<T>& y);
template <class T>
inline transform<T> operator*(const transform<T>& x, const transform<T>& y)
inline math::transform<T> operator*(const math::transform<T>& x, const math::transform<T>& y)
{
return mul(x, y);
}
template <class T>
inline vector<T, 3> operator*(const transform<T>& t, const vector<T, 3>& v)
inline math::vector<T, 3> operator*(const math::transform<T>& t, const math::vector<T, 3>& v)
{
return mul(t, v);
}
template <class T>
inline transform<T>& operator*=(transform<T>& x, const vector<T, 3>& y)
inline math::transform<T>& operator*=(math::transform<T>& x, const math::vector<T, 3>& y)
{
return (x = x * y);
}
/// @}
} // namespace transform_operators
} // namespace math
// Bring transform operators into global namespace
using namespace math::transform_operators;
#endif // ANTKEEPER_MATH_TRANSFORM_OPERATORS_HPP

+ 0
- 5
src/math/transform-type.hpp View File

@ -25,9 +25,6 @@
namespace math {
/// @addtogroup transform
/// @{
/**
* Represents 3D TRS transformation.
*
@ -46,8 +43,6 @@ struct transform
vector<T, 3> scale;
};
/// @}
} // namespace math
#endif // ANTKEEPER_MATH_TRANSFORM_TYPE_HPP

+ 0
- 5
src/math/vector-functions.hpp View File

@ -28,9 +28,6 @@
namespace math {
/// @addtogroup vector
/// @{
/**
* Adds two vectors.
*
@ -644,8 +641,6 @@ inline vector type_cast(const vector& v)
return type_cast<T2>(v, std::make_index_sequence<N>{});
}
/// @}
} // namespace math
#endif // ANTKEEPER_MATH_VECTOR_FUNCTIONS_HPP

+ 36
- 50
src/math/vector-operators.hpp View File

@ -23,43 +23,37 @@
#include "math/vector-type.hpp"
#include "math/vector-functions.hpp"
namespace math {
namespace vector_operators {
/// @addtogroup vector
/// @{
/// @copydoc add(const vector<T, N>&, const vector<T, N>&)
/// @copydoc math::add(const math::vector<T, N>&, const math::vector<T, N>&)
template <class T, std::size_t N>
vector<T, N> operator+(const vector<T, N>& x, const vector<T, N>& y);
math::vector<T, N> operator+(const math::vector<T, N>& x, const math::vector<T, N>& y);
/// @copydoc div(const vector<T, N>&, const vector<T, N>&)
/// @copydoc math::div(const math::vector<T, N>&, const math::vector<T, N>&)
template <class T, std::size_t N>
vector<T, N> operator/(const vector<T, N>& x, const vector<T, N>& y);
math::vector<T, N> operator/(const math::vector<T, N>& x, const math::vector<T, N>& y);
/// @copydoc div(const vector<T, N>&, T)
/// @copydoc math::div(const math::vector<T, N>&, T)
template <class T, std::size_t N>
vector<T, N> operator/(const vector<T, N>& v, T s);
math::vector<T, N> operator/(const math::vector<T, N>& v, T s);
/// @copydoc mul(const vector<T, N>&, const vector<T, N>&)
/// @copydoc math::mul(const math::vector<T, N>&, const math::vector<T, N>&)
template <class T, std::size_t N>
vector<T, N> operator*(const vector<T, N>& x, const vector<T, N>& y);
math::vector<T, N> operator*(const math::vector<T, N>& x, const math::vector<T, N>& y);
/// @copydoc mul(const vector<T, N>&, T)
/// @copydoc math::mul(const math::vector<T, N>&, T)
template <class T, std::size_t N>
vector<T, N> operator*(const vector<T, N>& v, T s);
math::vector<T, N> operator*(const math::vector<T, N>& v, T s);
/// @copydoc mul(const vector<T, N>&, T)
/// @copydoc math::mul(const math::vector<T, N>&, T)
template <class T, std::size_t N>
vector<T, N> operator*(T s, const vector<T, N>& v);
math::vector<T, N> operator*(T s, const math::vector<T, N>& v);
/// @copydoc negate(const vector<T, N>&)
/// @copydoc math::negate(const math::vector<T, N>&)
template <class T, std::size_t N>
vector<T, N> operator-(const vector<T, N>& x);
math::vector<T, N> operator-(const math::vector<T, N>& x);
/// @copydoc sub(const vector<T, N>&, const vector<T, N>&)
/// @copydoc math::sub(const math::vector<T, N>&, const math::vector<T, N>&)
template <class T, std::size_t N>
vector<T, N> operator-(const vector<T, N>& x, const vector<T, N>& y);
math::vector<T, N> operator-(const math::vector<T, N>& x, const math::vector<T, N>& y);
/**
* Adds two vectors and stores the result in the first vector.
@ -69,7 +63,7 @@ vector operator-(const vector& x, const vector& y);
* @return Reference to the first vector.
*/
template <class T, std::size_t N>
vector<T, N>& operator+=(vector<T, N>& x, const vector<T, N>& y);
math::vector<T, N>& operator+=(math::vector<T, N>& x, const math::vector<T, N>& y);
/**
* Subtracts two vectors and stores the result in the first vector.
@ -79,7 +73,7 @@ vector& operator+=(vector& x, const vector& y);
* @return Reference to the first vector.
*/
template <class T, std::size_t N>
vector<T, N>& operator-=(vector<T, N>& x, const vector<T, N>& y);
math::vector<T, N>& operator-=(math::vector<T, N>& x, const math::vector<T, N>& y);
/**
* Multiplies two vectors and stores the result in the first vector.
@ -89,7 +83,7 @@ vector& operator-=(vector& x, const vector& y);
* @return Reference to the first vector.
*/
template <class T, std::size_t N>
vector<T, N>& operator*=(vector<T, N>& x, const vector<T, N>& y);
math::vector<T, N>& operator*=(math::vector<T, N>& x, const math::vector<T, N>& y);
/**
* Multiplies a vector and a scalar and stores the result in the vector.
@ -99,7 +93,7 @@ vector& operator*=(vector& x, const vector& y);
* @return Reference to the vector.
*/
template <class T, std::size_t N>
vector<T, N>& operator*=(vector<T, N>& v, T s);
math::vector<T, N>& operator*=(math::vector<T, N>& v, T s);
/**
* Divides the first vector by the second vector the result in the first vector.
@ -109,7 +103,7 @@ vector& operator*=(vector& v, T s);
* @return Reference to the first vector.
*/
template <class T, std::size_t N>
vector<T, N>& operator/=(vector<T, N>& x, const vector<T, N>& y);
math::vector<T, N>& operator/=(math::vector<T, N>& x, const math::vector<T, N>& y);
/**
* Divides a vector by a scalar and stores the result in the vector.
@ -119,99 +113,91 @@ vector& operator/=(vector& x, const vector& y);
* @return Reference to the vector.
*/
template <class T, std::size_t N>
vector<T, N>& operator/=(vector<T, N>& v, T s);
math::vector<T, N>& operator/=(math::vector<T, N>& v, T s);
template <class T, std::size_t N>
inline vector<T, N> operator+(const vector<T, N>& x, const vector<T, N>& y)
inline math::vector<T, N> operator+(const math::vector<T, N>& x, const math::vector<T, N>& y)
{
return add(x, y);
}
template <class T, std::size_t N>
inline vector<T, N> operator-(const vector<T, N>& x)
inline math::vector<T, N> operator-(const math::vector<T, N>& x)
{
return negate(x);
}
template <class T, std::size_t N>
inline vector<T, N> operator-(const vector<T, N>& x, const vector<T, N>& y)
inline math::vector<T, N> operator-(const math::vector<T, N>& x, const math::vector<T, N>& y)
{
return sub(x, y);
}
template <class T, std::size_t N>
inline vector<T, N> operator*(const vector<T, N>& x, const vector<T, N>& y)
inline math::vector<T, N> operator*(const math::vector<T, N>& x, const math::vector<T, N>& y)
{
return mul(x, y);
}
template <class T, std::size_t N>
inline vector<T, N> operator*(const vector<T, N>& v, T s)
inline math::vector<T, N> operator*(const math::vector<T, N>& v, T s)
{
return mul(v, s);
}
template <class T, std::size_t N>
inline vector<T, N> operator*(T s, const vector<T, N>& v)
inline math::vector<T, N> operator*(T s, const math::vector<T, N>& v)
{
return mul(v, s);
}
template <class T, std::size_t N>
inline vector<T, N> operator/(const vector<T, N>& x, const vector<T, N>& y)
inline math::vector<T, N> operator/(const math::vector<T, N>& x, const math::vector<T, N>& y)
{
return div(x, y);
}
template <class T, std::size_t N>
inline vector<T, N> operator/(const vector<T, N>& v, T s)
inline math::vector<T, N> operator/(const math::vector<T, N>& v, T s)
{
return div(v, s);
}
template <class T, std::size_t N>
inline vector<T, N>& operator+=(vector<T, N>& x, const vector<T, N>& y)
inline math::vector<T, N>& operator+=(math::vector<T, N>& x, const math::vector<T, N>& y)
{
return (x = x + y);
}
template <class T, std::size_t N>
inline vector<T, N>& operator-=(vector<T, N>& x, const vector<T, N>& y)
inline math::vector<T, N>& operator-=(math::vector<T, N>& x, const math::vector<T, N>& y)
{
return (x = x - y);
}
template <class T, std::size_t N>
inline vector<T, N>& operator*=(vector<T, N>& x, const vector<T, N>& y)
inline math::vector<T, N>& operator*=(math::vector<T, N>& x, const math::vector<T, N>& y)
{
return (x = x * y);
}
template <class T, std::size_t N>
inline vector<T, N>& operator*=(vector<T, N>& v, T s)
inline math::vector<T, N>& operator*=(math::vector<T, N>& v, T s)
{
return (v = v * s);
}
template <class T, std::size_t N>
inline vector<T, N>& operator/=(vector<T, N>& x, const vector<T, N>& y)
inline math::vector<T, N>& operator/=(math::vector<T, N>& x, const math::vector<T, N>& y)
{
return (x = x * y);
}
template <class T, std::size_t N>
inline vector<T, N>& operator/=(vector<T, N>& v, T s)
inline math::vector<T, N>& operator/=(math::vector<T, N>& v, T s)
{
return (v = v / s);
}
/// @}
} // namespace vector_operators
} // namespace math
// Bring vector operators into global namespace
using namespace math::vector_operators;
#endif // ANTKEEPER_MATH_VECTOR_OPERATORS_HPP

+ 0
- 7
src/math/vector-type.hpp View File

@ -25,9 +25,6 @@
namespace math {
/// @addtogroup vector
/// @{
/**
* An `N`-dimensional Euclidean vector.
*
@ -121,10 +118,6 @@ struct vector
inline constexpr std::size_t size() const noexcept { return 4; };
};
static_assert(std::is_trivial<vector<float, 4>>::value);
/// @}
} // namespace math
#endif // ANTKEEPER_MATH_VECTOR_TYPE_HPP

Loading…
Cancel
Save