diff --git a/docs/images/lib2x-sweep-1.JPG b/docs/images/lib2x-sweep-1.JPG new file mode 100644 index 00000000..05408847 Binary files /dev/null and b/docs/images/lib2x-sweep-1.JPG differ diff --git a/docs/images/lib2x-sweep-10.JPG b/docs/images/lib2x-sweep-10.JPG new file mode 100644 index 00000000..656d5e4b Binary files /dev/null and b/docs/images/lib2x-sweep-10.JPG differ diff --git a/docs/images/lib2x-sweep-2.JPG b/docs/images/lib2x-sweep-2.JPG new file mode 100644 index 00000000..784c00be Binary files /dev/null and b/docs/images/lib2x-sweep-2.JPG differ diff --git a/docs/images/lib2x-sweep-3.JPG b/docs/images/lib2x-sweep-3.JPG new file mode 100644 index 00000000..41373606 Binary files /dev/null and b/docs/images/lib2x-sweep-3.JPG differ diff --git a/docs/images/lib2x-sweep-4.JPG b/docs/images/lib2x-sweep-4.JPG new file mode 100644 index 00000000..f2b0125a Binary files /dev/null and b/docs/images/lib2x-sweep-4.JPG differ diff --git a/docs/images/lib2x-sweep-5.JPG b/docs/images/lib2x-sweep-5.JPG new file mode 100644 index 00000000..99aee7ad Binary files /dev/null and b/docs/images/lib2x-sweep-5.JPG differ diff --git a/docs/images/lib2x-sweep-6.JPG b/docs/images/lib2x-sweep-6.JPG new file mode 100644 index 00000000..a8a05f43 Binary files /dev/null and b/docs/images/lib2x-sweep-6.JPG differ diff --git a/docs/images/lib2x-sweep-7.JPG b/docs/images/lib2x-sweep-7.JPG new file mode 100644 index 00000000..361bb0b0 Binary files /dev/null and b/docs/images/lib2x-sweep-7.JPG differ diff --git a/docs/images/lib2x-sweep-8.JPG b/docs/images/lib2x-sweep-8.JPG new file mode 100644 index 00000000..e87527f9 Binary files /dev/null and b/docs/images/lib2x-sweep-8.JPG differ diff --git a/docs/images/lib2x-sweep-9.JPG b/docs/images/lib2x-sweep-9.JPG new file mode 100644 index 00000000..d176351e Binary files /dev/null and b/docs/images/lib2x-sweep-9.JPG differ diff --git a/docs/lib2x-sweep.md b/docs/lib2x-sweep.md new file mode 100644 index 00000000..317bee4f --- /dev/null +++ b/docs/lib2x-sweep.md @@ -0,0 +1,135 @@ +# sweep + +This module sweeps multiple cross-sections to create a 3D object. For example, imagine that you have the following cross-sections: + +![sweep](images/lib2x-sweep-1.JPG) + +This module sweeps them to create a 3D object: + +![sweep](images/lib2x-sweep-2.JPG) + +When using this module, you should use points to represent a cross section. The points must be count-clockwise indexes. For example: + +![sweep](images/lib2x-sweep-10.JPG) + +If your cross section is hollow, set the `triangles` parameter to `"HOLLOW"` and index the points as the following: + +![sweep](images/lib2x-sweep-5.JPG) + +You can cut triangles by yourself. For example, the above shape can be cut into triangles such as: + +![sweep](images/lib2x-sweep-6.JPG) + +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] + ] + +## 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 + + use ; + use ; + + section1 = [ + [20, 0, 0], + [18, 9, 0], + [15, 10, 0], + [10, 0, 0] + ]; + + // spin section1 + sections = [ + for(i = [0:55]) + [ + for(p = section1) + let(pt = rotate_p(p, [90, 0, 10 * i])) + [pt[0], pt[1] , pt[2] + i] + ] + ]; + + sweep(sections); + +![sweep](images/lib2x-sweep-7.JPG) + + use ; + use ; + + 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]) + [ + for(p = section1) + let(pt = rotate_p(p, [90, 0, 10 * i])) + [pt[0], pt[1] , pt[2] + i] + ] + ]; + + sweep(sections, "HOLLOW"); + +![sweep](images/lib2x-sweep-8.JPG) + + use ; + use ; + + 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]) + [ + for(p = section1) + let(pt = rotate_p(p, [90, 0, 10 * i])) + [pt[0], pt[1] , pt[2] + i] + ] + ]; + + sweep( + sections = sections, + triangles = [ + [0, 3, 1], + [1, 3, 4], + [1, 4, 2], + [2, 4, 5], + [2, 5, 0], + [0, 5, 3] + ] + ); + +![sweep](images/lib2x-sweep-9.JPG) + + + +