diff options
Diffstat (limited to 'core/math/vector3.h')
| -rw-r--r-- | core/math/vector3.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h index fc02e66c3..951380e89 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -75,6 +75,7 @@ struct Vector3 { _FORCE_INLINE_ void normalize(); _FORCE_INLINE_ Vector3 normalized() const; + _FORCE_INLINE_ bool is_normalized() const; _FORCE_INLINE_ Vector3 inverse() const; _FORCE_INLINE_ void zero(); @@ -214,7 +215,7 @@ real_t Vector3::distance_squared_to(const Vector3 &p_b) const { real_t Vector3::angle_to(const Vector3 &p_b) const { - return Math::acos(this->dot(p_b) / Math::sqrt(this->length_squared() * p_b.length_squared())); + return Math::atan2(cross(p_b).length(), dot(p_b)); } /* Operators */ @@ -385,6 +386,10 @@ Vector3 Vector3::normalized() const { return v; } +bool Vector3::is_normalized() const { + return Math::isequal_approx(length(), (real_t)1.0); +} + Vector3 Vector3::inverse() const { return Vector3(1.0 / x, 1.0 / y, 1.0 / z); |
