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

How to specify exact size of spiral for printing

我想画阿基米德螺旋线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 + 5*t 在你的代码中)对应于它每弧度移动多远,所以要增加 6mm2*pi 弧度你会设置那个常量到 6/(2*pi) * t 所以它看起来像:

r = (6/(2*pi) * t)
x = r * cos(t)
y = r * sin(t)

使直径为 30 的部分是 r 的最后一个值 i

i = 199
t = i/20 * pi # just under 10*pi
r = (6/(2*pi) * t) # 10pi/2pi = 5, 5*6 = 30 mm :)