mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Added a clamp function
This commit is contained in:
parent
a236e33e50
commit
04c8477ea0
1 changed files with 7 additions and 0 deletions
|
@ -304,6 +304,13 @@ def digest_locals(obj, keys = None):
|
|||
def interpolate(start, end, alpha):
|
||||
return (1-alpha)*start + alpha*end
|
||||
|
||||
def clamp(lower, upper, val):
|
||||
if val < lower:
|
||||
return lower
|
||||
elif val > upper:
|
||||
return upper
|
||||
return val
|
||||
|
||||
def center_of_mass(points):
|
||||
points = [np.array(point).astype("float") for point in points]
|
||||
return sum(points) / len(points)
|
||||
|
|
Loading…
Add table
Reference in a new issue