diff options
| author | tagcup | 2018-05-11 20:14:39 -0400 |
|---|---|---|
| committer | tagcup | 2018-05-12 13:05:04 -0400 |
| commit | ed7aadcd87a64cde70febc8ee313860e8c67dcaf (patch) | |
| tree | 1c9a682a33463feff010a436caf852d4ad4fdcde /core/math/vector3.h | |
| parent | 81b1d3c846de263cf843e9e0e9d7c0c0a94f65c8 (diff) | |
| download | godot-ed7aadcd87a64cde70febc8ee313860e8c67dcaf.tar.gz godot-ed7aadcd87a64cde70febc8ee313860e8c67dcaf.tar.zst godot-ed7aadcd87a64cde70febc8ee313860e8c67dcaf.zip | |
Diffstat (limited to 'core/math/vector3.h')
| -rw-r--r-- | core/math/vector3.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h index 3bbfd7627..433adf09e 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -91,6 +91,7 @@ struct Vector3 { /* Static Methods between 2 vector3s */ _FORCE_INLINE_ Vector3 linear_interpolate(const Vector3 &p_b, real_t p_t) const; + _FORCE_INLINE_ Vector3 slerp(const Vector3 &p_b, real_t p_t) const; Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const; Vector3 cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const; @@ -218,6 +219,15 @@ Vector3 Vector3::linear_interpolate(const Vector3 &p_b, real_t p_t) const { z + (p_t * (p_b.z - z))); } +Vector3 Vector3::slerp(const Vector3 &p_b, real_t p_t) const { +#ifdef MATH_CHECKS + ERR_FAIL_COND_V(is_normalized() == false, Vector3()); +#endif + + real_t theta = angle_to(p_b); + return rotated(cross(p_b), theta * p_t); +} + real_t Vector3::distance_to(const Vector3 &p_b) const { return (p_b - *this).length(); |
