Quaternion.h 920 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef CORE_QUATERNION_H
  2. #define CORE_QUATERNION_H
  3. #include "math/Vector.h"
  4. #include "utils/ArrayString.h"
  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. // returns true on error and calls the error callback
  17. template<int L>
  18. check_return bool toString(ArrayString<L>& s) const {
  19. return s.append("(") || s.append(xyz[0]) || s.append(" i + ") ||
  20. s.append(xyz[1]) || s.append(" j + ") || s.append(xyz[2]) ||
  21. s.append(" k + ") || s.append(w) || s.append(')');
  22. }
  23. };
  24. }
  25. #endif