mirror of
https://github.com/3b1b/manim.git
synced 2025-07-31 14:03:59 +08:00
Actually ensure get_joint_angle works for start_new_path case
This commit is contained in:
@ -1046,15 +1046,16 @@ class VMobject(Mobject):
|
|||||||
self.needs_new_joint_angles = False
|
self.needs_new_joint_angles = False
|
||||||
|
|
||||||
points = self.get_points()
|
points = self.get_points()
|
||||||
|
append_one = False
|
||||||
|
if(len(points) % 3 == 1):
|
||||||
|
points = points[:-1]
|
||||||
|
append_one = True
|
||||||
|
|
||||||
self.data["joint_angle"] = resize_array(self.data["joint_angle"], len(points))
|
self.data["joint_angle"] = resize_array(self.data["joint_angle"], len(points))
|
||||||
|
|
||||||
if(len(points) < 3):
|
if(len(points) < 3):
|
||||||
return self.data["joint_angle"]
|
return self.data["joint_angle"]
|
||||||
|
|
||||||
append_one = False
|
|
||||||
if(len(points) % 3 == 1):
|
|
||||||
points = points[:-1]
|
|
||||||
append_one = True
|
|
||||||
|
|
||||||
# Unit tangent vectors
|
# Unit tangent vectors
|
||||||
a0, h, a1 = points[0::3], points[1::3], points[2::3]
|
a0, h, a1 = points[0::3], points[1::3], points[2::3]
|
||||||
@ -1078,7 +1079,7 @@ class VMobject(Mobject):
|
|||||||
dots = (vect_to_vert * vect_from_vert).sum(1)
|
dots = (vect_to_vert * vect_from_vert).sum(1)
|
||||||
angle = np.arccos(arr_clip(dots, -1, 1))
|
angle = np.arccos(arr_clip(dots, -1, 1))
|
||||||
sgn = np.sign(cross2d(vect_to_vert, vect_from_vert))
|
sgn = np.sign(cross2d(vect_to_vert, vect_from_vert))
|
||||||
self.data["joint_angle"][:len(angle), 0] = sgn * angle
|
self.data["joint_angle"][:, 0] = sgn * angle
|
||||||
|
|
||||||
# If a given anchor point sits at the end of a curve,
|
# If a given anchor point sits at the end of a curve,
|
||||||
# we set its angle equal to 0
|
# we set its angle equal to 0
|
||||||
@ -1092,7 +1093,7 @@ class VMobject(Mobject):
|
|||||||
self.data["joint_angle"][2:-1:3][mis_matches] = 0
|
self.data["joint_angle"][2:-1:3][mis_matches] = 0
|
||||||
|
|
||||||
if append_one:
|
if append_one:
|
||||||
self.data["joint_angle"] = np.hstack([self.data["joint_angle"], 0])
|
self.data["joint_angle"] = np.vstack([self.data["joint_angle"], np.zeros((1, 1))])
|
||||||
|
|
||||||
return self.data["joint_angle"]
|
return self.data["joint_angle"]
|
||||||
|
|
||||||
@ -1103,6 +1104,7 @@ class VMobject(Mobject):
|
|||||||
if refresh:
|
if refresh:
|
||||||
self.refresh_triangulation()
|
self.refresh_triangulation()
|
||||||
self.refresh_joint_angles()
|
self.refresh_joint_angles()
|
||||||
|
self.get_joint_angles()
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
@triggers_refreshed_triangulation
|
@triggers_refreshed_triangulation
|
||||||
|
Reference in New Issue
Block a user