mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 13:37:45 +00:00
Change implementation of pointwise_become_partial not to change the number of points
This commit is contained in:
parent
c8befa5b9a
commit
11a4d7696e
1 changed files with 16 additions and 11 deletions
|
|
@ -783,36 +783,41 @@ class VMobject(Mobject):
|
||||||
# so as to not have to change the point list
|
# so as to not have to change the point list
|
||||||
def pointwise_become_partial(self, vmobject, a, b):
|
def pointwise_become_partial(self, vmobject, a, b):
|
||||||
assert(isinstance(vmobject, VMobject))
|
assert(isinstance(vmobject, VMobject))
|
||||||
# Partial curve includes three portions:
|
assert(len(self.points) >= len(vmobject.points))
|
||||||
# - A middle section, which matches the curve exactly
|
|
||||||
# - A start, which is some ending portion of an inner quadratic
|
|
||||||
# - An end, which is the starting portion of a later inner quadratic
|
|
||||||
if a <= 0 and b >= 1:
|
if a <= 0 and b >= 1:
|
||||||
self.set_points(vmobject.points)
|
self.points[:] = vmobject.points
|
||||||
return self
|
return self
|
||||||
bezier_tuple = vmobject.get_bezier_tuples()
|
bezier_tuple = vmobject.get_bezier_tuples()
|
||||||
num_curves = len(bezier_tuple)
|
num_curves = len(bezier_tuple)
|
||||||
|
|
||||||
|
# Partial curve includes three portions:
|
||||||
|
# - A middle section, which matches the curve exactly
|
||||||
|
# - A start, which is some ending portion of an inner quadratic
|
||||||
|
# - An end, which is the starting portion of a later inner quadratic
|
||||||
|
|
||||||
lower_index, lower_residue = integer_interpolate(0, num_curves, a)
|
lower_index, lower_residue = integer_interpolate(0, num_curves, a)
|
||||||
upper_index, upper_residue = integer_interpolate(0, num_curves, b)
|
upper_index, upper_residue = integer_interpolate(0, num_curves, b)
|
||||||
|
|
||||||
self.clear_points()
|
new_point_list = []
|
||||||
if num_curves == 0:
|
if num_curves == 0:
|
||||||
|
self.points[:] = 0
|
||||||
return self
|
return self
|
||||||
if lower_index == upper_index:
|
if lower_index == upper_index:
|
||||||
self.append_points(partial_bezier_points(
|
new_point_list.append(partial_bezier_points(
|
||||||
bezier_tuple[lower_index], lower_residue, upper_residue
|
bezier_tuple[lower_index], lower_residue, upper_residue
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
self.append_points(partial_bezier_points(
|
new_point_list.append(partial_bezier_points(
|
||||||
bezier_tuple[lower_index], lower_residue, 1
|
bezier_tuple[lower_index], lower_residue, 1
|
||||||
))
|
))
|
||||||
for tup in bezier_tuple[lower_index + 1:upper_index]:
|
for tup in bezier_tuple[lower_index + 1:upper_index]:
|
||||||
self.append_points(tup)
|
new_point_list.append(tup)
|
||||||
self.append_points(partial_bezier_points(
|
new_point_list.append(partial_bezier_points(
|
||||||
bezier_tuple[upper_index], 0, upper_residue
|
bezier_tuple[upper_index], 0, upper_residue
|
||||||
))
|
))
|
||||||
self.refresh_triangulation()
|
new_points = np.vstack(new_point_list)
|
||||||
|
self.points[:len(new_points)] = new_points
|
||||||
|
self.points[len(new_points):] = new_points[-1]
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def get_subcurve(self, a, b):
|
def get_subcurve(self, a, b):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue