1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/docs/lib3x-sweep.md

138 lines
2.5 KiB
Markdown
Raw Normal View History

2020-03-19 17:16:21 +08:00
# sweep
This module sweeps multiple cross-sections to create a 3D object. For example, imagine that you have the following cross-sections:
2021-02-20 20:25:58 +08:00
![sweep](images/lib3x-sweep-1.JPG)
2020-03-19 17:16:21 +08:00
This module sweeps them to create a 3D object:
2021-02-20 20:25:58 +08:00
![sweep](images/lib3x-sweep-2.JPG)
2020-03-19 17:16:21 +08:00
2020-09-29 18:11:15 +08:00
When using this module, you should use points to represent a cross section. The points must be counter-clockwise indexes. For example:
2020-03-19 17:16:21 +08:00
2021-02-20 20:25:58 +08:00
![sweep](images/lib3x-sweep-10.JPG)
2020-03-19 17:16:21 +08:00
If your cross section is hollow, set the `triangles` parameter to `"HOLLOW"` and index the points as the following:
2021-02-20 20:25:58 +08:00
![sweep](images/lib3x-sweep-5.JPG)
2020-03-19 17:16:21 +08:00
You can cut triangles by yourself. For example, the above shape can be cut into triangles such as:
2021-02-20 20:25:58 +08:00
![sweep](images/lib3x-sweep-6.JPG)
2020-03-19 17:16:21 +08:00
The indexes of the above triangles is:
[
[0, 3, 1],
[1, 3, 4],
[1, 4, 2],
[2, 4, 5],
[2, 5, 0],
[0, 5, 3]
]
2020-04-05 10:57:53 +08:00
**Since:** 2.3
2020-03-19 17:16:21 +08:00
## Parameters
- `sections` : A list of cross-sections. Each cross-section is represented by points. See the example below.
- `triangles` : `"SOLID"` (default), `"HOLLOW"`, or user-defined indexes. See example below.
## Examples
2022-06-06 13:11:46 +08:00
use <ptf/ptf_rotate.scad>
use <sweep.scad>
2020-03-19 17:16:21 +08:00
section1 = [
[20, 0, 0],
[18, 9, 0],
[15, 10, 0],
[10, 0, 0]
];
// spin section1
sections = [
for(i = [0:55])
2022-04-06 17:44:11 +08:00
[
for(p = section1)
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
[pt.x, pt.y , pt.z + i]
]
2020-03-19 17:16:21 +08:00
];
sweep(sections);
2021-02-20 20:25:58 +08:00
![sweep](images/lib3x-sweep-7.JPG)
2020-03-19 17:16:21 +08:00
2022-06-06 13:11:46 +08:00
use <ptf/ptf_rotate.scad>
use <sweep.scad>
2020-03-19 17:16:21 +08:00
section1 = [
// outer
[20, 0, 0],
[18, 9, 0],
[15, 10, 0],
[10, 0, 0],
// inner
[18, 2, 0],
[17, 7, 0],
[15, 7, 0],
[12, 2, 0]
];
// spin section1
sections = [
for(i = [0:55])
2022-04-06 17:44:11 +08:00
[
for(p = section1)
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
[pt.x, pt.y , pt.z + i]
]
2020-03-19 17:16:21 +08:00
];
sweep(sections, "HOLLOW");
2021-02-20 20:25:58 +08:00
![sweep](images/lib3x-sweep-8.JPG)
2020-03-19 17:16:21 +08:00
2022-06-06 13:11:46 +08:00
use <ptf/ptf_rotate.scad>
use <sweep.scad>
2020-03-19 17:16:21 +08:00
section1 = [
// outer
[30, 0, 0],
[15, 10, 0],
[10, 0, 0],
// inner
[26, 1, 0],
[15, 8, 0],
[12, 1, 0],
];
// spin section1
sections = [
for(i = [0:55])
2022-04-06 17:44:11 +08:00
[
for(p = section1)
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
[pt.x, pt.y , pt.z + i]
]
2020-03-19 17:16:21 +08:00
];
sweep(
sections = sections,
triangles = [
[0, 3, 1],
[1, 3, 4],
[1, 4, 2],
[2, 4, 5],
[2, 5, 0],
[0, 5, 3]
]
);
2021-02-20 20:25:58 +08:00
![sweep](images/lib3x-sweep-9.JPG)
2020-03-19 17:16:21 +08:00