summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py
diff options
context:
space:
mode:
authorPurusharth Saxena2020-07-25 18:54:35 +0530
committerGitHub2020-07-25 18:54:35 +0530
commit15fc46198f69a6563b0348491efdf88a2dca3ef7 (patch)
treecd21ca0431f4c170387110f1e957d42ecd197ae2 /FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py
parent4b038d81daa0c700c057e65daa6afe2344f1501f (diff)
parent8011e2c8f700f1aee69fbbc5938ed68cc90d8f02 (diff)
downloadFSF-mathematics-python-code-archive-15fc46198f69a6563b0348491efdf88a2dca3ef7.tar.gz
FSF-mathematics-python-code-archive-15fc46198f69a6563b0348491efdf88a2dca3ef7.tar.bz2
FSF-mathematics-python-code-archive-15fc46198f69a6563b0348491efdf88a2dca3ef7.zip
Merge pull request #92 from nishanpoojary/master
Updated gifs and scripts
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py')
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py104
1 files changed, 36 insertions, 68 deletions
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py
index 86239ae..fcbc410 100644
--- a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py
@@ -4,28 +4,24 @@ class Sphere(ThreeDScene):
def construct(self):
axes = ThreeDAxes() # creates a 3D Axis
- text3d = TextMobject(r"$f(x,y) \rightarrow Point(x,y,z)$")
- text3d1 = TextMobject(r"$f(x,y) \rightarrow Point(x,y, \sqrt{r^2 - x^2 - y^2})$")
- self.add_fixed_in_frame_mobjects(text3d)
- text3d.scale(0.7)
+ text3d1 = TextMobject(r"$z = f(x,y) = \sqrt{r^2 - x^2 - y^2}$")
+
text3d1.scale(0.7)
- text3d.to_corner(UL)
+
text3d1.to_corner(UL)
- text3d.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
text3d1.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
- self.play(Write(text3d))
+ self.play(Write(text3d1))
self.wait(1)
- self.play(Transform(text3d,text3d1))
self.add_fixed_in_frame_mobjects(text3d1)
- self.play(FadeOut(text3d))
sphere = ParametricSurface(
lambda u, v: np.array([
2*np.sin(u)*np.cos(v),
2*np.sin(u)*np.sin(v),
2*np.cos(u)
- ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI,checkerboard_colors=[RED_D, RED_E],
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[RED_D, RED_E],
resolution=(15, 32)).scale(1)
@@ -53,8 +49,8 @@ class Sphere(ThreeDScene):
dot_x_y1 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([-1,1,0]))
dot_x_y_z1 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([-1,1,1.414]))
- dot_x_y_z_1 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([-1,1,-1.414]))
- line1 = DashedLine(np.array([-1,1,-1.414]), np.array([-1,1,1.414]), color = YELLOW_C)
+
+ line1 = DashedLine(np.array([-1,1,0]), np.array([-1,1,1.414]), color = YELLOW_C)
point_x_y1 = TexMobject("(-1,1,0)").set_color(BLUE_C).move_to(np.array([-1.5,1.5,0])).scale(0.5)
point_x_y_z1 = TexMobject("(-1,1,\\sqrt{r^2 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
@@ -62,38 +58,32 @@ class Sphere(ThreeDScene):
point_x_y_z1_3 = TexMobject("(-1,1,\\sqrt{4 - 1 - 1})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
point_x_y_z1_4 = TexMobject("(-1,1,\\sqrt{2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
point_x_y_z1_5 = TexMobject("(-1,1,1.414)").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
-
- point_x_y_z_1 = TexMobject("(-1,1,\\sqrt{r^2 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
- point_x_y_z_1_2 = TexMobject("(-1,1,\\sqrt{4 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
- point_x_y_z_1_3 = TexMobject("(-1,1,\\sqrt{4 - 1 - 1})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
- point_x_y_z_1_4 = TexMobject("(-1,1,\\sqrt{2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
- point_x_y_z_1_5 = TexMobject("(-1,1,-1.414)").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
-
+
self.play(ShowCreation(dot_x_y1))
self.add_fixed_orientation_mobjects(point_x_y1)
- self.play(ShowCreation(dot_x_y_z1), ShowCreation(dot_x_y_z_1), ShowCreation(line1))
- self.add_fixed_orientation_mobjects(point_x_y_z1, point_x_y_z_1)
+ self.play(ShowCreation(dot_x_y_z1), ShowCreation(line1))
+ self.add_fixed_orientation_mobjects(point_x_y_z1)
self.wait(0.5)
- self.play(ReplacementTransform(point_x_y_z1,point_x_y_z1_2), ReplacementTransform(point_x_y_z_1,point_x_y_z_1_2))
- self.add_fixed_orientation_mobjects(point_x_y_z1_2, point_x_y_z_1_2)
+ self.play(ReplacementTransform(point_x_y_z1,point_x_y_z1_2))
+ self.add_fixed_orientation_mobjects(point_x_y_z1_2)
self.wait(0.5)
- self.play(ReplacementTransform(point_x_y_z1_2,point_x_y_z1_3), ReplacementTransform(point_x_y_z_1_2,point_x_y_z_1_3))
- self.add_fixed_orientation_mobjects(point_x_y_z1_3, point_x_y_z_1_3)
+ self.play(ReplacementTransform(point_x_y_z1_2,point_x_y_z1_3))
+ self.add_fixed_orientation_mobjects(point_x_y_z1_3)
self.wait(0.5)
- self.play(ReplacementTransform(point_x_y_z1_3,point_x_y_z1_4), ReplacementTransform(point_x_y_z_1_3,point_x_y_z_1_4))
- self.add_fixed_orientation_mobjects(point_x_y_z1_4, point_x_y_z_1_4)
+ self.play(ReplacementTransform(point_x_y_z1_3,point_x_y_z1_4))
+ self.add_fixed_orientation_mobjects(point_x_y_z1_4)
self.wait(0.5)
- self.play(ReplacementTransform(point_x_y_z1_4,point_x_y_z1_5), ReplacementTransform(point_x_y_z_1_4,point_x_y_z_1_5))
- self.add_fixed_orientation_mobjects(point_x_y_z1_5, point_x_y_z_1_5)
+ self.play(ReplacementTransform(point_x_y_z1_4,point_x_y_z1_5))
+ self.add_fixed_orientation_mobjects(point_x_y_z1_5)
dot_x_y2 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([0.5,-0.5,0]))
dot_x_y_z2 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([0.5,-0.5,1.87]))
- dot_x_y_z_2 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([0.5,-0.5,-1.87]))
- line2 = DashedLine(np.array([0.5,-0.5,-1.87]), np.array([0.5,-0.5,1.87]), color = YELLOW_C)
+
+ line2 = DashedLine(np.array([0.5,-0.5,0]), np.array([0.5,-0.5,1.87]), color = YELLOW_C)
point_x_y2 = TexMobject("(0.5,-0.5,0)").set_color(BLUE_C).move_to(np.array([1.5,-1.5,0])).scale(0.5)
point_x_y_z2 = TexMobject("(0.5,-0.5,\\sqrt{r^2 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
@@ -101,41 +91,35 @@ class Sphere(ThreeDScene):
point_x_y_z2_3 = TexMobject("(0.5,-0.5,\\sqrt{4 - 0.25 - 0.25})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
point_x_y_z2_4 = TexMobject("(0.5,-0.5,\\sqrt{3.5})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
point_x_y_z2_5 = TexMobject("(0.5,-0.5,1.87)").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
-
- point_x_y_z_2 = TexMobject("(0.5,-0.5,\\sqrt{r^2 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
- point_x_y_z_2_2 = TexMobject("(0.5,-0.5,\\sqrt{4 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
- point_x_y_z_2_3 = TexMobject("(0.5,-0.5,\\sqrt{4 - 0.25 - 0.25})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
- point_x_y_z_2_4 = TexMobject("(0.5,-0.5,\\sqrt{3.5})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
- point_x_y_z_2_5 = TexMobject("(0.5,-0.5,-1.87)").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
-
+
self.play(ShowCreation(dot_x_y2))
self.add_fixed_orientation_mobjects(point_x_y2)
- self.play(ShowCreation(dot_x_y_z2), ShowCreation(dot_x_y_z_2), ShowCreation(line2))
- self.add_fixed_orientation_mobjects(point_x_y_z2, point_x_y_z_2)
+ self.play(ShowCreation(dot_x_y_z2), ShowCreation(line2))
+ self.add_fixed_orientation_mobjects(point_x_y_z2)
self.wait(0.5)
- self.play(ReplacementTransform(point_x_y_z2,point_x_y_z2_2), ReplacementTransform(point_x_y_z_2,point_x_y_z_2_2))
- self.add_fixed_orientation_mobjects(point_x_y_z2_2, point_x_y_z_2_2)
+ self.play(ReplacementTransform(point_x_y_z2,point_x_y_z2_2))
+ self.add_fixed_orientation_mobjects(point_x_y_z2_2)
self.wait(0.5)
- self.play(ReplacementTransform(point_x_y_z2_2,point_x_y_z2_3), ReplacementTransform(point_x_y_z_2_2,point_x_y_z_2_3))
- self.add_fixed_orientation_mobjects(point_x_y_z2_3, point_x_y_z_2_3)
+ self.play(ReplacementTransform(point_x_y_z2_2,point_x_y_z2_3))
+ self.add_fixed_orientation_mobjects(point_x_y_z2_3)
self.wait(0.5)
- self.play(ReplacementTransform(point_x_y_z2_3,point_x_y_z2_4), ReplacementTransform(point_x_y_z_2_3,point_x_y_z_2_4))
- self.add_fixed_orientation_mobjects(point_x_y_z2_4, point_x_y_z_2_4)
+ self.play(ReplacementTransform(point_x_y_z2_3,point_x_y_z2_4))
+ self.add_fixed_orientation_mobjects(point_x_y_z2_4)
self.wait(0.5)
- self.play(ReplacementTransform(point_x_y_z2_4,point_x_y_z2_5), ReplacementTransform(point_x_y_z_2_4,point_x_y_z_2_5))
- self.add_fixed_orientation_mobjects(point_x_y_z2_5, point_x_y_z_2_5)
+ self.play(ReplacementTransform(point_x_y_z2_4,point_x_y_z2_5))
+ self.add_fixed_orientation_mobjects(point_x_y_z2_5)
- self.play(FadeOut(point_x_y1), FadeOut(point_x_y_z1_5), FadeOut(point_x_y_z_1_5), FadeOut(dot_x_y1), FadeOut(dot_x_y_z1), FadeOut(dot_x_y_z_1), FadeOut(line1))
- self.play(FadeOut(point_x_y2), FadeOut(point_x_y_z2_5), FadeOut(point_x_y_z_2_5), FadeOut(dot_x_y2), FadeOut(dot_x_y_z2), FadeOut(dot_x_y_z_2), FadeOut(line2))
+ self.play(FadeOut(point_x_y1), FadeOut(point_x_y_z1_5))
+ self.play(FadeOut(point_x_y2), FadeOut(point_x_y_z2_5))
sphere_final = []
- for u in range(0, 180, 15):
+ for u in range(0, 90, 15):
sphere_points1 = [np.array([2*np.sin(u*DEGREES)*np.cos(v*DEGREES), 2*np.sin(u*DEGREES)*np.sin(v*DEGREES), 2*np.cos(u*DEGREES)]) for v in range(0, 370, 10)]
sphere_dots1 = [Dot().scale(0.75).set_fill(RED_C).move_to(pts) for pts in sphere_points1]
@@ -158,20 +142,4 @@ class Sphere(ThreeDScene):
self.begin_ambient_camera_rotation(rate=0.5)
self.wait(3)
self.play(ReplacementTransform(sphere_final_with_dots, sphere))
- self.wait(5)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ self.wait(5) \ No newline at end of file