diff --git a/Source/Engine/Core/Math/Double2.h b/Source/Engine/Core/Math/Double2.h
index e1ee3ef46..905a87a59 100644
--- a/Source/Engine/Core/Math/Double2.h
+++ b/Source/Engine/Core/Math/Double2.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
+// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
@@ -625,6 +625,20 @@ public:
/// The third triangle vertex.
/// The triangle area.
static double TriangleArea(const Double2& v0, const Double2& v1, const Double2& v2);
+
+ ///
+ /// Calculates the angle (in radians) between from and to. This is always the smallest value.
+ ///
+ /// The first vector.
+ /// The second vector.
+ /// The angle (in radians).
+ static double Angle(const Double2& from, const Double2& 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);
+ }
};
inline Double2 operator+(double a, const Double2& b)