如何在 manim 中的圆上绘制等距点?
How to draw equally spaced dots on a circle in manim?
在漫画中,
如何在圆上绘制等间距的点,如下图所示?
我可以手动计算每个点的坐标并输入它们,但是有没有一种简单的方法可以在 manim 中输入点?
文档解释说 Circle
对象有一个方法 point_at_angle
。 PointAtAngle Example
point_at_angle
方法采用单个参数,即点沿圆的角度(以弧度为单位)。
下面是绘制一个绿色圆圈和圆周上 16 个红点的代码:
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)
在漫画中,
如何在圆上绘制等间距的点,如下图所示?
我可以手动计算每个点的坐标并输入它们,但是有没有一种简单的方法可以在 manim 中输入点?
文档解释说 Circle
对象有一个方法 point_at_angle
。 PointAtAngle Example
point_at_angle
方法采用单个参数,即点沿圆的角度(以弧度为单位)。
下面是绘制一个绿色圆圈和圆周上 16 个红点的代码:
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)