# 兩點決定一線

``````radius = 10;
hull() {
}
``````

``````module line3D(p1, p2, thickness, fn = 24) {
\$fn = fn;

hull() {
translate(p1) sphere(thickness / 2);
translate(p2) sphere(thickness / 2);
}
}

line3D([1, 1, 1], [10, 10, 10], 1, 3);
``````

# polyline3D

``````module line3D(p1, p2, thickness, fn = 24) {
\$fn = fn;

hull() {
translate(p1) sphere(thickness / 2);
translate(p2) sphere(thickness / 2);
}
}

module polyline3D(points, thickness, fn) {
module polyline3D_inner(points, index) {
if(index < len(points)) {
line3D(points[index - 1], points[index], thickness, fn);
polyline3D_inner(points, index + 1);
}
}

polyline3D_inner(points, 1);
}

points = [[1, 2, 3], [4, -5, -6], [-1, -3, -5], [0, 0, 0]];
polyline3D(points, 1, 3);
``````

# 試著做螺線

``````module line3D(p1, p2, thickness, fn = 24) {
\$fn = fn;

hull() {
translate(p1) sphere(thickness / 2);
translate(p2) sphere(thickness / 2);
}
}

module polyline3D(points, thickness, fn) {
module polyline3D_inner(points, index) {
if(index < len(points)) {
line3D(points[index - 1], points[index], thickness, fn);
polyline3D_inner(points, index + 1);
}
}

polyline3D_inner(points, 1);
}

r = 20;
h = 5;
fa = 15;
circles = 10;

points = [
for(a = [0:fa:360 * circles])
[r * cos(a), r * sin(a), h / (360 / fa) * (a / fa)]
];
polyline3D(points, 1, 3);
``````

``````module line3D(p1, p2, thickness, fn = 24) {
\$fn = fn;

hull() {
translate(p1) sphere(thickness / 2);
translate(p2) sphere(thickness / 2);
}
}

module polyline3D(points, thickness, fn) {
module polyline3D_inner(points, index) {
if(index < len(points)) {
line3D(points[index - 1], points[index], thickness, fn);
polyline3D_inner(points, index + 1);
}
}

polyline3D_inner(points, 1);
}

r = 50;
points = [
for(a = [0:180])
[r * cos(-90 + a) * cos(a), r * cos(-90 + a) * sin(a), r * sin(-90 + a)]
];

for(i = [0:7]) {
rotate(45 * i) polyline3D(points, 2, 3);
}
``````