mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Add case for zero vectors on angle_between_vectors
This commit is contained in:
parent
d7bdcab161
commit
e8ac25903e
1 changed files with 2 additions and 0 deletions
|
@ -152,6 +152,8 @@ def angle_between_vectors(v1: np.ndarray, v2: np.ndarray) -> float:
|
|||
"""
|
||||
n1 = get_norm(v1)
|
||||
n2 = get_norm(v2)
|
||||
if n1 == 0 or n2 == 0:
|
||||
return 0
|
||||
cos_angle = np.dot(v1, v2) / (n1 * n2)
|
||||
return math.acos(clip(cos_angle, -1, 1))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue