Fix C++ Vector3::Angle to return value in degrees just like C# API (instead of radians)

This commit is contained in:
Wojtek Figat
2024-10-29 20:36:01 +01:00
parent 41a0ccb218
commit 072f7c7e45
2 changed files with 4 additions and 4 deletions

View File

@@ -321,7 +321,7 @@ float Float3::Angle(const Float3& from, const Float3& to)
const float dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0f, 1.0f);
if (Math::Abs(dot) > 1.0f - ZeroTolerance)
return dot > 0.0f ? 0.0f : PI;
return Math::Acos(dot);
return Math::Acos(dot) * RadiansToDegrees;
}
template<>
@@ -649,7 +649,7 @@ double Double3::Angle(const Double3& from, const Double3& to)
const double dot = Math::Clamp(Dot(Normalize(from), Normalize(to)), -1.0, 1.0);
if (Math::Abs(dot) > 1.0 - ZeroTolerance)
return dot > 0.0 ? 0.0 : PI;
return Math::Acos(dot);
return Math::Acos(dot) * RadiansToDegrees;
}
template<>

View File

@@ -812,11 +812,11 @@ public:
static FLAXENGINE_API T TriangleArea(const Vector3Base& v0, const Vector3Base& v1, const Vector3Base& v2);
/// <summary>
/// Calculates the angle (in radians) between from and to. This is always the smallest value.
/// Calculates the angle (in degrees) between from and to. This is always the smallest value.
/// </summary>
/// <param name="from">The first vector.</param>
/// <param name="to">The second vector.</param>
/// <returns>The angle (in radians).</returns>
/// <returns>The angle (in degrees).</returns>
static FLAXENGINE_API T Angle(const Vector3Base& from, const Vector3Base& to);
/// <summary>