diff options
| author | Rémi Verschelde | 2018-05-16 23:24:56 +0200 |
|---|---|---|
| committer | GitHub | 2018-05-16 23:24:56 +0200 |
| commit | 36a74696d6751957c1d345ed1c7633d8b68ba827 (patch) | |
| tree | 73ca2106917b826f93de8d5048b07db982f6cb79 /core/math/math_2d.h | |
| parent | 2cf36651b968e99602445678e1fa6ea0adfc078a (diff) | |
| parent | ed7aadcd87a64cde70febc8ee313860e8c67dcaf (diff) | |
| download | godot-36a74696d6751957c1d345ed1c7633d8b68ba827.tar.gz godot-36a74696d6751957c1d345ed1c7633d8b68ba827.tar.zst godot-36a74696d6751957c1d345ed1c7633d8b68ba827.zip | |
Diffstat (limited to 'core/math/math_2d.h')
| -rw-r--r-- | core/math/math_2d.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 611d47e3f..25c39e5d7 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -112,6 +112,7 @@ struct Vector2 { _FORCE_INLINE_ static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t); _FORCE_INLINE_ Vector2 linear_interpolate(const Vector2 &p_b, real_t p_t) const; + _FORCE_INLINE_ Vector2 slerp(const Vector2 &p_b, real_t p_t) const; Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; Vector2 slide(const Vector2 &p_normal) const; @@ -263,6 +264,14 @@ Vector2 Vector2::linear_interpolate(const Vector2 &p_b, real_t p_t) const { return res; } +Vector2 Vector2::slerp(const Vector2 &p_b, real_t p_t) const { +#ifdef MATH_CHECKS + ERR_FAIL_COND_V(is_normalized() == false, Vector2()); +#endif + real_t theta = angle_to(p_b); + return rotated(theta * p_t); +} + Vector2 Vector2::linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t) { Vector2 res = p_a; |
