summaryrefslogtreecommitdiff
path: root/modules/mono/glue/cs_files/Mathf.cs
diff options
context:
space:
mode:
authorpablotato <pabtatoramos@gmail.com>2017-10-13 01:15:45 +0200
committerRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-20 23:34:40 +0100
commit054a2ac579c4893f46b680b1cb0d2460aa3d9140 (patch)
tree8787f924a0eaad0d5924d14e55bbdcb7314ee2e7 /modules/mono/glue/cs_files/Mathf.cs
parentfb801d4964fae52e3807e28f2cc5fcd940ce1700 (diff)
Add cartesian to polar conversion functions
Diffstat (limited to 'modules/mono/glue/cs_files/Mathf.cs')
-rw-r--r--modules/mono/glue/cs_files/Mathf.cs10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs
index cb0eb1acdd..37e6e5bbe3 100644
--- a/modules/mono/glue/cs_files/Mathf.cs
+++ b/modules/mono/glue/cs_files/Mathf.cs
@@ -35,6 +35,11 @@ namespace Godot
return (float)Math.Atan2(x, y);
}
+ public static Vector2 cartesian2polar(float x, float y)
+ {
+ return new Vector2(sqrt(x * x + y * y), atan2(y, x));
+ }
+
public static float ceil(float s)
{
return (float)Math.Ceiling(s);
@@ -176,6 +181,11 @@ namespace Godot
return val;
}
+ public static Vector2 polar2cartesian(float r, float th)
+ {
+ return new Vector2(r * cos(th), r * sin(th));
+ }
+
public static float pow(float x, float y)
{
return (float)Math.Pow(x, y);