# 從圓到弧

March 6, 2022

## 圓的組成

``````use <polyline_join.scad>

thickness = 2;

points = [
for(a = [0:360])
];
polyline_join(points)
circle(thickness / 2, \$fn = 24);
``````

``````use <shape_circle.scad>

thickness = 2;

points = shape_circle(radius, \$fn = 12);
polygon(points);

polyline_join(points)
circle(thickness / 2, \$fn = 24);
``````

## 建立弧線

``````use <arc.scad>

\$fn = 24;

arc(radius, angle = [45, 290], width = 2);

arc(radius, angle = [45, 290], width = 2, width_mode = "LINE_OUTWARD");
}

arc(radius, angle = [45, 290], width = 2, width_mode = "LINE_INWARD");
}
``````

`arc` 模組支援 `\$fn` 等特殊變數，`width_mode` 可設定線是在圓上（預設）、圓外還是圓內，這會繪製出以下的模型：

## shape_ 的擠出

dotSCAD 有個 `shape_arc` 函式，它產生的頂點可以提供給 `polygon` 繪製多邊形，事實上 `arc` 模組內部就是基於 `shape_arc``polygon` 實現。

dotSCAD 中 shape_ 開頭的函式，除了可以給 `polygon` 繪製多邊形、作為曲線的頂點資訊，還有個作用，它們都可以透過〈2D Shape Extrusion〉模組來進行擠出。

``````use <shape_arc.scad>

\$fn = 24;
arc = shape_arc(radius, angle = [45, 290], width = 5);
ring_extrude(arc, radius = 50, angle = 270, twist = 90, scale = 2);
``````

`twist` 可以在擠出過程設定扭轉總角度，`scale` 可設定縮放級數，這會繪製出以下的模型：

``````use <shape_square.scad>