1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Add cartesian to polar conversion functions

This commit is contained in:
pablotato
2017-10-13 01:15:45 +02:00
committed by Rémi Verschelde
parent fb801d4964
commit 054a2ac579
7 changed files with 132 additions and 22 deletions

View File

@@ -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);