diff --git a/unfinished/AnyToFrac.py b/AnyToFrac.py similarity index 100% rename from unfinished/AnyToFrac.py rename to AnyToFrac.py diff --git a/unfinished/FracForms.py b/FracForms.py similarity index 100% rename from unfinished/FracForms.py rename to FracForms.py diff --git a/unfinished/CubVolume.py b/LineToSquareToCube.py similarity index 55% rename from unfinished/CubVolume.py rename to LineToSquareToCube.py index 005f81e..346e9fa 100644 --- a/unfinished/CubVolume.py +++ b/LineToSquareToCube.py @@ -1,69 +1,39 @@ from manim import * -class CubeVolume(ThreeDScene): +class LineToSquareToCube(ThreeDScene): def construct(self): - - # Set the camera initial position - self.set_camera_orientation(phi=0) - - # Initialize the mobjects - # TODO, keep track of the numbers so they always show up clearly on the screen. - axes = ThreeDAxes(x_length=12,y_length=10,z_length=8) + # MathTex() mobjects st_dim_l = Line(start=DL*2,end=UL*2,color=RED) st_dim_r = st_dim_l.copy() st_dim_br = Brace(st_dim_l,direction=LEFT) - st_dim_tex = MathTex('4').next_to(st_dim_br,LEFT).scale(2) - times = MathTex('\\times').scale(2) + # The square sq = always_redraw(lambda: Polygon(st_dim_r.get_end(),st_dim_r.get_start(),st_dim_l.get_start(),st_dim_l.get_end(), color=RED,fill_color=BLUE,fill_opacity=0.75,stroke_width=4)) - arr = Arrow(start=st_dim_l.get_top(),end=UR*2,color=RED) - arr_br = Brace(arr,direction=UP) - arrs = [arr.copy().shift(DOWN*(i+1)) for i in range(4)] - + # Some arrows + arr = Arrow(start=st_dim_l.get_top(),end=UR*2,color=RED,buff=0) + arrs = [arr.copy().shift(DOWN*(i)) for i in range(5)] + arr_br = Brace(arr[0],direction=UP) arr_br_tex = MathTex('4').next_to(arr_br,UP).scale(2) - - result = MathTex('16').scale(2.5) - - cube = always_redraw(lambda:Cube(side_length=4,color=BLUE,fill_opacity=1,stroke_width=4,stroke_color=RED) - .shift(np.array([0,0,2])) - .stretch_to_fit_depth(sq.get_center()[2],about_point=axes.c2p(0,0,0))) - - rd_0_arr_dim = Arrow3D(start=np.array([2,-2,0]),end=np.array([2,-2,4]),color=RED) - rd_1_arr_dim = rd_0_arr_dim.copy().move_to(np.array([2,2,2])) - rd_2_arr_dim = rd_0_arr_dim.copy().move_to(np.array([-2,2,2])) - rd_3_arr_dim = rd_0_arr_dim.copy().move_to(np.array([-2,-2,2])) - - arrs_3d = [rd_0_arr_dim,rd_1_arr_dim,rd_2_arr_dim,rd_3_arr_dim] - - rd_dim_br = (Brace(Line3D(start=[2,-2,0],end=[2,2,0]),direction=RIGHT)) - rd_dim_tex = (MathTex('4').scale(2.5).next_to(rd_dim_br)) - - rd_dim = VGroup(rd_dim_br,rd_dim_tex).rotate(angle=PI/2,axis=X_AXIS,about_point=np.array([2,-2,0])) - - result_3d = MathTex('64').scale(2) - grp_3d = VGroup(result_3d,times,result).to_corner(DOWN) - grp_3d.arrange() + result = MathTex('16').scale(3) # Play animations self.add(sq) self.play(Create(st_dim_l)) self.play(Write(st_dim_br),Write(st_dim_tex)) self.wait() - self.play(GrowArrow(arr),run_time=0.5) - self.play(Write(arr_br_tex),Write(arr_br)) + self.play(Write(arr_br_tex),Write(arr_br)) for i in arrs: self.play(GrowArrow(i),run_time=0.5) self.wait(3) - self.play(FadeOut(arr),run_time=0.25) - + for i in arrs: self.play(FadeOut(i),run_time=0.25) @@ -76,33 +46,44 @@ def construct(self): self.wait() self.play(ReplacementTransform(VGroup(st_dim_tex,arr_br_tex,times),result)) self.play(FadeOut(st_dim_br,st_dim_tex,arr_br_tex,arr_br)) + self.play(result.animate.to_corner(DOWN)) + self.add_fixed_in_frame_mobjects(result.to_corner(DOWN)) - self.move_camera(phi=60*DEGREES,theta=-45*DEGREES, - focal_distance=20) + # Initialize mobjects + cube = always_redraw(lambda:Cube(side_length=4,color=BLUE,fill_opacity=1,stroke_width=4,stroke_color=RED) + .shift(np.array([0,0,2])) + .stretch_to_fit_depth(sq.get_center()[2],about_point=ORIGIN)) - self.remove(result) + arr_3d = Arrow3D(start=ORIGIN,end=np.array([0,0,4]),color=RED) + rd_dim_br = (Brace(Line3D(start=[2,-2,0],end=[2,2,0]),direction=RIGHT)) + rd_dim_tex = (MathTex('4').scale(3).next_to(rd_dim_br)) + rd_dim = VGroup(rd_dim_br,rd_dim_tex).rotate(angle=PI/2,axis=X_AXIS,about_point=np.array([2,-2,0])) + + exp = MathTex('16 \\times 4 = 64').scale(2) + + # Set the camera settings + self.set_camera_orientation(phi=0) + self.move_camera(phi=60*DEGREES,theta=-45*DEGREES,focal_distance=20) self.camera.set_zoom(0.75) + #self.play(Write(result)) self.wait() - for arr in arrs_3d: - self.play(Create(arr),run_time=0.2) - + self.play(Create(arr_3d),run_time=0.2) self.play(Write(rd_dim)) - - for arr in arrs_3d: - self.play(FadeOut(arr)) - - + self.play(FadeOut(arr_3d)) self.wait() - self.add(cube) - self.add_fixed_in_frame_mobjects(grp_3d) - + self.add(cube) self.play(st_dim_r.animate.move_to(np.array([-2,0,4])), st_dim_l.animate.move_to(np.array([2,0,4]))) + + self.add_fixed_in_frame_mobjects(exp) + self.play(TransformMatchingTex(result,exp)) + + #self.begin_ambient_camera_rotation(rate=PI/9) + self.wait(10) - self.play(Write(grp_3d)) - self.begin_ambient_camera_rotation(rate=PI/9) - self.wait(5) - # TODO, not completed; needs more clarifications with LaTeX and formulae. \ No newline at end of file + # Almost done + # TODO: would like to pull the 16 from the square to let it be fixed_in_frame, then add + # the other `times` and `MathTex('64')` mobjects. It will seem better this way \ No newline at end of file diff --git a/unfinished/NumsBetween.py b/NumsBetween.py similarity index 100% rename from unfinished/NumsBetween.py rename to NumsBetween.py diff --git a/unfinished/SR_Numline.py b/SR_Numline.py similarity index 100% rename from unfinished/SR_Numline.py rename to SR_Numline.py diff --git a/unfinished/S_count_l.py b/S_count_l.py similarity index 100% rename from unfinished/S_count_l.py rename to S_count_l.py diff --git a/unfinished/S_int_l.py b/S_int_l.py similarity index 100% rename from unfinished/S_int_l.py rename to S_int_l.py diff --git a/unfinished/S_nat_l.py b/S_nat_l.py similarity index 100% rename from unfinished/S_nat_l.py rename to S_nat_l.py diff --git a/unfinished/S_rat_l.py b/S_rat_l.py similarity index 100% rename from unfinished/S_rat_l.py rename to S_rat_l.py diff --git a/SpheresCuboid.py b/SpheresCuboid.py new file mode 100644 index 0000000..0576299 --- /dev/null +++ b/SpheresCuboid.py @@ -0,0 +1,125 @@ +from manim import * + +class SpheresCuboid(ThreeDScene): + def construct(self): + + # Initialize the TexTemplate + temp = TexTemplate() + temp.add_to_preamble('\\usepackage{arabtex,utf8} \n\\setcode{utf8}') + Tex.set_default(tex_template=temp) + MathTex.set_default(tex_template=temp) + + # Set the camera orientaion + self.set_camera_orientation(phi=0,theta=0,gamma=90*DEGREES) + + # Initialize mobjects + s_0 = Sphere(fill_opacity=0.5,checkerboard_colors=None,stroke_width=0) + l_0 = Line(start=LEFT,end=RIGHT,color=RED) + b_0 = Brace(Line(start=ORIGIN,end=l_0.get_end()),direction=UP) + t_0 = Tex('\\begin{arabtex}\nنق\n\\end{arabtex}',font_size=30).next_to(b_0,direction=UP,buff=0.2) + t_0_1 = VGroup(t_0,b_0).copy() + + s_1 = s_0.copy().move_to(RIGHT*2) + l_1 = l_0.copy().move_to(s_1.get_center()) + t_1 = VGroup(t_0,b_0).copy() + t_1_1 = VGroup(t_0,b_0).copy() + + s_2 = s_0.copy().move_to(LEFT*2) + l_2 = l_0.copy().move_to(s_2.get_center()) + t_2 = VGroup(t_0,b_0).copy() + t_2_1 = VGroup(t_0,b_0).copy() + + b_all = Brace(Line(start=LEFT*3,end=RIGHT*3),direction=UP) + t_all = Tex('\\begin{arabtex}\n6نق\n\\end{arabtex}',font_size=60).next_to(b_all,direction=UP) + + small_braces_group = VGroup(b_0,t_0,t_0_1,t_1,t_1_1,t_2,t_2_1) + big_brace_group = VGroup(b_all,t_all) + + # Play animations + self.play(Create(s_0)) + self.wait(2) + + self.play(Create(l_0),Write(t_0),Write(b_0)) + self.wait() + + t_0_1.save_state(); t_1_1.save_state() + + self.play(t_0_1.animate.shift(np.array([-1,0,0]))) + self.wait() + + self.play(Create(s_1),Create(s_2),run_time=0.5) + self.play(Create(l_1),Create(l_2),run_time=0.5) + self.play(t_1.animate.shift(RIGHT), + t_1_1.animate.shift(RIGHT*2), + t_2.animate.shift(LEFT*2), + t_2_1.animate.shift(LEFT*3),run_time=0.5) + self.wait(3) + + self.play(ReplacementTransform(small_braces_group,big_brace_group,remover=False)) + self.wait(3) + + t_all.save_state() + + self.play(Unwrite(big_brace_group),remover=False) + + t_all.restore() + + self.add_fixed_in_frame_mobjects(t_all.to_corner(DOWN)) + self.play(Write(t_all)) + + # TODO: + # Make another one from the other side after rotation + # Make these rectangle a base for stretching a prism which will represent the parallelopaipad + + # Set camera orientation + self.move_camera(phi=90*DEGREES,theta=-180*DEGREES,gamma=0) + + # Initialize new mobjects + t_0_1.restore(); t_1_1.restore() + + def rot_br(mob): + return (mob.rotate(-90*DEGREES,axis=Z_AXIS,about_point=l_0.get_center()) + .rotate(-90*DEGREES,axis=Y_AXIS,about_point=l_0.get_center())) + + rot_br(t_0_1) + rot_br(t_1_1) + + + s_2.save_state() + # Playing animations + self.play(Uncreate(s_2)) + self.play(l_0.animate.rotate(90*DEGREES,axis=Z_AXIS,about_point=l_0.get_center())) + + b_two_r = Brace(l_0,direction=OUT) + text_two_r = Tex('\\begin{arabtex}\n2نق\n\\end{arabtex}',font_size=30).next_to(b_two_r,direction=OUT,buff=0.2) + two_r = VGroup(b_two_r,text_two_r) + + self.play(Write(t_0_1),t_1_1.animate.shift(UP)) + self.play(ReplacementTransform(VGroup(t_0_1,t_1_1),two_r)) + self.wait() + #self.play(grp_2r_0.animate.shift(np.array([0,1,0]))) + + #self.play(ReplacementTransform(VGroup(grp_2r,grp_2r_0),two_r)) + self.play(FadeOut(two_r)) + self.play(text_two_r.animate.move_to(np.array([-3,0,-1]))) + self.add_fixed_orientation_mobjects(two_r) + + self.play(l_0.animate.rotate(90*DEGREES,axis=X_AXIS,about_point=l_0.get_center())) + + b_two_r = Brace(l_0,direction=DOWN) + text_two_r = Tex('\\begin{arabtex}\n2نق\n\\end{arabtex}',font_size=30).next_to(b_two_r,direction=DOWN,buff=0.2) + two_r = VGroup(b_two_r,text_two_r) + + self.play(Write(two_r)) + + self.wait() + + + #rec_side = Line(start=np.array([-3,1,1]),end=np.array([3,1,1]),stroke_width=4,color=RED) + #rec_other_side = rec_side.copy() + #rec_plan = always_redraw(lambda: Polygon(rec_side.get_start(),rec_side.get_end(),rec_other_side.get_end(), + # rec_other_side.get_start(),stroke_color=RED,fill_color=PURE_BLUE,fill_opacity=0.3)) + + #self.add(rec_plan) + #self.play(rec_side.animate.move_to(np.array([0,-1,1]))) + #self.wait() \ No newline at end of file diff --git a/__pycache__/1p1t_1lesson.cpython-311.pyc b/__pycache__/1p1t_1lesson.cpython-311.pyc deleted file mode 100644 index aa60feb..0000000 Binary files a/__pycache__/1p1t_1lesson.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/1p1t_lesson.cpython-311.pyc b/__pycache__/1p1t_lesson.cpython-311.pyc deleted file mode 100644 index d59e902..0000000 Binary files a/__pycache__/1p1t_lesson.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/Scenes.cpython-311.pyc b/__pycache__/Scenes.cpython-311.pyc deleted file mode 100644 index 201826d..0000000 Binary files a/__pycache__/Scenes.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/demo1.cpython-311.pyc b/__pycache__/demo1.cpython-311.pyc deleted file mode 100644 index 2bccce4..0000000 Binary files a/__pycache__/demo1.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/demo_equation.cpython-311.pyc b/__pycache__/demo_equation.cpython-311.pyc deleted file mode 100644 index be8ed87..0000000 Binary files a/__pycache__/demo_equation.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/discord.cpython-311.pyc b/__pycache__/discord.cpython-311.pyc deleted file mode 100644 index 0c0415e..0000000 Binary files a/__pycache__/discord.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/main.cpython-311.pyc b/__pycache__/main.cpython-311.pyc deleted file mode 100644 index 1ccd9f0..0000000 Binary files a/__pycache__/main.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/practice.cpython-311.pyc b/__pycache__/practice.cpython-311.pyc deleted file mode 100644 index c223cc0..0000000 Binary files a/__pycache__/practice.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/re_1p1t_lesson.cpython-311.pyc b/__pycache__/re_1p1t_lesson.cpython-311.pyc deleted file mode 100644 index 1ba5092..0000000 Binary files a/__pycache__/re_1p1t_lesson.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/try_manimlib.cpython-311.pyc b/__pycache__/try_manimlib.cpython-311.pyc deleted file mode 100644 index e2a6308..0000000 Binary files a/__pycache__/try_manimlib.cpython-311.pyc and /dev/null differ diff --git a/challenges.md b/challenges.md index 6836a30..560156c 100644 --- a/challenges.md +++ b/challenges.md @@ -42,8 +42,6 @@ ## SpheresCuboid scene -### Uncomplete scene - > Explains a specific problem in a textbook about the ration between 3 spheres and the box that contains them. 1. I wanted to get the braces to completely be replaced with the bigger one, but, as it seems in the video that one of the braces wasn't replaced. diff --git a/manim.cfg b/manim.cfg index 26674ca..a9e0a42 100644 --- a/manim.cfg +++ b/manim.cfg @@ -4,5 +4,4 @@ pixel_height = 720 pixel_width = 1280 background_color = BLACK background_opacity = 1 -scene_names = DefaultTemplate - +scene_names = DefaultTemplate \ No newline at end of file diff --git a/unfinished/SpheresCuboid.py b/unfinished/SpheresCuboid.py deleted file mode 100644 index 82eb39c..0000000 --- a/unfinished/SpheresCuboid.py +++ /dev/null @@ -1,61 +0,0 @@ -from manim import * - -class SpheresCuboid(ThreeDScene): - def construct(self): - - # Initialize the TexTemplate - temp = TexTemplate() - temp.add_to_preamble('\\usepackage{arabtex,utf8} \n\\setcode{utf8}') - Tex.set_default(tex_template=temp) - MathTex.set_default(tex_template=temp) - - # Set camera Orientation - self.set_camera_orientation(phi=0) - - # Initialize mobjects - s_0 = Sphere(fill_opacity=0.5,checkerboard_colors=None,stroke_width=0) - l_0 = Line3D(start=np.array([-1,0,0]),end=np.array([1,0,0]),color=RED) - b_0 = Brace(Line3D(start=ORIGIN,end=np.array([1,0,0])),direction=UP) - t_0 = Tex('\\begin{arabtex}\nنق\n\\end{arabtex}',font_size=30).next_to(b_0,direction=UP,buff=0.2) - t_0_1 = VGroup(t_0,b_0).copy() - - s_1 = s_0.copy().move_to(np.array([2,0,0])) - l_1 = l_0.copy().move_to(s_1.get_center()) - t_1 = VGroup(t_0,b_0).copy() - t_1_1 = VGroup(t_0,b_0).copy() - - s_2 = s_0.copy().move_to(np.array([-2,0,0])) - l_2 = l_0.copy().move_to(s_2.get_center()) - t_2 = VGroup(t_0,b_0).copy() - t_2_1 = VGroup(t_0,b_0).copy() - - b_all = Brace(Line3D(start=np.array([-3,0,0]),end=np.array([3,0,0])),direction=UP) - t_all = Tex('\\begin{arabtex}\n6نق\n\\end{arabtex}',font_size=60).next_to(b_all,direction=UP) - - # Play animations - self.play(Create(s_0)) - self.wait(2) - - self.play(Create(l_0),Write(t_0),Write(b_0)) - self.wait() - - self.play(t_0_1.animate.shift(np.array([-1,0,0]))) - self.wait() - - self.play(Create(s_1),Create(s_2),run_time=0.5) - self.play(Create(l_1),Create(l_2),run_time=0.5) - self.play(t_1.animate.shift(np.array([1,0,0])), - t_1_1.animate.shift(np.array([2,0,0])), - t_2.animate.shift(np.array([-2,0,0])), - t_2_1.animate.shift(np.array([-3,0,0])),run_time=0.5) - self.wait() - # TODO, the remaining brace behind at [0.5,0,0] has to be removed - # you have to think or find a way to make less redundant variables instead - self.play(ReplacementTransform(Group(t_0,t_0_1, - t_1,t_1_1, - t_2,t_2_1),VGroup(b_all,t_all), - replace_with_target_in_scene=True)) - self.wait() - - #self.play() - #self.wait()