Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Make fall back value in normalize an optional thing

Grant Sanderson6b7ca78ad5e6
diff --git a/utils/space_ops.py b/utils/space_ops.py
index 3b65b4cdf..0bc6b744b 100644
--- a/utils/space_ops.py
+++ b/utils/space_ops.py
@@ -100,12 +100,15 @@ def project_along_vector(point, vector):
return np.dot(point, matrix.T)
-def normalize(vect):
+def normalize(vect, fall_back=None):
norm = get_norm(vect)
if norm > 0:
return vect / norm
else:
- return np.zeros(len(vect))
+ if fall_back is not None:
+ return fall_back
+ else:
+ return np.zeros(len(vect))
def cross(v1, v2):