mirror of
https://github.com/3b1b/manim.git
synced 2025-11-13 21:18:09 +00:00
Small bug fix for angle_between_vectors
This commit is contained in:
parent
25045143a1
commit
fbc329d7ce
1 changed files with 2 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ from manimlib.constants import OUT
|
||||||
from manimlib.constants import PI
|
from manimlib.constants import PI
|
||||||
from manimlib.constants import TAU
|
from manimlib.constants import TAU
|
||||||
from manimlib.utils.iterables import adjacent_pairs
|
from manimlib.utils.iterables import adjacent_pairs
|
||||||
|
from manimlib.utils.simple_functions import clip
|
||||||
|
|
||||||
|
|
||||||
def cross(v1, v2):
|
def cross(v1, v2):
|
||||||
|
|
@ -174,7 +175,7 @@ def angle_between_vectors(v1, v2):
|
||||||
Returns the angle between two 3D vectors.
|
Returns the angle between two 3D vectors.
|
||||||
This angle will always be btw 0 and pi
|
This angle will always be btw 0 and pi
|
||||||
"""
|
"""
|
||||||
return math.acos(np.dot(normalize(v1), normalize(v2)))
|
return math.acos(clip(np.dot(normalize(v1), normalize(v2)), -1, 1))
|
||||||
|
|
||||||
|
|
||||||
def project_along_vector(point, vector):
|
def project_along_vector(point, vector):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue