@@ -4,28 +4,24 @@ class Sphere(ThreeDScene):
4
4
def construct (self ):
5
5
axes = ThreeDAxes () # creates a 3D Axis
6
6
7
- text3d = TextMobject (r"$f(x,y) \rightarrow Point(x,y,z)$" )
8
- text3d1 = TextMobject (r"$f(x,y) \rightarrow Point(x,y, \sqrt{r^2 - x^2 - y^2})$" )
9
- self .add_fixed_in_frame_mobjects (text3d )
10
- text3d .scale (0.7 )
7
+ text3d1 = TextMobject (r"$z = f(x,y) = \sqrt{r^2 - x^2 - y^2}$" )
8
+
11
9
text3d1 .scale (0.7 )
12
- text3d . to_corner ( UL )
10
+
13
11
text3d1 .to_corner (UL )
14
- text3d . set_color_by_gradient ( RED , ORANGE , YELLOW , GREEN , BLUE , PURPLE )
12
+
15
13
text3d1 .set_color_by_gradient (RED , ORANGE , YELLOW , GREEN , BLUE , PURPLE )
16
- self .play (Write (text3d ))
14
+ self .play (Write (text3d1 ))
17
15
self .wait (1 )
18
16
19
- self .play (Transform (text3d ,text3d1 ))
20
17
self .add_fixed_in_frame_mobjects (text3d1 )
21
- self .play (FadeOut (text3d ))
22
18
23
19
sphere = ParametricSurface (
24
20
lambda u , v : np .array ([
25
21
2 * np .sin (u )* np .cos (v ),
26
22
2 * np .sin (u )* np .sin (v ),
27
23
2 * np .cos (u )
28
- ]),u_min = 0 ,u_max = PI ,v_min = 0 ,v_max = 2 * PI ,checkerboard_colors = [RED_D , RED_E ],
24
+ ]),u_min = 0 ,u_max = PI / 2 ,v_min = 0 ,v_max = 2 * PI ,checkerboard_colors = [RED_D , RED_E ],
29
25
resolution = (15 , 32 )).scale (1 )
30
26
31
27
@@ -53,89 +49,77 @@ def construct(self):
53
49
54
50
dot_x_y1 = Dot ().scale (0.75 ).set_fill (RED_C ).move_to (np .array ([- 1 ,1 ,0 ]))
55
51
dot_x_y_z1 = Dot ().scale (0.75 ).set_fill (RED_C ).move_to (np .array ([- 1 ,1 ,1.414 ]))
56
- dot_x_y_z_1 = Dot (). scale ( 0.75 ). set_fill ( RED_C ). move_to ( np . array ([ - 1 , 1 , - 1.414 ]))
57
- line1 = DashedLine (np .array ([- 1 ,1 ,- 1.414 ]), np .array ([- 1 ,1 ,1.414 ]), color = YELLOW_C )
52
+
53
+ line1 = DashedLine (np .array ([- 1 ,1 ,0 ]), np .array ([- 1 ,1 ,1.414 ]), color = YELLOW_C )
58
54
59
55
point_x_y1 = TexMobject ("(-1,1,0)" ).set_color (BLUE_C ).move_to (np .array ([- 1.5 ,1.5 ,0 ])).scale (0.5 )
60
56
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 )
61
57
point_x_y_z1_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 )
62
58
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 )
63
59
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 )
64
60
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 )
65
-
66
- 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 )
67
- 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 )
68
- 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 )
69
- 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 )
70
- 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 )
71
-
61
+
72
62
73
63
self .play (ShowCreation (dot_x_y1 ))
74
64
self .add_fixed_orientation_mobjects (point_x_y1 )
75
- self .play (ShowCreation (dot_x_y_z1 ), ShowCreation (dot_x_y_z_1 ), ShowCreation ( line1 ))
76
- self .add_fixed_orientation_mobjects (point_x_y_z1 , point_x_y_z_1 )
65
+ self .play (ShowCreation (dot_x_y_z1 ), ShowCreation (line1 ))
66
+ self .add_fixed_orientation_mobjects (point_x_y_z1 )
77
67
self .wait (0.5 )
78
- self .play (ReplacementTransform (point_x_y_z1 ,point_x_y_z1_2 ), ReplacementTransform ( point_x_y_z_1 , point_x_y_z_1_2 ) )
79
- self .add_fixed_orientation_mobjects (point_x_y_z1_2 , point_x_y_z_1_2 )
68
+ self .play (ReplacementTransform (point_x_y_z1 ,point_x_y_z1_2 ))
69
+ self .add_fixed_orientation_mobjects (point_x_y_z1_2 )
80
70
81
71
self .wait (0.5 )
82
- 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 ) )
83
- self .add_fixed_orientation_mobjects (point_x_y_z1_3 , point_x_y_z_1_3 )
72
+ self .play (ReplacementTransform (point_x_y_z1_2 ,point_x_y_z1_3 ))
73
+ self .add_fixed_orientation_mobjects (point_x_y_z1_3 )
84
74
self .wait (0.5 )
85
- 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 ) )
86
- self .add_fixed_orientation_mobjects (point_x_y_z1_4 , point_x_y_z_1_4 )
75
+ self .play (ReplacementTransform (point_x_y_z1_3 ,point_x_y_z1_4 ))
76
+ self .add_fixed_orientation_mobjects (point_x_y_z1_4 )
87
77
self .wait (0.5 )
88
- 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 ) )
89
- self .add_fixed_orientation_mobjects (point_x_y_z1_5 , point_x_y_z_1_5 )
78
+ self .play (ReplacementTransform (point_x_y_z1_4 ,point_x_y_z1_5 ))
79
+ self .add_fixed_orientation_mobjects (point_x_y_z1_5 )
90
80
91
81
92
82
93
83
dot_x_y2 = Dot ().scale (0.75 ).set_fill (RED_C ).move_to (np .array ([0.5 ,- 0.5 ,0 ]))
94
84
dot_x_y_z2 = Dot ().scale (0.75 ).set_fill (RED_C ).move_to (np .array ([0.5 ,- 0.5 ,1.87 ]))
95
- dot_x_y_z_2 = Dot (). scale ( 0.75 ). set_fill ( RED_C ). move_to ( np . array ([ 0.5 , - 0.5 , - 1.87 ]))
96
- line2 = DashedLine (np .array ([0.5 ,- 0.5 ,- 1.87 ]), np .array ([0.5 ,- 0.5 ,1.87 ]), color = YELLOW_C )
85
+
86
+ line2 = DashedLine (np .array ([0.5 ,- 0.5 ,0 ]), np .array ([0.5 ,- 0.5 ,1.87 ]), color = YELLOW_C )
97
87
98
88
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 )
99
89
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 )
100
90
point_x_y_z2_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 )
101
91
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 )
102
92
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 )
103
93
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 )
104
-
105
- 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 )
106
- 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 )
107
- 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 )
108
- 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 )
109
- 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 )
110
-
94
+
111
95
112
96
self .play (ShowCreation (dot_x_y2 ))
113
97
self .add_fixed_orientation_mobjects (point_x_y2 )
114
- self .play (ShowCreation (dot_x_y_z2 ), ShowCreation (dot_x_y_z_2 ), ShowCreation ( line2 ))
115
- self .add_fixed_orientation_mobjects (point_x_y_z2 , point_x_y_z_2 )
98
+ self .play (ShowCreation (dot_x_y_z2 ), ShowCreation (line2 ))
99
+ self .add_fixed_orientation_mobjects (point_x_y_z2 )
116
100
self .wait (0.5 )
117
- self .play (ReplacementTransform (point_x_y_z2 ,point_x_y_z2_2 ), ReplacementTransform ( point_x_y_z_2 , point_x_y_z_2_2 ) )
118
- self .add_fixed_orientation_mobjects (point_x_y_z2_2 , point_x_y_z_2_2 )
101
+ self .play (ReplacementTransform (point_x_y_z2 ,point_x_y_z2_2 ))
102
+ self .add_fixed_orientation_mobjects (point_x_y_z2_2 )
119
103
120
104
self .wait (0.5 )
121
- 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 ) )
122
- self .add_fixed_orientation_mobjects (point_x_y_z2_3 , point_x_y_z_2_3 )
105
+ self .play (ReplacementTransform (point_x_y_z2_2 ,point_x_y_z2_3 ))
106
+ self .add_fixed_orientation_mobjects (point_x_y_z2_3 )
123
107
self .wait (0.5 )
124
- 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 ) )
125
- self .add_fixed_orientation_mobjects (point_x_y_z2_4 , point_x_y_z_2_4 )
108
+ self .play (ReplacementTransform (point_x_y_z2_3 ,point_x_y_z2_4 ))
109
+ self .add_fixed_orientation_mobjects (point_x_y_z2_4 )
126
110
self .wait (0.5 )
127
- 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 ) )
128
- self .add_fixed_orientation_mobjects (point_x_y_z2_5 , point_x_y_z_2_5 )
111
+ self .play (ReplacementTransform (point_x_y_z2_4 ,point_x_y_z2_5 ))
112
+ self .add_fixed_orientation_mobjects (point_x_y_z2_5 )
129
113
130
- 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 ) )
131
- 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 ) )
114
+ self .play (FadeOut (point_x_y1 ), FadeOut (point_x_y_z1_5 ))
115
+ self .play (FadeOut (point_x_y2 ), FadeOut (point_x_y_z2_5 ))
132
116
133
117
134
118
135
119
136
120
sphere_final = []
137
121
138
- for u in range (0 , 180 , 15 ):
122
+ for u in range (0 , 90 , 15 ):
139
123
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 )]
140
124
sphere_dots1 = [Dot ().scale (0.75 ).set_fill (RED_C ).move_to (pts ) for pts in sphere_points1 ]
141
125
@@ -158,20 +142,4 @@ def construct(self):
158
142
self .begin_ambient_camera_rotation (rate = 0.5 )
159
143
self .wait (3 )
160
144
self .play (ReplacementTransform (sphere_final_with_dots , sphere ))
161
- self .wait (5 )
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
145
+ self .wait (5 )
0 commit comments