diff options
Diffstat (limited to 'Assets/Scripts/MathFunctionLibrary.cs')
| -rw-r--r-- | Assets/Scripts/MathFunctionLibrary.cs | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/Assets/Scripts/MathFunctionLibrary.cs b/Assets/Scripts/MathFunctionLibrary.cs index d83b673..1169eca 100644 --- a/Assets/Scripts/MathFunctionLibrary.cs +++ b/Assets/Scripts/MathFunctionLibrary.cs @@ -8,20 +8,15 @@ public static class MathFunctionLibrary { public delegate float Function(float x, float t); - public static float GetFunction(float x, float t) + static Function[] functions = { + Wave, + MultiWave, + Ripple + }; + + public static Function GetFunction(int index) { - if(index == 0) - { - return Wave; - } - else if(index == 1) - { - return MultiWave; - } - else //if(index == 2) - { - return Ripple; - } + return functions[index]; } public static float Wave(float x, float t) @@ -31,27 +26,15 @@ public static class MathFunctionLibrary public static float MultiWave(float x, float t) { - float y = MathFunctionLibrary.Wave(x, t * 0.5f); + float y = Wave(x, t * 0.5f); y += Sin(2f * PI * (x + t)) * 0.5f; return y * (2f / 3f); } - public static float Ripple(float x, float t) { + public static float Ripple (float x, float t) { float d = Abs(x); float y = Sin(PI * (4f * d - (2f * t))); return y / (1f + 10f * d); } - /* - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } - */ + } |
