mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Make fall back value in normalize an optional thing
This commit is contained in:
parent
7736e321a0
commit
6b7ca78ad5
1 changed files with 5 additions and 2 deletions
|
@ -100,12 +100,15 @@ def project_along_vector(point, vector):
|
||||||
return np.dot(point, matrix.T)
|
return np.dot(point, matrix.T)
|
||||||
|
|
||||||
|
|
||||||
def normalize(vect):
|
def normalize(vect, fall_back=None):
|
||||||
norm = get_norm(vect)
|
norm = get_norm(vect)
|
||||||
if norm > 0:
|
if norm > 0:
|
||||||
return vect / norm
|
return vect / norm
|
||||||
else:
|
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):
|
def cross(v1, v2):
|
||||||
|
|
Loading…
Add table
Reference in a new issue