summaryrefslogtreecommitdiffstats
path: root/thirdparty/thorvg/src/common/tvgMath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/thorvg/src/common/tvgMath.cpp')
-rw-r--r--thirdparty/thorvg/src/common/tvgMath.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/thirdparty/thorvg/src/common/tvgMath.cpp b/thirdparty/thorvg/src/common/tvgMath.cpp
index e99ec46681..c56b32249f 100644
--- a/thirdparty/thorvg/src/common/tvgMath.cpp
+++ b/thirdparty/thorvg/src/common/tvgMath.cpp
@@ -22,6 +22,20 @@
#include "tvgMath.h"
+//see: https://en.wikipedia.org/wiki/Remez_algorithm
+float mathAtan2(float y, float x)
+{
+ if (y == 0.0f && x == 0.0f) return 0.0f;
+
+ auto a = std::min(fabsf(x), fabsf(y)) / std::max(fabsf(x), fabsf(y));
+ auto s = a * a;
+ auto r = ((-0.0464964749f * s + 0.15931422f) * s - 0.327622764f) * s * a + a;
+ if (fabsf(y) > fabsf(x)) r = 1.57079637f - r;
+ if (x < 0) r = 3.14159274f - r;
+ if (y < 0) return -r;
+ return r;
+}
+
bool mathInverse(const Matrix* m, Matrix* out)
{