[英]How to draw equally spaced dots on a circle in manim?
文檔解釋了Circle
對象有一個方法point_at_angle
。 PointAtAngle 示例
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.