如何指定要打印的螺旋的确切尺寸

时间:2020-08-08 21:07:13

标签: python turtle-graphics python-turtle

我想绘制阿奇米德螺旋https://en.m.wikipedia.org/wiki/Archimedean_spiral,其环间间隙为6mm,总直径为30mm。这是我打印时应具有的尺寸。我的MWE(来自Rosetta Stone)是:

from turtle import *
from math import *
color("blue")
down()
for i in range(200):
    t = i / 20 * pi
    x = (1 + 5 * t) * cos(t)
    y = (1 + 5 * t) * sin(t)
    goto(x, y)
up()
done()

如何设置确切尺寸?

1 个答案:

答案 0 :(得分:1)

这实际上与代码无关,只是使它正常工作的数学方法。

前面的常量(代码中的1 + 5*t)对应于每个弧度将其移动多远,因此,要使每个6mm弧度增加2*pi,您可以将该常量设置为{ {1}}看起来像这样:

6/(2*pi) * t

使直径为30的部分是r = (6/(2*pi) * t) x = r * cos(t) y = r * sin(t) 的最后一个值r

i
相关问题