diff --git a/README.md b/README.md index c21fbc95..8a06680f 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I - [helix_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-helix_extrude.html) - [golden_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-golden_spiral_extrude.html) - [archimedean_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-archimedean_spiral_extrude.html) + - [sphere_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral_extrude_spiral_extrude.html) - Other - [turtle2d](https://openhome.cc/eGossip/OpenSCAD/lib-turtle2d.html) diff --git a/docs/images/lib-sphere_spiral_extrude-1.JPG b/docs/images/lib-sphere_spiral_extrude-1.JPG new file mode 100644 index 00000000..41e25eac Binary files /dev/null and b/docs/images/lib-sphere_spiral_extrude-1.JPG differ diff --git a/docs/lib-sphere_spiral_extrude.md b/docs/lib-sphere_spiral_extrude.md new file mode 100644 index 00000000..e8613760 --- /dev/null +++ b/docs/lib-sphere_spiral_extrude.md @@ -0,0 +1,63 @@ +# sphere_spiral_extrude + +Extrudes a 2D shape along the path of a sphere spiral. + +When using this module, you should use points to represent the 2D shape. You need to provide indexes of triangles, too. This module provides two prepared triangles indexes. One is `"RADIAL"`. See [polysections](https://openhome.cc/eGossip/OpenSCAD/lib-polysections.html) for details. + +Dependencies: `rotate_p`, `sphere_spiral`, `cross_sections`, `polysections`. + +## Parameters + +- `shape_pts` : A list of points represent a shape. See the example below. +- `radius` , `za_step`, `z_circles`, `begin_angle`, `end_angle`, `vt_dir`, `rt_dir` : See [sphere_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral.html) for details. +- `twist` : The number of degrees of through which the shape is extruded. +- `scale` : Scales the 2D shape by this value over the length of the extrusion. Scale can be a scalar or a vector. +- `triangles` : `"RADIAL"` (default), `"HOLLOW"` or user-defined indexes. See [polysections](https://openhome.cc/eGossip/OpenSCAD/lib-polysections.html) for details. + +## Examples + + include ; + include ; + include ; + include ; + include ; + + function shape_pentagram(r) = + [ + // shape points + [ + [0, 1], [-0.224514, 0.309017], + [-0.951057, 0.309017], [-0.363271, -0.118034], + [-0.587785, -0.809017], [0, -0.381966], + [0.587785, -0.809017], [0.363271, -0.118034], + [0.951057, 0.309017], [0.224514, 0.309017] + ] * r, + // triangles + [ + [0, 1, 9], + [2, 3, 1], + [4, 5, 3], + [6, 7, 5], + [8, 9, 7], + [1, 3, 5], + [1, 5, 7], + [1, 7, 9] + ] + ]; + + points_triangles = shape_pentagram(2); + + + sphere_spiral_extrude( + shape_pts = points_triangles[0], + radius = 40, + za_step = 2, + z_circles = 20, + begin_angle = 90, + end_angle = 450, + vt_dir = "SPI_UP", + scale = 5, + triangles = points_triangles[1] + ); + +![sphere_spiral_extrude](images/lib-sphere_spiral_extrude-1.JPG) diff --git a/src/sphere_spiral_extrude.scad b/src/sphere_spiral_extrude.scad new file mode 100644 index 00000000..89600f23 --- /dev/null +++ b/src/sphere_spiral_extrude.scad @@ -0,0 +1,36 @@ +/** +* sphere_spiral_extrude.scad +* +* Extrudes a 2D shape along the path of a sphere spiral. +* +* @copyright Justin Lin, 2017 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral_extrude.html +* +**/ + +module sphere_spiral_extrude(shape_pts, radius, za_step, + z_circles = 1, begin_angle = 0, end_angle = 0, vt_dir = "SPI_DOWN", rt_dir = "CT_CLK", + twist = 0, scale = 1.0, triangles = "RADIAL") { + + points_angles = sphere_spiral( + radius = radius, + za_step = za_step, + z_circles = z_circles, + begin_angle = begin_angle, + end_angle = end_angle, + vt_dir = vt_dir, + rt_dir = rt_dir + ); + + points = [for(pa = points_angles) pa[0]]; + angles = [for(pa = points_angles) [pa[1][0] + 90, pa[1][1], pa[1][2]]]; + + polysections( + cross_sections( + shape_pts, points, angles, twist = twist, scale = scale + ), + triangles = triangles + ); +} \ No newline at end of file