diff --git a/Source/Engine/Core/Math/Double3.h b/Source/Engine/Core/Math/Double3.h
index 177bbcc5e..356c2ee26 100644
--- a/Source/Engine/Core/Math/Double3.h
+++ b/Source/Engine/Core/Math/Double3.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
@@ -934,6 +934,19 @@ public:
/// The triangle area.
static double TriangleArea(const Double3& v0, const Double3& v1, const Double3& 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 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);
+ }
};
inline Double3 operator+(double a, const Double3& b)