I am trying to have two identical Bezier curves in the same scene, one with an end tip and the other with a start tip, but the Bezier curves come out differently despite having the same anchors and handles. I know I can add both tips to the same Bezier curve but to integrate the graphics into my existing code (to animate it) I need to have them separate. Sample code to demonstrate the problem is as follows:
from manimlib.imports import *
class Testing3(Scene):
def construct(self):
coords_list=[0.818*UP+.9*UP, -2*RIGHT+((1/6-19/36)*np.sqrt(3))*UP+.9*UP]
node_list=[]
for i in range(2):
mobject = VMobject()
number = TexMobject(str(i+1))
circle = Circle(radius=0.4,color=WHITE)
mobject.add(number)
mobject.add(circle)
mobject.move_to(coords_list[i])
node_list.append(mobject)
arc1=TipableVMobject()
arc1.add_cubic_bezier_curve(
node_list[1].get_center(),
node_list[1].get_center()-3*RIGHT+2*UP,
node_list[1].get_center()-2*RIGHT+5.2*UP,
node_list[0].get_center()
)
arc1.pointwise_become_partial(
arc1,
0.4/arc1.get_arc_length(n_sample_points=20),
1-0.2/arc1.get_arc_length(n_sample_points=100)
)
arc1.add_tip(tip_length=0.2)
arc2=TipableVMobject()
arc2.add_cubic_bezier_curve(
node_list[1].get_center(),
node_list[1].get_center()-3*RIGHT+2*UP,
node_list[1].get_center()-2*RIGHT+5.2*UP,
node_list[0].get_center()
)
arc2.pointwise_become_partial(
arc2,
0.4/arc2.get_arc_length(n_sample_points=20),
1-0.2/arc2.get_arc_length(n_sample_points=100)
)
arc2.add_tip(tip_length=0.2,at_start=True)
self.add(*node_list,arc1,arc2)
self.wait()
I have tried making a copy of the Bezier curve but it produces the same result.
For the moment this is only can I do:
class Testing3(Scene):
def construct(self):
coords_list=[0.818*UP+.9*UP, -2*RIGHT+((1/6-19/36)*np.sqrt(3))*UP+.9*UP]
node_list=[]
for i in range(2):
mobject = VMobject()
number = TexMobject(str(i+1))
circle = Circle(radius=0.4,color=WHITE)
mobject.add(number)
mobject.add(circle)
mobject.move_to(coords_list[i])
node_list.append(mobject)
arc1=TipableVMobject()
arc1.add_cubic_bezier_curve(
node_list[1].get_center(),
node_list[1].get_center()-3*RIGHT+2*UP,
node_list[1].get_center()-2*RIGHT+5.2*UP,
node_list[0].get_center()
)
arc1.pointwise_become_partial(
arc1,
0.4/arc1.get_arc_length(n_sample_points=20),
1-0.2/arc1.get_arc_length(n_sample_points=100)
)
arc1.add_tip(tip_length=0.2,
#at_start=True
)
arc1.add_tip(tip_length=0.2,
at_start=True
)
arc1.set_color(RED)
arc2=TipableVMobject()
arc2.add_cubic_bezier_curve(
node_list[1].get_center(),
node_list[1].get_center()-3*RIGHT+2*UP,
node_list[1].get_center()-2*RIGHT+5.2*UP,
node_list[0].get_center()
)
arc2.pointwise_become_partial(
arc2,
0.4/arc2.get_arc_length(n_sample_points=20),
1-0.2/arc2.get_arc_length(n_sample_points=100)
)
arc2.add_tip(tip_length=0.2,
#at_start=True
)
arc2.add_tip(tip_length=0.2,
at_start=True
)
arc2.set_color(BLUE)
arc1.remove(arc1[-2])
arc2.remove(arc2[-1])
self.add(*node_list,arc1)
self.wait()
self.add(arc2)
self.wait()