Basis.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #ifndef BASIS_H
  2. #define BASIS_H
  3. #if defined(_WIN32)
  4. # ifdef _GD_CPP_CORE_API_IMPL
  5. # define GD_CPP_CORE_API __declspec(dllexport)
  6. # else
  7. # define GD_CPP_CORE_API __declspec(dllimport)
  8. # endif
  9. #else
  10. # define GD_CPP_CORE_API
  11. #endif
  12. #include "Defs.hpp"
  13. #include "Vector3.hpp"
  14. namespace godot {
  15. class Quat;
  16. class GD_CPP_CORE_API Basis {
  17. public:
  18. Vector3 elements[3];
  19. Basis(const Quat& p_quat); // euler
  20. Basis(const Vector3& p_euler); // euler
  21. Basis(const Vector3& p_axis, real_t p_phi);
  22. Basis(const Vector3& row0, const Vector3& row1, const Vector3& row2);
  23. Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz);
  24. Basis();
  25. const Vector3& operator[](int axis) const;
  26. Vector3& operator[](int axis);
  27. void invert();
  28. bool isequal_approx(const Basis& a, const Basis& b) const;
  29. bool is_orthogonal() const;
  30. bool is_rotation() const;
  31. void transpose();
  32. Basis inverse() const;
  33. Basis transposed() const;
  34. real_t determinant() const;
  35. Vector3 get_axis(int p_axis) const;
  36. void set_axis(int p_axis, const Vector3& p_value);
  37. void rotate(const Vector3& p_axis, real_t p_phi);
  38. Basis rotated(const Vector3& p_axis, real_t p_phi) const;
  39. void scale( const Vector3& p_scale );
  40. Basis scaled( const Vector3& p_scale ) const;
  41. Vector3 get_scale() const;
  42. Vector3 get_euler() const;
  43. void set_euler(const Vector3& p_euler);
  44. // transposed dot products
  45. real_t tdotx(const Vector3& v) const;
  46. real_t tdoty(const Vector3& v) const;
  47. real_t tdotz(const Vector3& v) const;
  48. bool operator==(const Basis& p_matrix) const;
  49. bool operator!=(const Basis& p_matrix) const;
  50. Vector3 xform(const Vector3& p_vector) const;
  51. Vector3 xform_inv(const Vector3& p_vector) const;
  52. void operator*=(const Basis& p_matrix);
  53. Basis operator*(const Basis& p_matrix) const;
  54. void operator+=(const Basis& p_matrix);
  55. Basis operator+(const Basis& p_matrix) const;
  56. void operator-=(const Basis& p_matrix);
  57. Basis operator-(const Basis& p_matrix) const;
  58. void operator*=(real_t p_val);
  59. Basis operator*(real_t p_val) const;
  60. int get_orthogonal_index() const; // down below
  61. void set_orthogonal_index(int p_index); // down below
  62. operator String() const;
  63. void get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const;
  64. /* create / set */
  65. void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz);
  66. Vector3 get_column(int i) const;
  67. Vector3 get_row(int i) const;
  68. Vector3 get_main_diagonal() const;
  69. void set_row(int i, const Vector3& p_row);
  70. Basis transpose_xform(const Basis& m) const;
  71. void orthonormalize();
  72. Basis orthonormalized() const;
  73. bool is_symmetric() const;
  74. Basis diagonalize();
  75. operator Quat() const;
  76. };
  77. }
  78. #endif // BASIS_H