diff options
| author | realtradam <[email protected]> | 2022-12-07 02:02:12 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-12-07 02:02:12 -0500 |
| commit | ba11c1f9a934ebb59d56348b78ac0bd687135585 (patch) | |
| tree | b6e8bd9871f275262394f207054ee3930227340d /Assets/Scripts/MathFunctionLibrary.cs | |
| parent | 860d8fabe9496df2d9246fd17954c598e6c696a0 (diff) | |
| download | UnityDancingGraph-ba11c1f9a934ebb59d56348b78ac0bd687135585.tar.gz UnityDancingGraph-ba11c1f9a934ebb59d56348b78ac0bd687135585.zip | |
isolate graph functions
Diffstat (limited to 'Assets/Scripts/MathFunctionLibrary.cs')
| -rw-r--r-- | Assets/Scripts/MathFunctionLibrary.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Assets/Scripts/MathFunctionLibrary.cs b/Assets/Scripts/MathFunctionLibrary.cs new file mode 100644 index 0000000..d83b673 --- /dev/null +++ b/Assets/Scripts/MathFunctionLibrary.cs @@ -0,0 +1,57 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using static UnityEngine.Mathf; + +public static class MathFunctionLibrary +{ + public delegate float Function(float x, float t); + + public static float GetFunction(float x, float t) + { + if(index == 0) + { + return Wave; + } + else if(index == 1) + { + return MultiWave; + } + else //if(index == 2) + { + return Ripple; + } + } + + public static float Wave(float x, float t) + { + return Sin(PI * (x + t)); + } + + public static float MultiWave(float x, float t) + { + float y = MathFunctionLibrary.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) { + 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() + { + + } + */ +} |
