From be1acb19e53ddc0c6f4261bff1e32c40419abbf7 Mon Sep 17 00:00:00 2001 From: Tyler Fox Date: Wed, 4 Sep 2024 17:14:38 -0700 Subject: [PATCH] Consolidate --- Examples/simplePlot.py | 70 ---------------------------- {Examples => scripts}/complexPlot.py | 0 2 files changed, 70 deletions(-) delete mode 100644 Examples/simplePlot.py rename {Examples => scripts}/complexPlot.py (100%) diff --git a/Examples/simplePlot.py b/Examples/simplePlot.py deleted file mode 100644 index 1e102b8..0000000 --- a/Examples/simplePlot.py +++ /dev/null @@ -1,70 +0,0 @@ -# pylint:disable=missing-docstring,redefined-outer-name,invalid-name -import matplotlib.pyplot as plt -from math import sin, cos, exp, pi, floor, ceil - - -def getAccel(anim, curTime): - if curTime == 0: - # return 0 - curTime += 1 - elif curTime == len(anim) - 1: - return 0 - curTime -= 1 - - last = anim[curTime - 1] - cur = anim[curTime] - fut = anim[curTime + 1] - return last - 2 * cur + fut - - -def evalCrv(c, w, d, t): - """c -> count, w -> wavelength, d -> decay""" - return sin(2 * pi * t / w) / exp(t * d / (c * w)) - - -def test(anim, num=10, amp=1.0, length=20, decay=5.0, matchVelocity=True): - extra = int((num + 0.5) * length) - anim += [anim[-1]] * extra - - steps = [1.0] * len(anim) - steps = [1.0] * 60 + [3.5] * 60 + [1.0] - - steps += [steps[-1]] * len(anim) - steps = steps[: len(anim)] - - # Build the response curve - trange = range(len(anim)) - crvLen = int(num * length) + 1 - - accel = [getAccel(anim, curTime) for curTime in trange] - - mvel = amp - if matchVelocity: - mvel = amp * length / (2 * pi) - - out = [] - for f in trange: # frame - val = anim[f] - s = 0 # total steps taken - for b in range(crvLen): - val -= accel[f - b] * evalCrv(num, length, decay, s) * mvel - s += steps[f - b] - out.append(val) - - plt.plot(trange, anim, "b--") - plt.plot(trange, accel, "g") - plt.plot(trange, out, "r") - plt.show() - - -if __name__ == "__main__": - # linear stop - anim = list(range(10)) - - # Parabolic stop - # anim = [9.0 - (((i-10) ** 2) * 9.0 / 100.0) for i in range(10)] - - # Sine motion - # anim = [sin(pi * i / 10) for i in range(80)] - - test(anim) diff --git a/Examples/complexPlot.py b/scripts/complexPlot.py similarity index 100% rename from Examples/complexPlot.py rename to scripts/complexPlot.py