Ensure get_joint_angles works in start-new-path case

This commit is contained in:
Grant Sanderson 2023-01-10 16:48:08 -08:00
parent 9d9e000c63
commit eccaa8681e

View file

@ -1046,9 +1046,14 @@ class VMobject(Mobject):
points = self.get_points()
self.data["joint_angle"] = resize_array(self.data["joint_angle"], len(points))
if(len(points) == 0):
if(len(points) < 3):
return self.data["joint_angle"]
append_one = False
if(len(points) % 3 == 1):
points = points[:-1]
append_one = True
# Unit tangent vectors
a0, h, a1 = points[0::3], points[1::3], points[2::3]
a0_to_h = normalize_along_axis(h - a0, 1)
@ -1084,6 +1089,9 @@ class VMobject(Mobject):
self.data["joint_angle"][3::3][mis_matches] = 0
self.data["joint_angle"][2:-1:3][mis_matches] = 0
if append_one:
self.data["joint_angle"] = np.hstack([self.data["joint_angle"], 0])
return self.data["joint_angle"]
def triggers_refreshed_triangulation(func: Callable):