mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Fix get_subpath_end_indices_from_points
This commit is contained in:
parent
bcafcbf490
commit
a08523d746
1 changed files with 6 additions and 2 deletions
|
@ -736,10 +736,14 @@ class VMobject(Mobject):
|
|||
return self.get_bezier_tuples_from_points(self.get_points())
|
||||
|
||||
def get_subpath_end_indices_from_points(self, points: Vect3Array) -> np.ndarray:
|
||||
a0, h = points[0:-1:2], points[1::2]
|
||||
atol = self.tolerance_for_point_equality
|
||||
a0, h, a1 = points[0:-1:2], points[1::2], points[2::2]
|
||||
# An anchor point is considered the end of a path
|
||||
# if its following handle is sitting on top of it.
|
||||
is_end = (a0 == h).all(1)
|
||||
# To disambiguate this from cases with many null
|
||||
# curves in a row, we also check that the following
|
||||
# anchor is genuinely distinct
|
||||
is_end = (a0 == h).all(1) & (abs(h - a1) > atol).any(1)
|
||||
end_indices = (2 * n for n, end in enumerate(is_end) if end)
|
||||
return np.array([*end_indices, len(points) - 1])
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue