Quaternion.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef CORE_QUATERNION_HPP
  2. #define CORE_QUATERNION_HPP
  3. #include "math/Vector.hpp"
  4. #include "utils/ArrayString.hpp"
  5. namespace Core {
  6. class Quaternion final {
  7. Vector3 xyz;
  8. float w;
  9. public:
  10. Quaternion();
  11. Quaternion(const Vector3& axis, float angle);
  12. Quaternion lerp(float f, const Quaternion& other) const;
  13. Quaternion& operator*=(const Quaternion& other);
  14. Quaternion operator*(const Quaternion& other) const;
  15. Vector3 operator*(const Vector3& v) const;
  16. template<typename String>
  17. check_return Error toString(String& s) const {
  18. CORE_RETURN_ERROR(s.append("("));
  19. CORE_RETURN_ERROR(s.append(xyz[0]));
  20. CORE_RETURN_ERROR(s.append(" i + "));
  21. CORE_RETURN_ERROR(s.append(xyz[1]));
  22. CORE_RETURN_ERROR(s.append(" j + "));
  23. CORE_RETURN_ERROR(s.append(xyz[2]));
  24. CORE_RETURN_ERROR(s.append(" k + "));
  25. CORE_RETURN_ERROR(s.append(w));
  26. CORE_RETURN_ERROR(s.append(')'));
  27. return Error::NONE;
  28. }
  29. };
  30. }
  31. #endif