X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=dev4%2Fpsychlops%2Fcore%2Fmath%2Futil.cs;fp=dev4%2Fpsychlops%2Fcore%2Fmath%2Futil.cs;h=7f498d359280489b33e36dcbc38704b07f922625;hb=cb8916a7a5cd929f57b3f9edd99209680db90546;hp=0000000000000000000000000000000000000000;hpb=e05ab8e68d381f8f5c9a2ddb7c63b89a7bb6371a;p=psychlops%2Fsilverlight.git diff --git a/dev4/psychlops/core/math/util.cs b/dev4/psychlops/core/math/util.cs new file mode 100644 index 0000000..7f498d3 --- /dev/null +++ b/dev4/psychlops/core/math/util.cs @@ -0,0 +1,68 @@ +using System; + +namespace Psychlops +{ + + public static class Math + { + public static readonly double PI = 3.14159265, E = 2.718281828459045; + public static Random random_generator; + static Math() + { + random_generator = new Random(); + } + + public static double abs(double x) + { + return System.Math.Abs(x); + } + public static double sin(double x) + { + return System.Math.Sin(x); + } + public static double cos(double x) + { + return System.Math.Cos(x); + } + public static double tan(double x) + { + return System.Math.Tan(x); + } + public static double sqrt(double x) + { + return System.Math.Sqrt(x); + } + public static double exp(double x) + { + return System.Math.Exp(x); + } + public static double log(double x) + { + return System.Math.Log(x); + } + public static double radius(double x, double y) + { + return System.Math.Sqrt(x * x + y * y); + } + + public static double random() + { + return (random_generator.NextDouble()); + } + public static double random(double x) + { + return (random_generator.NextDouble()) * x; + } + public static double random(double x, double y) + { + return (random_generator.NextDouble()) * (y-x) + x; + } + + + public static double gaussian(double x, double sigma) + { + return exp(- (x*x) / (2*sigma*sigma)); + } + } + +} \ No newline at end of file