diff options
author | Ferenc Arn <tagcup@yahoo.com> | 2017-10-09 20:51:45 -0400 |
---|---|---|
committer | Ferenc Arn <tagcup@yahoo.com> | 2017-10-11 16:56:47 -0400 |
commit | 8861cc40fa79acd131875a556a8cf528384858ee (patch) | |
tree | cce2164234d59e26f7e5ed504eff71561c05054c | |
parent | 18d3ba0c50ac073a4588388a6bdc71cfee44ea1f (diff) |
Added Basis::get_quat() and set_quat().
-rw-r--r-- | core/math/matrix3.cpp | 13 | ||||
-rw-r--r-- | core/math/matrix3.h | 15 |
2 files changed, 11 insertions, 17 deletions
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index 4051de7afb..85421c074b 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -538,7 +538,7 @@ Basis::operator String() const { return mtx; } -Basis::operator Quat() const { +Quat Basis::get_quat() const { //commenting this check because precision issues cause it to fail when it shouldn't //#ifdef MATH_CHECKS //ERR_FAIL_COND_V(is_rotation() == false, Quat()); @@ -710,12 +710,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { r_angle = angle; } -Basis::Basis(const Vector3 &p_euler) { - - set_euler(p_euler); -} - -Basis::Basis(const Quat &p_quat) { +void Basis::set_quat(const Quat &p_quat) { real_t d = p_quat.length_squared(); real_t s = 2.0 / d; @@ -750,7 +745,3 @@ void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) { elements[2][1] = p_axis.y * p_axis.z * (1.0 - cosine) + p_axis.x * sine; elements[2][2] = axis_sq.z + cosine * (1.0 - axis_sq.z); } - -Basis::Basis(const Vector3 &p_axis, real_t p_phi) { - set_axis_angle(p_axis, p_phi); -} diff --git a/core/math/matrix3.h b/core/math/matrix3.h index 23429888e0..9a33b8203d 100644 --- a/core/math/matrix3.h +++ b/core/math/matrix3.h @@ -88,8 +88,11 @@ public: Vector3 get_euler_yxz() const; void set_euler_yxz(const Vector3 &p_euler); - Vector3 get_euler() const { return get_euler_yxz(); }; - void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }; + Quat get_quat() const; + void set_quat(const Quat &p_quat); + + Vector3 get_euler() const { return get_euler_yxz(); } + void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); } void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const; void set_axis_angle(const Vector3 &p_axis, real_t p_phi); @@ -205,11 +208,11 @@ public: bool is_symmetric() const; Basis diagonalize(); - operator Quat() const; + operator Quat() const { return get_quat(); } - Basis(const Quat &p_quat); // euler - Basis(const Vector3 &p_euler); // euler - Basis(const Vector3 &p_axis, real_t p_phi); + Basis(const Quat &p_quat) { set_quat(p_quat); }; + Basis(const Vector3 &p_euler) { set_euler(p_euler); } + Basis(const Vector3 &p_axis, real_t p_phi) { set_axis_angle(p_axis, p_phi); } _FORCE_INLINE_ Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) { elements[0] = row0; |