There is a grouped angle (two lines and a arc) moving and rotating at the same time, depending on the location of another Dot, from the video, the grouped angle is lagged behind the Dot, don't know why? below is the code:
class MovRot(Scene):
def construct(self):
ln = Line(LEFT*2, LEFT*1+UP*1.5)
self.add(ln)
ln_ab = Line(LEFT*2, interpolate(LEFT*2, LEFT*1+UP*1.5, 0.7), color=RED_D)
ln_bc = Line(LEFT*2, ORIGIN, color=RED_D)
arc_b = Arc(0, ln_ab.get_angle(), radius=0.6, color=RED_D).move_arc_center_to(LEFT*2)
grp_b = VGroup(ln_ab, ln_bc, arc_b)
self.add(grp_b)
dt = Dot(color=YELLOW_D).move_to(LEFT*2)
grp_1 = grp_b.copy()
def update_grp1(mob, alpha):
mob.become(grp_1)
mob.move_to(dt.get_center(), aligned_edge=arc_b.get_arc_center())
mob.rotate(alpha*PI, about_point=arc_b.get_arc_center())
self.add(grp_1, dt)
self.play(UpdateFromAlphaFunc(grp_b, update_grp1, rate_func=smooth), dt.move_to, LEFT*1+UP*1.5,
rate_func=smooth,
run_time=2)
Thanks for any help.
You always have to write the "master" animation at the beginning of the play method, in your case, the animation that "takes the baton" is move_to
, so it must be the first to be written:
self.play(
dt.move_to, LEFT*1+UP*1.5,
UpdateFromAlphaFunc(grp_b, update_grp1, rate_func=smooth),
rate_func=smooth,
run_time=2
)