diff options
author | Ignacio Etcheverry <neikeq@users.noreply.github.com> | 2018-09-12 22:08:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 22:08:54 +0200 |
commit | 8704b7787624da98cece35c1b8b8e51bde709488 (patch) | |
tree | 398ab2ee1e88e3b853c6157458362dced14d64da /modules/mono/glue/Managed/Files/MathfEx.cs | |
parent | 4cd3dd821932660a7d89d90da7626fa46c07ac39 (diff) | |
parent | 995a40e8efa9f7a868a6706e30c476305e16180b (diff) |
Merge pull request #22007 from neikeq/<name_of_your_new_branch>
Move modules/mono/glue/cs_files to modules/mono/glue/Managed/Files
Diffstat (limited to 'modules/mono/glue/Managed/Files/MathfEx.cs')
-rw-r--r-- | modules/mono/glue/Managed/Files/MathfEx.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/modules/mono/glue/Managed/Files/MathfEx.cs b/modules/mono/glue/Managed/Files/MathfEx.cs new file mode 100644 index 0000000000..739b7fb568 --- /dev/null +++ b/modules/mono/glue/Managed/Files/MathfEx.cs @@ -0,0 +1,39 @@ +using System; + +#if REAL_T_IS_DOUBLE +using real_t = System.Double; +#else +using real_t = System.Single; +#endif + +namespace Godot +{ + public static partial class Mathf + { + // Define constants with Decimal precision and cast down to double or float. + + public const real_t E = (real_t) 2.7182818284590452353602874714M; // 2.7182817f and 2.718281828459045 + public const real_t Sqrt2 = (real_t) 1.4142135623730950488016887242M; // 1.4142136f and 1.414213562373095 + +#if REAL_T_IS_DOUBLE + public const real_t Epsilon = 1e-14; // Epsilon size should depend on the precision used. +#else + public const real_t Epsilon = 1e-06f; +#endif + + public static int CeilToInt(real_t s) + { + return (int)Math.Ceiling(s); + } + + public static int FloorToInt(real_t s) + { + return (int)Math.Floor(s); + } + + public static int RoundToInt(real_t s) + { + return (int)Math.Round(s); + } + } +}
\ No newline at end of file |