diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2020-09-27 08:46:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-27 08:46:37 +0200 |
| commit | fc481db1c3187688d54b5afdb7a1ebb3e4d506c2 (patch) | |
| tree | ac67cf34523b93a7747aa2676154693128d5a348 /core/math/basis.cpp | |
| parent | 68e4454c31278fc44cc1ce42a7405a9acf42a38f (diff) | |
| parent | 9394c057b871d1e52ae8995a56948dfae0f5583e (diff) | |
| download | redot-engine-fc481db1c3187688d54b5afdb7a1ebb3e4d506c2.tar.gz | |
Merge pull request #37403 from aaronfranke/basis_equal_approx
Change Basis is_equal_approx to use instance method
Diffstat (limited to 'core/math/basis.cpp')
| -rw-r--r-- | core/math/basis.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/core/math/basis.cpp b/core/math/basis.cpp index dd38e25bb1..a712ae7e3e 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -113,19 +113,22 @@ bool Basis::is_rotation() const { return Math::is_equal_approx(determinant(), 1, UNIT_EPSILON) && is_orthogonal(); } +#ifdef MATH_CHECKS +// This method is only used once, in diagonalize. If it's desired elsewhere, feel free to remove the #ifdef. bool Basis::is_symmetric() const { - if (!Math::is_equal_approx_ratio(elements[0][1], elements[1][0], UNIT_EPSILON)) { + if (!Math::is_equal_approx(elements[0][1], elements[1][0])) { return false; } - if (!Math::is_equal_approx_ratio(elements[0][2], elements[2][0], UNIT_EPSILON)) { + if (!Math::is_equal_approx(elements[0][2], elements[2][0])) { return false; } - if (!Math::is_equal_approx_ratio(elements[1][2], elements[2][1], UNIT_EPSILON)) { + if (!Math::is_equal_approx(elements[1][2], elements[2][1])) { return false; } return true; } +#endif Basis Basis::diagonalize() { //NOTE: only implemented for symmetric matrices @@ -737,18 +740,6 @@ bool Basis::is_equal_approx(const Basis &p_basis) const { return elements[0].is_equal_approx(p_basis.elements[0]) && elements[1].is_equal_approx(p_basis.elements[1]) && elements[2].is_equal_approx(p_basis.elements[2]); } -bool Basis::is_equal_approx_ratio(const Basis &a, const Basis &b, real_t p_epsilon) const { - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - if (!Math::is_equal_approx_ratio(a.elements[i][j], b.elements[i][j], p_epsilon)) { - return false; - } - } - } - - return true; -} - bool Basis::operator==(const Basis &p_matrix) const { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { |
