Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Bugfix: Several fixes and improvements for PointCloundDot (#947)

Hugues Devimeux9687bd427c84
diff --git a/manim/constants.py b/manim/constants.py
index a51e79985..e70f006de 100644
--- a/manim/constants.py
+++ b/manim/constants.py
@@ -101,7 +101,7 @@ DEFAULT_WAIT_TIME: float = 1.0
# Misc
DEFAULT_POINT_DENSITY_2D: int = 25
-DEFAULT_POINT_DENSITY_1D: int = 250
+DEFAULT_POINT_DENSITY_1D: int = 10
DEFAULT_STROKE_WIDTH: int = 4
# Mathematical constants
diff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.py
index 954772ff3..fe7be9dbe 100644
--- a/manim/mobject/types/point_cloud_mobject.py
+++ b/manim/mobject/types/point_cloud_mobject.py
@@ -214,7 +214,7 @@ class PointCloudDot(Mobject1D):
def __init__(
self,
center=ORIGIN,
- radius=0.075,
+ radius=2.0,
stroke_width=2,
density=DEFAULT_POINT_DENSITY_1D,
color=YELLOW,
@@ -235,8 +235,11 @@ class PointCloudDot(Mobject1D):
self.add_points(
[
r * (np.cos(theta) * RIGHT + np.sin(theta) * UP)
- for r in np.arange(0, self.radius, self.epsilon)
- for theta in np.arange(0, 2 * np.pi, self.epsilon / r)
+ for r in np.arange(self.epsilon, self.radius, self.epsilon)
+ # Num is equal to int(stop - start)/ (step + 1) reformulated.
+ for theta in np.linspace(
+ 0, 2 * np.pi, num=int(2 * np.pi * (r + self.epsilon) / self.epsilon)
+ )
]
)
diff --git a/tests/control_data/graphical_units_data/mobjects/PointCloudDotTest.npz b/tests/control_data/graphical_units_data/mobjects/PointCloudDotTest.npz
new file mode 100644
index 000000000..5e523ae8c
Binary files /dev/null and b/tests/control_data/graphical_units_data/mobjects/PointCloudDotTest.npz differ
diff --git a/tests/test_graphical_units/test_mobjects.py b/tests/test_graphical_units/test_mobjects.py
new file mode 100644
index 000000000..17f23d739
--- /dev/null
+++ b/tests/test_graphical_units/test_mobjects.py
@@ -0,0 +1,19 @@
+import pytest
+
+from manim import *
+from ..utils.testing_utils import get_scenes_to_test
+from ..utils.GraphicalUnitTester import GraphicalUnitTester
+
+
+class PointCloudDotTest(ThreeDScene):
+ def construct(self):
+ p = PointCloudDot()
+ self.play(Animation(p))
+
+
+MODULE_NAME = "mobjects"
+
+
[email protected]("scene_to_test", get_scenes_to_test(__name__), indirect=False)
+def test_scene(scene_to_test, tmpdir, show_diff):
+ GraphicalUnitTester(scene_to_test[1], MODULE_NAME, tmpdir).test(show_diff=show_diff)