💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.0 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_MATH_QUATERNION_OPERATORS_HPP
  20. #define ANTKEEPER_MATH_QUATERNION_OPERATORS_HPP
  21. #include "math/quaternion-type.hpp"
  22. #include "math/quaternion-functions.hpp"
  23. /// @copydoc math::add(const math::quaternion<T>&, const math::quaternion<T>&)
  24. template <class T>
  25. math::quaternion<T> operator+(const math::quaternion<T>& x, const math::quaternion<T>& y);
  26. /// @copydoc math::div(const math::quaternion<T>&, T)
  27. template <class T>
  28. math::quaternion<T> operator/(const math::quaternion<T>& q, T s);
  29. /// @copydoc math::mul(const math::quaternion<T>&, const math::quaternion<T>&)
  30. template <class T>
  31. math::quaternion<T> operator*(const math::quaternion<T>& x, const math::quaternion<T>& y);
  32. /// @copydoc math::mul(const math::quaternion<T>&, T)
  33. template <class T>
  34. math::quaternion<T> operator*(const math::quaternion<T>& q, T s);
  35. /// @copydoc math::mul(const math::quaternion<T>&, const math::vector<T, 3>&)
  36. template <class T>
  37. math::vector<T, 3> operator*(const math::quaternion<T>& q, const math::vector<T, 3>& v);
  38. /// @copydoc math::sub(const math::quaternion<T>&, const math::quaternion<T>&)
  39. template <class T>
  40. math::quaternion<T> operator-(const math::quaternion<T>& x, const math::quaternion<T>& y);
  41. /// @copydoc math::negate(const math::quaternion<T>&)
  42. template <class T, std::size_t N>
  43. math::quaternion<T> operator-(const math::quaternion<T>& x);
  44. template <class T>
  45. inline math::quaternion<T> operator+(const math::quaternion<T>& x, const math::quaternion<T>& y)
  46. {
  47. return add(x, y);
  48. }
  49. template <class T>
  50. inline math::quaternion<T> operator/(const math::quaternion<T>& q, T s)
  51. {
  52. return div(q, s);
  53. }
  54. template <class T>
  55. inline math::quaternion<T> operator*(const math::quaternion<T>& x, const math::quaternion<T>& y)
  56. {
  57. return mul(x, y);
  58. }
  59. template <class T>
  60. inline math::quaternion<T> operator*(const math::quaternion<T>& q, T s)
  61. {
  62. return mul(q, s);
  63. }
  64. template <class T>
  65. inline math::vector<T, 3> operator*(const math::quaternion<T>& q, const math::vector<T, 3>& v)
  66. {
  67. return mul(q, v);
  68. }
  69. template <class T>
  70. inline math::quaternion<T> operator-(const math::quaternion<T>& x, const math::quaternion<T>& y)
  71. {
  72. return sub(x, y);
  73. }
  74. template <class T, std::size_t N>
  75. inline math::quaternion<T> operator-(const math::quaternion<T>& x)
  76. {
  77. return negate(x);
  78. }
  79. #endif // ANTKEEPER_MATH_QUATERNION_OPERATORS_HPP