Performs a spherical linear interpolation between two vectors.
| 560 | |
| 561 | // Performs a spherical linear interpolation between two vectors. |
| 562 | static void Slerp(const Vector2Base& start, const Vector2Base& end, T amount, Vector2Base& result) |
| 563 | { |
| 564 | T dot = Math::Clamp(Dot(start, end), -1.0f, 1.0f); |
| 565 | T theta = Math::Acos(dot) * amount; |
| 566 | Vector2Base relativeVector = end - start * dot; |
| 567 | relativeVector.Normalize(); |
| 568 | result = ((start * Math::Cos(theta)) + (relativeVector * Math::Sin(theta))); |
| 569 | } |
| 570 | |
| 571 | // Performs a spherical linear interpolation between two vectors. |
| 572 | static Vector2Base Slerp(const Vector2Base& start, const Vector2Base& end, T amount) |