File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,9 @@ def construct(self):
89
89
__all__ = [
90
90
"linear" ,
91
91
"smooth" ,
92
+ "smoothstep" ,
93
+ "smootherstep" ,
94
+ "smoothererstep" ,
92
95
"rush_into" ,
93
96
"rush_from" ,
94
97
"slow_into" ,
@@ -155,6 +158,36 @@ def smooth(t: float, inflection: float = 10.0) -> float:
155
158
)
156
159
157
160
161
+ def smoothstep (t : float ) -> float :
162
+ """Implementation of the 1st order SmoothStep sigmoid function.
163
+ The 1st derivative (speed) is zero at the endpoints.
164
+ https://en.wikipedia.org/wiki/Smoothstep
165
+ """
166
+ return 0 if t <= 0 else 3 * t ** 2 - 2 * t ** 3 if t < 1 else 1
167
+
168
+
169
+ def smootherstep (t : float ) -> float :
170
+ """Implementation of the 2nd order SmoothStep sigmoid function.
171
+ The 1st and 2nd derivatives (speed and acceleration) are zero at the endpoints.
172
+ https://en.wikipedia.org/wiki/Smoothstep
173
+ """
174
+ return 0 if t <= 0 else 6 * t ** 5 - 15 * t ** 4 + 10 * t ** 3 if t < 1 else 1
175
+
176
+
177
+ def smoothererstep (t : float ) -> float :
178
+ """Implementation of the 3rd order SmoothStep sigmoid function.
179
+ The 1st, 2nd and 3rd derivatives (speed, acceleration and jerk) are zero at the endpoints.
180
+ https://en.wikipedia.org/wiki/Smoothstep
181
+ """
182
+ return (
183
+ 0
184
+ if t <= 0
185
+ else 35 * t ** 4 - 84 * t ** 5 + 70 * t ** 6 - 20 * t ** 7
186
+ if t < 1
187
+ else 1
188
+ )
189
+
190
+
158
191
@unit_interval
159
192
def rush_into (t : float , inflection : float = 10.0 ) -> float :
160
193
return 2 * smooth (t / 2.0 , inflection )
You can’t perform that action at this time.
0 commit comments