def bell(t0): A = -2 B = 3 t = t0 m = 1 if(t0< (-1)): return -1 if(t0>1): return 1 if t0<0: t=(-t0) ts = t*t return (A*t*ts + B*ts) #input 0 <= t0 <= 2 #outputs [0:1] smoothed inverted bell curve def invbell(t0): t=t0-1 return (bell(t)-1) #input 0 <= t0 <= 2 #outputs [0:1] smoothed positive bell curve def pbell(t0): t=t0-1 return (1-bell(t)) #bell2 #input 0 <= t0 <= 4 #input 0 <= t0 <= 2 then #outputs [0:1] smoothed positive bell curve #input 2 <= t0 <= 4 #outputs [0 : -1] smoothed inverted bell curve def bell2(t0): if (t0<=2): return pbell(t0) return invbell(t0-2) #bell4 #input t0 is positive integer t0 mod 4 is used #input 0 <= t0 <= 2 then #outputs [0:1] smoothed positive bell curve #input 2 <= t0 <= 4 #outputs [0 : -1] smoothed inverted bell curve def bell4(t0): t = t0 % 4 return bell2(t) #cycles between the minimum and maximum of the range #starts at the median when t=0 def range(t0, min, max): t = t0 % 4 f = bell2(t) d = max - min m = d/2.0 median = min + m return median+f*m