Quat.hpp 2.0 KB

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