Reputation: 297
In manimce,
How to draw equally spaced dots on a circle as shown below?
I can calculate each point's coordinates by hand and input them, but is there an easy build in way to input dots in manim?
Upvotes: 0
Views: 1927
Reputation: 5425
The documentation explains that the Circle
object has a method point_at_angle
. PointAtAngle Example
The point_at_angle
method takes a single argument which is the angle of the point along the circle in radians.
Here is some code to draw a green circle and 16 red dots on its circumference:
from manim import *
class PointsOnCircle(Scene):
def construct(self):
circle = Circle(radius=3.0, color=GREEN)
# Number of points required
num_points = 16
# Calculate each angle
angles = [n * (360 / num_points) for n in range(num_points)]
# Points on circumference of circle
points = [circle.point_at_angle(n*DEGREES) for n in angles]
# Create circles at each point
circles = [Circle(radius=0.05, color=RED, fill_opacity=1).move_to(p) for p in points]
# Add the circle to the scene
self.add(circle)
# Add each of the points to the scene
for c in circles:
self.add(c)
Upvotes: 2