mirror of
https://github.com/3b1b/manim.git
synced 2025-07-28 04:23:16 +08:00
Add case for zero vectors on angle_between_vectors
This commit is contained in:
@ -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))
|
||||
|
||||
|
Reference in New Issue
Block a user