From a896c7dfa7d299ab7d0863cdc1be3e3fa54f6aed Mon Sep 17 00:00:00 2001 From: HKS_cp <804d57068da1b85c21a2aa7102263f0b712556b1DWcdp7Ps> Date: Sun, 28 Aug 2011 19:17:49 +0000 Subject: [PATCH] Added Ceiling and Floor functions. --- .../Cosmos.System.Plugs.System/MathImpl.cs | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/source2/Kernel/System/Cosmos.System.Plugs.System/MathImpl.cs b/source2/Kernel/System/Cosmos.System.Plugs.System/MathImpl.cs index d7969e471..8317168a1 100644 --- a/source2/Kernel/System/Cosmos.System.Plugs.System/MathImpl.cs +++ b/source2/Kernel/System/Cosmos.System.Plugs.System/MathImpl.cs @@ -266,7 +266,7 @@ namespace Cosmos.System.Plugs.System double result = 0; //TO radians - double radians = a * (Math.PI / 180); + double radians = a;// *(Math.PI / 180); if (radians > Math.PI) { @@ -283,6 +283,8 @@ namespace Cosmos.System.Plugs.System result = (radians) - (Math.Pow(radians, 3) / Factorial(3)); result += (Math.Pow(radians, 5) / Factorial(5)) - (Math.Pow(radians, 7) / Factorial(7)) + (Math.Pow(radians, 9) / Factorial(9)); + //result *= -1; + /* USE WHEN Modulus Works * int sign = 0; for (int i = 3; i < 19; i += 2) @@ -305,7 +307,7 @@ namespace Cosmos.System.Plugs.System public static double Cos(double a) { //Cos(x) = Sin(90degrees - radians) - return Sin(90 - a); + return Sin((Math.PI / 2) - a); } #endregion @@ -325,5 +327,28 @@ namespace Cosmos.System.Plugs.System return n * Factorial(n - 1); } #endregion + + #region Ceiling + public static double Ceiling(double a) + { + int returnval = (int)Floor(a); + returnval += 1; + return returnval; + } + #endregion + + #region Floor + public static double Floor(double a) + { + int returnval = (int)a; + + if (a < 0) + { + returnval -= 1; + } + + return returnval; + } + #endregion } } \ No newline at end of file