mirror of
https://github.com/3b1b/manim.git
synced 2025-08-20 05:14:12 +00:00
Fixed z_to_vector for vectors on z-axis
This commit is contained in:
parent
cacfe67fe1
commit
b2137f2746
1 changed files with 7 additions and 4 deletions
|
@ -137,11 +137,14 @@ def z_to_vector(vector):
|
||||||
Returns some matrix in SO(3) which takes the z-axis to the
|
Returns some matrix in SO(3) which takes the z-axis to the
|
||||||
(normalized) vector provided as an argument
|
(normalized) vector provided as an argument
|
||||||
"""
|
"""
|
||||||
cp = cross(OUT, vector)
|
axis = cross(OUT, vector)
|
||||||
if get_norm(cp) == 0:
|
if get_norm(axis) == 0:
|
||||||
return np.identity(3)
|
if vector[2] > 0:
|
||||||
|
return np.identity(3)
|
||||||
|
else:
|
||||||
|
return rotation_matrix(PI, RIGHT)
|
||||||
angle = np.arccos(np.dot(OUT, normalize(vector)))
|
angle = np.arccos(np.dot(OUT, normalize(vector)))
|
||||||
return rotation_matrix(angle, axis=cp)
|
return rotation_matrix(angle, axis=axis)
|
||||||
|
|
||||||
|
|
||||||
def angle_of_vector(vector):
|
def angle_of_vector(vector):
|
||||||
|
|
Loading…
Add table
Reference in a new issue