Quat.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef QUAT_H
  2. #define QUAT_H
  3. #include <cmath>
  4. #include "Vector3.hpp"
  5. // #include "Basis.h"
  6. namespace godot {
  7. class Quat {
  8. public:
  9. real_t x, y, z, w;
  10. real_t length_squared() const;
  11. real_t length() const;
  12. void normalize();
  13. Quat normalized() const;
  14. bool is_normalized() const;
  15. Quat inverse() const;
  16. void set_euler_xyz(const Vector3 &p_euler);
  17. Vector3 get_euler_xyz() const;
  18. void set_euler_yxz(const Vector3 &p_euler);
  19. Vector3 get_euler_yxz() const;
  20. inline void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }
  21. inline Vector3 get_euler() const { return get_euler_yxz(); }
  22. real_t dot(const Quat &q) const;
  23. Quat slerp(const Quat &q, const real_t &t) const;
  24. Quat slerpni(const Quat &q, const real_t &t) const;
  25. Quat cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const;
  26. void get_axis_and_angle(Vector3 &r_axis, real_t &r_angle) const;
  27. void set_axis_angle(const Vector3 &axis, const float angle);
  28. void operator*=(const Quat &q);
  29. Quat operator*(const Quat &q) const;
  30. Quat operator*(const Vector3 &v) const;
  31. Vector3 xform(const Vector3 &v) const;
  32. void operator+=(const Quat &q);
  33. void operator-=(const Quat &q);
  34. void operator*=(const real_t &s);
  35. void operator/=(const real_t &s);
  36. Quat operator+(const Quat &q2) const;
  37. Quat operator-(const Quat &q2) const;
  38. Quat operator-() const;
  39. Quat operator*(const real_t &s) const;
  40. Quat operator/(const real_t &s) const;
  41. bool operator==(const Quat &p_quat) const;
  42. bool operator!=(const Quat &p_quat) const;
  43. operator String() const;
  44. inline void set(real_t p_x, real_t p_y, real_t p_z, real_t p_w) {
  45. x = p_x;
  46. y = p_y;
  47. z = p_z;
  48. w = p_w;
  49. }
  50. inline Quat(real_t p_x, real_t p_y, real_t p_z, real_t p_w) {
  51. x = p_x;
  52. y = p_y;
  53. z = p_z;
  54. w = p_w;
  55. }
  56. Quat(const Vector3 &axis, const real_t &angle);
  57. Quat(const Vector3 &v0, const Vector3 &v1);
  58. inline Quat() {
  59. x = y = z = 0;
  60. w = 1;
  61. }
  62. };
  63. } // namespace godot
  64. #endif // QUAT_H