Quat.hpp 1.8 KB

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