/**************************************************************************/ /* basis.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "basis.h" #include "core/math/math_funcs.h" #include "core/string/ustring.h" #define cofac(row1, col1, row2, col2) … void Basis::invert() { … } void Basis::orthonormalize() { … } Basis Basis::orthonormalized() const { … } void Basis::orthogonalize() { … } Basis Basis::orthogonalized() const { … } // Returns true if the basis vectors are orthogonal (perpendicular), so it has no skew or shear, and can be decomposed into rotation and scale. // See https://en.wikipedia.org/wiki/Orthogonal_basis bool Basis::is_orthogonal() const { … } // Returns true if the basis vectors are orthonormal (orthogonal and normalized), so it has no scale, skew, or shear. // See https://en.wikipedia.org/wiki/Orthonormal_basis bool Basis::is_orthonormal() const { … } // Returns true if the basis is conformal (orthogonal, uniform scale, preserves angles and distance ratios). // See https://en.wikipedia.org/wiki/Conformal_linear_transformation bool Basis::is_conformal() const { … } // Returns true if the basis only has diagonal elements, so it may only have scale or flip, but no rotation, skew, or shear. bool Basis::is_diagonal() const { … } // Returns true if the basis is a pure rotation matrix, so it has no scale, skew, shear, or flip. bool Basis::is_rotation() const { … } #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 { … } #endif Basis Basis::diagonalize() { … } Basis Basis::inverse() const { … } void Basis::transpose() { … } Basis Basis::transposed() const { … } Basis Basis::from_scale(const Vector3 &p_scale) { … } // Multiplies the matrix from left by the scaling matrix: M -> S.M // See the comment for Basis::rotated for further explanation. void Basis::scale(const Vector3 &p_scale) { … } Basis Basis::scaled(const Vector3 &p_scale) const { … } void Basis::scale_local(const Vector3 &p_scale) { … } void Basis::scale_orthogonal(const Vector3 &p_scale) { … } Basis Basis::scaled_orthogonal(const Vector3 &p_scale) const { … } real_t Basis::get_uniform_scale() const { … } Basis Basis::scaled_local(const Vector3 &p_scale) const { … } Vector3 Basis::get_scale_abs() const { … } Vector3 Basis::get_scale_global() const { … } // get_scale works with get_rotation, use get_scale_abs if you need to enforce positive signature. Vector3 Basis::get_scale() const { … } // Decomposes a Basis into a rotation-reflection matrix (an element of the group O(3)) and a positive scaling matrix as B = O.S. // Returns the rotation-reflection matrix via reference argument, and scaling information is returned as a Vector3. // This (internal) function is too specific and named too ugly to expose to users, and probably there's no need to do so. Vector3 Basis::rotref_posscale_decomposition(Basis &rotref) const { … } // Multiplies the matrix from left by the rotation matrix: M -> R.M // Note that this does *not* rotate the matrix itself. // // The main use of Basis is as Transform.basis, which is used by the transformation matrix // of 3D object. Rotate here refers to rotation of the object (which is R * (*this)), // not the matrix itself (which is R * (*this) * R.transposed()). Basis Basis::rotated(const Vector3 &p_axis, real_t p_angle) const { … } void Basis::rotate(const Vector3 &p_axis, real_t p_angle) { … } void Basis::rotate_local(const Vector3 &p_axis, real_t p_angle) { … } Basis Basis::rotated_local(const Vector3 &p_axis, real_t p_angle) const { … } Basis Basis::rotated(const Vector3 &p_euler, EulerOrder p_order) const { … } void Basis::rotate(const Vector3 &p_euler, EulerOrder p_order) { … } Basis Basis::rotated(const Quaternion &p_quaternion) const { … } void Basis::rotate(const Quaternion &p_quaternion) { … } Vector3 Basis::get_euler_normalized(EulerOrder p_order) const { … } Quaternion Basis::get_rotation_quaternion() const { … } void Basis::rotate_to_align(Vector3 p_start_direction, Vector3 p_end_direction) { … } void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const { … } void Basis::get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) const { … } Vector3 Basis::get_euler(EulerOrder p_order) const { … } void Basis::set_euler(const Vector3 &p_euler, EulerOrder p_order) { … } bool Basis::is_equal_approx(const Basis &p_basis) const { … } bool Basis::is_finite() const { … } bool Basis::operator==(const Basis &p_matrix) const { … } bool Basis::operator!=(const Basis &p_matrix) const { … } operator String() Quaternion Basis::get_quaternion() const { … } void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { … } void Basis::set_quaternion(const Quaternion &p_quaternion) { … } void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_angle) { … } void Basis::set_axis_angle_scale(const Vector3 &p_axis, real_t p_angle, const Vector3 &p_scale) { … } void Basis::set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale, EulerOrder p_order) { … } void Basis::set_quaternion_scale(const Quaternion &p_quaternion, const Vector3 &p_scale) { … } // This also sets the non-diagonal elements to 0, which is misleading from the // name, so we want this method to be private. Use `from_scale` externally. void Basis::_set_diagonal(const Vector3 &p_diag) { … } Basis Basis::lerp(const Basis &p_to, real_t p_weight) const { … } Basis Basis::slerp(const Basis &p_to, real_t p_weight) const { … } void Basis::rotate_sh(real_t *p_values) { … } Basis Basis::looking_at(const Vector3 &p_target, const Vector3 &p_up, bool p_use_model_front) { … }