I am trying to animate a coin flip using Manim.
For that I create a VGroup with a central Cylinder and two Dots for the two sides.
Still, when I rotate the object the bottom part doesn’t come to the front, it’ like the front side always stays there. Can someone help me?
class Coin(VGroup):
def __init__(self, radius=1, height=None, **kwargs):
super().__init__(**kwargs)
if height is None:
height = radius / 4
self.top = Dot(radius=radius, color=GOLD_D, fill_opacity=1)
self.top.move_to(OUT*height/2)
self.bottom = self.top.copy()
self.bottom.set_color(RED)
self.bottom.move_to(IN*height/2)
self.edge = Cylinder(radius=radius, height=height)
self.edge.set_fill(GREY, opacity=1)
# rotate the cylinder so that the upper face is towards the camera
self.edge.rotate(90 * DEGREES, OUT)
self.add(self.edge, self.bottom, self.top)
class CoinFlip(Scene):
def construct(self):
c = Coin()
self.play(Rotate(c, PI*.8, axis=RIGHT, about_point=ORIGIN))