簡體   English   中英

如何在manim的圓圈上繪制等距的點?

[英]How to draw equally spaced dots on a circle in manim?

在 Manimce 中,

如何在圓上繪制等距的點,如下所示?

在此處輸入圖片說明

我可以手動計算每個點的坐標並輸入它們,但是有沒有一種簡單的方法可以在 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM