mirror of
https://github.com/3b1b/manim.git
synced 2025-08-03 04:04:36 +08:00
Allow interpolate to work on an array of alpha values
This commit is contained in:
@ -67,7 +67,13 @@ def partial_quadratic_bezier_points(points, a, b):
|
||||
|
||||
def interpolate(start, end, alpha):
|
||||
try:
|
||||
return (1 - alpha) * start + alpha * end
|
||||
if isinstance(alpha, float):
|
||||
return (1 - alpha) * start + alpha * end
|
||||
# Otherwise, assume alpha is a list or array, and return
|
||||
# an appropriated shaped array of all corresponding
|
||||
# interpolations
|
||||
result = np.outer(1 - alpha, start) + np.outer(alpha, end)
|
||||
return result.reshape((*np.shape(alpha), *np.shape(start)))
|
||||
except TypeError:
|
||||
log.debug(f"`start` parameter with type `{type(start)}` and dtype `{start.dtype}`")
|
||||
log.debug(f"`end` parameter with type `{type(end)}` and dtype `{end.dtype}`")
|
||||
|
Reference in New Issue
Block a user