mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 13:01:00 +00:00
normalize_along_axis
This commit is contained in:
parent
a62a4ae02b
commit
efe15cf2f0
1 changed files with 8 additions and 0 deletions
|
@ -175,6 +175,14 @@ def normalize(vect, fall_back=None):
|
|||
return np.zeros(len(vect))
|
||||
|
||||
|
||||
def normalize_along_axis(array, axis, fall_back=None):
|
||||
norms = np.sqrt((array * array).sum(axis))
|
||||
norms[norms == 0] = 1
|
||||
buffed_norms = np.repeat(norms, array.shape[axis]).reshape(array.shape)
|
||||
array /= buffed_norms
|
||||
return array
|
||||
|
||||
|
||||
def cross(v1, v2):
|
||||
return np.array([
|
||||
v1[1] * v2[2] - v1[2] * v2[1],
|
||||
|
|
Loading…
Add table
Reference in a new issue