2017-04-30 20:05:17 +08:00
# polysections
Crosscutting a tube-like shape at different points gets several cross-sections. This module can operate reversely. It uses cross-sections to construct a tube-like shape. For example, imagine that you have the following cross-sections:

This module can use them to construct the following model:

Looks like extruding along the path? Yes, it can perform the task; however, it's more flexible.
2017-05-27 16:16:11 +08:00
You can also view it as a better polyline3d module if you want. If you have only the points of a path, using `polyline3d` or `hull_polyline3d` is a simple solution. If you know the cross sections along a path, you can use `polysections` to do more.
2017-04-30 20:05:17 +08:00
2017-05-27 16:14:22 +08:00
When using this module, you should use points to represent each cross section. The points of your cross section should have count-clockwise indexes. For example:
2017-05-10 16:16:27 +08:00
2017-05-16 09:47:15 +08:00

2017-05-27 16:16:11 +08:00
If your cross section is hollow, set the `triangles` parameter to `"HOLLOW"` and index the points as the following:
2017-04-30 20:05:17 +08:00

2017-05-16 09:47:15 +08:00
You can cut triangles by yourself. For example, the above shape can be cut into triangles such as:
2017-04-30 20:05:17 +08:00

2017-05-16 09:47:15 +08:00
The indexes of the above triangles is:
2017-04-30 20:05:17 +08:00
[
2017-06-09 10:14:38 +08:00
[0, 3, 1],
[1, 3, 4],
[1, 4, 2],
[2, 4, 5],
[2, 5, 0],
[0, 5, 3]
]
2017-06-10 20:23:43 +08:00
When defining triangles, you can use clockwise or counter-clockwise indexes.
2017-04-30 20:05:17 +08:00
## Parameters
- `sections` : A list of cross-sections. Each cross-section is represented by a list of points. See the example below.
2017-05-10 16:27:35 +08:00
- `triangles` : `"SOLID"` (default), `"HOLLOW"` , or user-defined indexes. See example below.
2017-04-30 20:05:17 +08:00
## Examples
2020-01-28 17:51:20 +08:00
use < rotate_p.scad > ;
use < polysections.scad > ;
2017-05-16 09:47:15 +08:00
2017-04-30 20:05:17 +08:00
section1 = [
2017-05-16 09:47:15 +08:00
[20, 0, 0],
[18, 9, 0],
[15, 10, 0],
[10, 0, 0]
2017-04-30 20:05:17 +08:00
];
2017-05-16 09:47:15 +08:00
2017-04-30 20:05:17 +08:00
// spin section1
sections = [
2017-05-16 09:47:15 +08:00
for(i = [0:55])
[
for(p = section1)
let(pt = rotate_p(p, [90, 0, 10 * i]))
[pt[0], pt[1] , pt[2] + i]
]
2017-04-30 20:05:17 +08:00
];
2017-05-16 09:47:15 +08:00
2017-04-30 20:05:17 +08:00
polysections(sections);

2020-01-28 17:51:20 +08:00
use < rotate_p.scad > ;
use < polysections.scad > ;
2017-04-30 20:05:17 +08:00
section1 = [
// outer
2017-05-16 09:47:15 +08:00
[20, 0, 0],
[18, 9, 0],
[15, 10, 0],
[10, 0, 0],
2017-04-30 20:05:17 +08:00
// inner
2017-05-16 09:47:15 +08:00
[18, 2, 0],
[17, 7, 0],
[15, 7, 0],
[12, 2, 0]
2017-04-30 20:05:17 +08:00
];
// spin section1
sections = [
for(i = [0:55])
[
for(p = section1)
2017-05-16 09:47:15 +08:00
let(pt = rotate_p(p, [90, 0, 10 * i]))
2017-04-30 20:05:17 +08:00
[pt[0], pt[1] , pt[2] + i]
]
];
polysections(sections, "HOLLOW");

2020-01-28 17:51:20 +08:00
use < rotate_p.scad > ;
use < polysections.scad > ;
2017-04-30 20:05:17 +08:00
section1 = [
// outer
2017-05-16 09:47:15 +08:00
[30, 0, 0],
2017-04-30 20:05:17 +08:00
[15, 10, 0],
2017-05-16 09:47:15 +08:00
[10, 0, 0],
2017-04-30 20:05:17 +08:00
// inner
2017-05-16 09:47:15 +08:00
[26, 1, 0],
2017-04-30 20:05:17 +08:00
[15, 8, 0],
2017-05-16 09:47:15 +08:00
[12, 1, 0],
2017-04-30 20:05:17 +08:00
];
// spin section1
sections = [
for(i = [0:55])
[
for(p = section1)
2017-05-16 09:47:15 +08:00
let(pt = rotate_p(p, [90, 0, 10 * i]))
2017-04-30 20:05:17 +08:00
[pt[0], pt[1] , pt[2] + i]
]
];
polysections(
sections = sections,
triangles = [
2017-05-16 09:47:15 +08:00
[0, 3, 1],
[1, 3, 4],
[1, 4, 2],
[2, 4, 5],
[2, 5, 0],
[0, 5, 3]
]
2017-04-30 20:05:17 +08:00
);
