trying-manim/folding.py

38 lines
1.2 KiB
Python

from manimlib.imports import *
from math import radians,sin,cos
class CubeRoot2(Scene):
def construct(self):
mainTitle = TexMobject("Getting \\sqrt[3][2]")
mainTitle.to_corner()
self.add(mainTitle)
mainSquare = Square(side_length=5)
self.play(ShowCreation(mainSquare))
self.wait(1)
msg_split_into_thirds = TextMobject("Split into Thirds")
self.play(ShowCreation(msg_split_into_thirds))
mainSquareThirds1 = Line(2.5 * LEFT + (2.5 - 5/3) * UP, 2.5 * RIGHT + (2.5 - 5/3) * UP)
mainSquareThirds2 = Line(2.5 * LEFT + (2.5 - 5/3) * DOWN, 2.5 * RIGHT + (2.5 - 5/3) * DOWN)
self.play(ShowCreation(mainSquareThirds1), ShowCreation(mainSquareThirds2))
self.wait(1)
self.play(FadeOutAndShift(msg_split_into_thirds))
self.wait(1)
# This fold line is not yet correct
foldLine = Line(2.5 * UP + 2 * LEFT, 2.5 * DOWN + 0.966220 * RIGHT, color=BLUE)
self.play(ShowCreation(foldLine))
self.wait(1)
class Common(object):
@staticmethod
def polarToCartesian(distance, angle, center=0):
return sin(angle) * distance * UP + cos(angle) * distance * RIGHT + center