diff options
| author | realtradam <[email protected]> | 2022-12-07 04:28:20 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-12-07 04:28:20 -0500 |
| commit | 13bcae5f22a8034af1db830cce79c1f3ffd476cb (patch) | |
| tree | a5fe77976c6a387d30256d4c4a42127de0b281ac /Assets/Scripts/MathFunctionLibrary.cs | |
| parent | a71efa41f09e878b5cfa68072e896df1a85bc51f (diff) | |
| download | UnityDancingGraph-13bcae5f22a8034af1db830cce79c1f3ffd476cb.tar.gz UnityDancingGraph-13bcae5f22a8034af1db830cce79c1f3ffd476cb.zip | |
lerp and sliders
Diffstat (limited to 'Assets/Scripts/MathFunctionLibrary.cs')
| -rw-r--r-- | Assets/Scripts/MathFunctionLibrary.cs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Assets/Scripts/MathFunctionLibrary.cs b/Assets/Scripts/MathFunctionLibrary.cs index 1169eca..ba818ef 100644 --- a/Assets/Scripts/MathFunctionLibrary.cs +++ b/Assets/Scripts/MathFunctionLibrary.cs @@ -6,7 +6,13 @@ using static UnityEngine.Mathf; public static class MathFunctionLibrary { - public delegate float Function(float x, float t); + public delegate float Function(float x, float z, float t); + + public enum FunctionEnum { + Wave, + MultiWave, + Ripple + } static Function[] functions = { Wave, @@ -14,25 +20,25 @@ public static class MathFunctionLibrary Ripple }; - public static Function GetFunction(int index) + public static Function GetFunction(FunctionEnum name) { - return functions[index]; + return functions[(int)name]; } - public static float Wave(float x, float t) + public static float Wave(float x, float z, float t) { - return Sin(PI * (x + t)); + return Sin(PI * (x + z + t)); } - public static float MultiWave(float x, float t) + public static float MultiWave(float x, float z, float t) { - float y = Wave(x, t * 0.5f); + float y = Wave(x, z, t * 0.5f); y += Sin(2f * PI * (x + t)) * 0.5f; return y * (2f / 3f); } - public static float Ripple (float x, float t) { - float d = Abs(x); + public static float Ripple (float x, float z, float t) { + float d = Sqrt(x * x + z * z); float y = Sin(PI * (4f * d - (2f * t))); return y / (1f + 10f * d); } |
