From 072f7c7e45757f011ebd6936e4b2e01d9833abfe Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 29 Oct 2024 20:36:01 +0100 Subject: [PATCH] Fix C++ `Vector3::Angle` to return value in degrees just like C# API (instead of radians) --- Source/Engine/Core/Math/Vector3.cpp | 4 ++-- Source/Engine/Core/Math/Vector3.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Core/Math/Vector3.cpp b/Source/Engine/Core/Math/Vector3.cpp index 5a26f2309..d9e00f0c0 100644 --- a/Source/Engine/Core/Math/Vector3.cpp +++ b/Source/Engine/Core/Math/Vector3.cpp @@ -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<> diff --git a/Source/Engine/Core/Math/Vector3.h b/Source/Engine/Core/Math/Vector3.h index 67f8e7d44..5a571c47f 100644 --- a/Source/Engine/Core/Math/Vector3.h +++ b/Source/Engine/Core/Math/Vector3.h @@ -812,11 +812,11 @@ public: static FLAXENGINE_API T TriangleArea(const Vector3Base& v0, const Vector3Base& v1, const Vector3Base& v2); /// - /// 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. /// /// The first vector. /// The second vector. - /// The angle (in radians). + /// The angle (in degrees). static FLAXENGINE_API T Angle(const Vector3Base& from, const Vector3Base& to); ///