Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fix to Stars Mobject

Grant Sandersonf21f6619a515
diff --git a/topics/geometry.py b/topics/geometry.py
index e306b8122..946dc8057 100644
--- a/topics/geometry.py
+++ b/topics/geometry.py
@@ -1,6 +1,6 @@
from helpers import *
-from mobject import Mobject, Mobject1D
+from mobject import Mobject, Mobject1D, Point
class Dot(Mobject1D): #Use 1D density, even though 2D
DEFAULT_CONFIG = {
diff --git a/topics/three_dimensions.py b/topics/three_dimensions.py
index 809da3cd1..c995973b2 100644
--- a/topics/three_dimensions.py
+++ b/topics/three_dimensions.py
@@ -12,23 +12,18 @@ class Stars(Mobject):
"radius" : SPACE_WIDTH,
"num_points" : 1000,
}
- def __init__(self, **kwargs):
- digest_config(self, Stars, kwargs)
- Mobject.__init__(self, **kwargs)
-
def generate_points(self):
+ radii, phis, thetas = [
+ scalar*np.random.random(self.num_points)
+ for scalar in [self.radius, np.pi, 2*np.pi]
+ ]
self.add_points([
(
r * np.sin(phi)*np.cos(theta),
r * np.sin(phi)*np.sin(theta),
r * np.cos(phi)
)
- for x in range(self.num_points)
- for r, phi, theta in [[
- self.radius * random(),
- np.pi * random(),
- 2 * np.pi * random(),
- ]]
+ for r, phi, theta in zip(radii, phis, thetas)
])
class CubeWithFaces(Mobject2D):