Smoothstep is a mathematical function that can smoothly interpolate between two values.
In [2]:
def smoothstep(value): return value * value * (3 - 2 * value)
In [3]:
resolution = 1000 x = [x / resolution for x in range(resolution)] y = [smoothstep(x) for x in x] _ = plt.plot(x, y)
Out:
In [4]:
def smootherstep(value): return value * value * value * (value * (value * 6 - 15) + 10)
In [5]:
resolution = 1000 x = [x / resolution for x in range(resolution)] y = [smootherstep(x) for x in x] _ = plt.plot(x, y)
Out:
Comparison
In [6]:
resolution = 10_000 x = [x / resolution for x in range(resolution)] y = [smootherstep(x) for x in x] _ = plt.plot(x, y, label="Smootherstep") x = [x / resolution for x in range(resolution)] y = [smoothstep(x) for x in x] _ = plt.plot(x, y, label="Smoothstep") _ = plt.legend()
Out: