# 阿基米德螺線

``````module line(point1, point2, width = 1, cap_round = true) {
angle = 90 - atan((point2[1] - point1[1]) / (point2[0] - point1[0]));
offset_x = 0.5 * width * cos(angle);
offset_y = 0.5 * width * sin(angle);

offset1 = [-offset_x, offset_y];
offset2 = [offset_x, -offset_y];

if(cap_round) {
translate(point1) circle(d = width, \$fn = 24);
translate(point2) circle(d = width, \$fn = 24);
}

polygon(points=[
point1 + offset1, point2 + offset1,
point2 + offset2, point1 + offset2
]);
}

module polyline(points, width = 1) {
module polyline_inner(points, index) {
if(index < len(points)) {
line(points[index - 1], points[index], width);
polyline_inner(points, index + 1);
}
}

polyline_inner(points, 1);
}

PI = 3.14159;
step = 0.25;
circles = 5;
arm_len = 10;

a = arm_len / 2 / PI;
points = [for(theta = [0:step:2 * PI * circles])
[a * theta * cos(theta * 57.2958), a * theta * sin(theta * 57.2958)]
];

polyline(points, 1);
``````

``````PI = 3.14159;
step = 0.2;
circles = 5;
arm_len = 10;

a = arm_len / 2 / PI;
for(theta = [0:step:2 * PI * circles]) {
rotate(theta * 57.2958)
translate([a * theta, 0, 0])
circle(1, \$fn = 24);
}
``````

# 找出徑度的增量

``````PI = 3.14159;

dots = 100;            // 點的數目
dot_dist = 5;          // 點的距離
arm_len = 5;           // 臂長
init_radian = PI * 4;  // 初始角（第一個點的角）

a = arm_len / 2 / PI;

function r(a, theta) = a * theta;

acos((2 * pow(r(a, theta), 2) - pow(l, 2)) / (2 * pow(r(a, theta), 2))) / 180 * PI;

count == n ? radians : (
a,
l,
concat(
),
n,
count + 1)
);