Connect lines into an open polygon #2731
-
Hey! I am new with Manim, and to test the library, today I tried to animate the Cantor function iterative construction: CantorFunctionConstruction.mp4What I don't like about the result is that when the function (in red) transforms from one iteration to the next one, the interpolation of the Transform map is odd. I think the problem has to do with the fact that the vertices of consecutive lines in the function are disconnected. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Heya! It is a bit easier to help if you share a snippet of how you have been approaching your animation so far, but from what I can see your analysis is spot-on. It looks like you are first trying to transform a
One way to make this more natural instead, is to transform between specialized mobjects: def construct(self):
initial_line = VMobject(color=RED).set_points_as_corners([[0,0,0], [1, 1, 0]])
new_line = VMobject(color=RED).set_points_as_corners([[0,0,0], [1/3, 1/2, 0], [2/3, 1/2, 0], [1, 1, 0]])
self.play(Create(initial_line))
self.wait()
self.play(Transform(initial_line, new_line))
self.wait() There probably is a better way of doing this, depending on how you are currently generating the points of the curve, but it should give you an idea of how to make the transformation look better. :-) |
Beta Was this translation helpful? Give feedback.
Heya! It is a bit easier to help if you share a snippet of how you have been approaching your animation so far, but from what I can see your analysis is spot-on. It looks like you are first trying to transform a
Line
into aVGroup
, and then theVGroup
into (larger)VGroup
s ofLines
.Transform
basically tries to match mobjects onto (sub)mobjects, which explains why in the first played animation the complete line transforms into the first segment, and the two others transform out of "thin air".One way to make this more natural instead, is to transform between specialized mobjects: