summaryrefslogtreecommitdiff
path: root/modules/mono/glue/cs_files/Mathf.cs
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/glue/cs_files/Mathf.cs')
-rw-r--r--modules/mono/glue/cs_files/Mathf.cs90
1 files changed, 50 insertions, 40 deletions
diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs
index cb0eb1acdd..6951ace4fc 100644
--- a/modules/mono/glue/cs_files/Mathf.cs
+++ b/modules/mono/glue/cs_files/Mathf.cs
@@ -10,37 +10,42 @@ namespace Godot
private const float Deg2RadConst = 0.0174532924f;
private const float Rad2DegConst = 57.29578f;
- public static float abs(float s)
+ public static float Abs(float s)
{
return Math.Abs(s);
}
- public static float acos(float s)
+ public static float Acos(float s)
{
return (float)Math.Acos(s);
}
- public static float asin(float s)
+ public static float Asin(float s)
{
return (float)Math.Asin(s);
}
- public static float atan(float s)
+ public static float Atan(float s)
{
return (float)Math.Atan(s);
}
- public static float atan2(float x, float y)
+ public static float Atan2(float x, float y)
{
return (float)Math.Atan2(x, y);
}
- public static float ceil(float s)
+ 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);
}
- public static float clamp(float val, float min, float max)
+ public static float Clamp(float val, float min, float max)
{
if (val < min)
{
@@ -54,32 +59,32 @@ namespace Godot
return val;
}
- public static float cos(float s)
+ public static float Cos(float s)
{
return (float)Math.Cos(s);
}
- public static float cosh(float s)
+ public static float Cosh(float s)
{
return (float)Math.Cosh(s);
}
- public static int decimals(float step)
+ public static int Decimals(float step)
{
- return decimals(step);
+ return Decimals(step);
}
- public static int decimals(decimal step)
+ public static int Decimals(decimal step)
{
return BitConverter.GetBytes(decimal.GetBits(step)[3])[2];
}
- public static float deg2rad(float deg)
+ public static float Deg2Rad(float deg)
{
return deg * Deg2RadConst;
}
- public static float ease(float s, float curve)
+ public static float Ease(float s, float curve)
{
if (s < 0f)
{
@@ -94,35 +99,35 @@ namespace Godot
{
if (curve < 1.0f)
{
- return 1.0f - pow(1.0f - s, 1.0f / curve);
+ return 1.0f - Pow(1.0f - s, 1.0f / curve);
}
- return pow(s, curve);
+ return Pow(s, curve);
}
else if (curve < 0f)
{
if (s < 0.5f)
{
- return pow(s * 2.0f, -curve) * 0.5f;
+ return Pow(s * 2.0f, -curve) * 0.5f;
}
- return (1.0f - pow(1.0f - (s - 0.5f) * 2.0f, -curve)) * 0.5f + 0.5f;
+ return (1.0f - Pow(1.0f - (s - 0.5f) * 2.0f, -curve)) * 0.5f + 0.5f;
}
return 0f;
}
- public static float exp(float s)
+ public static float Exp(float s)
{
return (float)Math.Exp(s);
}
- public static float floor(float s)
+ public static float Floor(float s)
{
return (float)Math.Floor(s);
}
- public static float fposmod(float x, float y)
+ public static float Fposmod(float x, float y)
{
if (x >= 0f)
{
@@ -134,37 +139,37 @@ namespace Godot
}
}
- public static float lerp(float from, float to, float weight)
+ public static float Lerp(float from, float to, float weight)
{
- return from + (to - from) * clamp(weight, 0f, 1f);
+ return from + (to - from) * Clamp(weight, 0f, 1f);
}
- public static float log(float s)
+ public static float Log(float s)
{
return (float)Math.Log(s);
}
- public static int max(int a, int b)
+ public static int Max(int a, int b)
{
return (a > b) ? a : b;
}
- public static float max(float a, float b)
+ public static float Max(float a, float b)
{
return (a > b) ? a : b;
}
- public static int min(int a, int b)
+ public static int Min(int a, int b)
{
return (a < b) ? a : b;
}
- public static float min(float a, float b)
+ public static float Min(float a, float b)
{
return (a < b) ? a : b;
}
- public static int nearest_po2(int val)
+ public static int NearestPo2(int val)
{
val--;
val |= val >> 1;
@@ -176,57 +181,62 @@ namespace Godot
return val;
}
- public static float pow(float x, float y)
+ 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);
}
- public static float rad2deg(float rad)
+ public static float Rad2Deg(float rad)
{
return rad * Rad2DegConst;
}
- public static float round(float s)
+ public static float Round(float s)
{
return (float)Math.Round(s);
}
- public static float sign(float s)
+ public static float Sign(float s)
{
return (s < 0f) ? -1f : 1f;
}
- public static float sin(float s)
+ public static float Sin(float s)
{
return (float)Math.Sin(s);
}
- public static float sinh(float s)
+ public static float Sinh(float s)
{
return (float)Math.Sinh(s);
}
- public static float sqrt(float s)
+ public static float Sqrt(float s)
{
return (float)Math.Sqrt(s);
}
- public static float stepify(float s, float step)
+ public static float Stepify(float s, float step)
{
if (step != 0f)
{
- s = floor(s / step + 0.5f) * step;
+ s = Floor(s / step + 0.5f) * step;
}
return s;
}
- public static float tan(float s)
+ public static float Tan(float s)
{
return (float)Math.Tan(s);
}
- public static float tanh(float s)
+ public static float Tanh(float s)
{
return (float)Math.Tanh(s);
}