Quaternion.h 711 B

123456789101112131415161718192021222324252627282930
  1. #ifndef QUATERNION_H
  2. #define QUATERNION_H
  3. #include "math/Vector.h"
  4. #include "utils/StringBuffer.h"
  5. class Quaternion {
  6. Vector3 xyz;
  7. float w;
  8. public:
  9. Quaternion();
  10. Quaternion(const Vector3& axis, float angle);
  11. Quaternion lerp(float f, const Quaternion& other) const;
  12. Quaternion& operator*=(const Quaternion& other);
  13. Quaternion operator*(const Quaternion& other) const;
  14. Vector3 operator*(const Vector3& v) const;
  15. template<int L>
  16. void toString(StringBuffer<L>& s) const {
  17. s.append("(");
  18. s.append(xyz[0]).append(" i + ");
  19. s.append(xyz[1]).append(" j + ");
  20. s.append(xyz[2]).append(" k + ");
  21. s.append(w).append(')');
  22. }
  23. };
  24. #endif