diff options
| author | realtradam <[email protected]> | 2022-12-07 02:23:06 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-12-07 02:23:06 -0500 |
| commit | a71efa41f09e878b5cfa68072e896df1a85bc51f (patch) | |
| tree | c2bad6ee8c4613160f66abae24334aa9b90836ac /Assets/Scripts/MathFunctionLibrary.cs | |
| parent | ba11c1f9a934ebb59d56348b78ac0bd687135585 (diff) | |
| download | UnityDancingGraph-a71efa41f09e878b5cfa68072e896df1a85bc51f.tar.gz UnityDancingGraph-a71efa41f09e878b5cfa68072e896df1a85bc51f.zip | |
cleaner organization of functions
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() - { - - } - */ + } |
