Added a clamp function

This commit is contained in:
Sridhar Ramesh
2018-01-17 23:17:23 -08:00
parent a236e33e50
commit 04c8477ea0

View File

@ -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)