Merge pull request #59075 from aaronfranke/cs-slerp-doc-xml-and-test

Fix Slerp C# docs and add test cases for vectors in the same direction
This commit is contained in:
Rémi Verschelde 2022-03-12 21:09:46 +01:00 committed by GitHub
commit 5959d38c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 4 deletions

View File

@ -511,8 +511,9 @@ namespace Godot
/// Returns the result of the spherical linear interpolation between /// Returns the result of the spherical linear interpolation between
/// this vector and <paramref name="to"/> by amount <paramref name="weight"/>. /// this vector and <paramref name="to"/> by amount <paramref name="weight"/>.
/// ///
/// This method also handles interpolating the lengths if the input vectors have different lengths. /// This method also handles interpolating the lengths if the input vectors
/// For the special case of one or both input vectors having zero length, this method behaves like [method lerp]. /// have different lengths. For the special case of one or both input vectors
/// having zero length, this method behaves like <see cref="Lerp"/>.
/// </summary> /// </summary>
/// <param name="to">The destination vector for interpolation.</param> /// <param name="to">The destination vector for interpolation.</param>
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param> /// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>

View File

@ -551,8 +551,9 @@ namespace Godot
/// Returns the result of the spherical linear interpolation between /// Returns the result of the spherical linear interpolation between
/// this vector and <paramref name="to"/> by amount <paramref name="weight"/>. /// this vector and <paramref name="to"/> by amount <paramref name="weight"/>.
/// ///
/// This method also handles interpolating the lengths if the input vectors have different lengths. /// This method also handles interpolating the lengths if the input vectors
/// For the special case of one or both input vectors having zero length, this method behaves like [method lerp]. /// have different lengths. For the special case of one or both input vectors
/// having zero length, this method behaves like <see cref="Lerp"/>.
/// </summary> /// </summary>
/// <param name="to">The destination vector for interpolation.</param> /// <param name="to">The destination vector for interpolation.</param>
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param> /// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>

View File

@ -89,6 +89,9 @@ TEST_CASE("[Vector2] Interpolation methods") {
CHECK_MESSAGE( CHECK_MESSAGE(
Vector2(5, 0).slerp(Vector2(0, 5), 0.5).is_equal_approx(Vector2(5, 5) * Math_SQRT12), Vector2(5, 0).slerp(Vector2(0, 5), 0.5).is_equal_approx(Vector2(5, 5) * Math_SQRT12),
"Vector2 slerp with non-normalized values should work as expected."); "Vector2 slerp with non-normalized values should work as expected.");
CHECK_MESSAGE(
Vector2(1, 1).slerp(Vector2(2, 2), 0.5).is_equal_approx(Vector2(1.5, 1.5)),
"Vector2 slerp with colinear inputs should behave as expected.");
CHECK_MESSAGE( CHECK_MESSAGE(
Vector2().slerp(Vector2(), 0.5) == Vector2(), Vector2().slerp(Vector2(), 0.5) == Vector2(),
"Vector2 slerp with both inputs as zero vectors should return a zero vector."); "Vector2 slerp with both inputs as zero vectors should return a zero vector.");

View File

@ -110,6 +110,9 @@ TEST_CASE("[Vector3] Interpolation methods") {
CHECK_MESSAGE( CHECK_MESSAGE(
Vector3(5, 0, 0).slerp(Vector3(0, 3, 4), 0.5).is_equal_approx(Vector3(3.535533905029296875, 2.121320486068725586, 2.828427314758300781)), Vector3(5, 0, 0).slerp(Vector3(0, 3, 4), 0.5).is_equal_approx(Vector3(3.535533905029296875, 2.121320486068725586, 2.828427314758300781)),
"Vector3 slerp with non-normalized values should work as expected."); "Vector3 slerp with non-normalized values should work as expected.");
CHECK_MESSAGE(
Vector3(1, 1, 1).slerp(Vector3(2, 2, 2), 0.5).is_equal_approx(Vector3(1.5, 1.5, 1.5)),
"Vector3 slerp with colinear inputs should behave as expected.");
CHECK_MESSAGE( CHECK_MESSAGE(
Vector3().slerp(Vector3(), 0.5) == Vector3(), Vector3().slerp(Vector3(), 0.5) == Vector3(),
"Vector3 slerp with both inputs as zero vectors should return a zero vector."); "Vector3 slerp with both inputs as zero vectors should return a zero vector.");