diff --git a/README.md b/README.md index ec2c5bee..24e6aed4 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,8 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I - [shape_pie](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pie.html) - [shape_ellipse](https://openhome.cc/eGossip/OpenSCAD/lib-shape_ellipse.html) - [shape_square](https://openhome.cc/eGossip/OpenSCAD/lib-shape_square.html) - - [shape_pentagram](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pentagram.html) + - [shape_pentagram](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pentagram.html) + - [shape_superformula](https://openhome.cc/eGossip/OpenSCAD/lib-shape_superformula.html) - Other - [turtle2d](https://openhome.cc/eGossip/OpenSCAD/lib-turtle2d.html) diff --git a/docs/images/lib-shape_superformula-1.JPG b/docs/images/lib-shape_superformula-1.JPG new file mode 100644 index 00000000..b0e18281 Binary files /dev/null and b/docs/images/lib-shape_superformula-1.JPG differ diff --git a/docs/images/lib-shape_superformula-2.JPG b/docs/images/lib-shape_superformula-2.JPG new file mode 100644 index 00000000..0f29884b Binary files /dev/null and b/docs/images/lib-shape_superformula-2.JPG differ diff --git a/docs/lib-shape_superformula.md b/docs/lib-shape_superformula.md new file mode 100644 index 00000000..02bf4e6a --- /dev/null +++ b/docs/lib-shape_superformula.md @@ -0,0 +1,60 @@ +# shape_superformula + +Returns shape points and triangle indexes of a [Superformula](https://en.wikipedia.org/wiki/Superformula) shape. They can be used with xxx_extrude modules of dotSCAD. The shape points can be also used with the built-in polygon module. + +## Parameters + +- `phi_step` : The radius of the circle. +- `m1`, `m2`, `n1`, `n2`, `n3`, `a`, `b` : The parameters of [Superformula](https://en.wikipedia.org/wiki/Superformula). The default value of `n2`, `n3`, `a`, and `b` is 1. + +## Examples + + include ; + + phi_step = 0.05; + + polygon(shape_superformula(phi_step, 3, 3, 4.5, 10, 10)[0]); + translate([3, 0]) + polygon(shape_superformula(phi_step, 4, 4, 12, 15, 15)[0]); + translate([6, 0]) + polygon(shape_superformula(phi_step, 7, 7, 10, 6, 6)[0]); + translate([9, 0]) + polygon(shape_superformula(phi_step, 5, 5, 4, 4, 4)[0]); + + translate([0, -4]) + scale(0.8) polygon(shape_superformula(phi_step, 5, 5, 2, 7, 7)[0]); + translate([3, -4]) + scale(0.25) polygon(shape_superformula(phi_step, 5, 5, 2, 13, 13)[0]); + translate([6, -4]) + polygon(shape_superformula(phi_step, 4, 4, 1, 1, 1)[0]); + translate([9, -4]) + scale(0.3) polygon(shape_superformula(phi_step, 4, 4, 1, 7, 8)[0]); + +![shape_superformula](images/lib-shape_superformula-1.JPG) + + include ; + include ; + include ; + include ; + include ; + include ; + include ; + + phi_step = 0.05; + + m = 16; + n = 0.5; + n3 = 16; + + shape_pts_tris = shape_superformula(phi_step, m, m, n, n, n3); + + golden_spiral_extrude( + shape_pts_tris[0], + from = 5, + to = 10, + point_distance = 2, + scale = 10, + triangles = shape_pts_tris[1] + ); + +![shape_superformula](images/lib-shape_superformula-2.JPG) diff --git a/src/shape_superformula.scad b/src/shape_superformula.scad index b96f623c..9f8e5cf6 100644 --- a/src/shape_superformula.scad +++ b/src/shape_superformula.scad @@ -1,3 +1,17 @@ +/** +* shape_superformula.scad +* +* Returns shape points and triangle indexes of a Superformula shape. +* They can be used with xxx_extrude modules of dotSCAD. +* The shape points can be also used with the built-in polygon module. +* +* @copyright Justin Lin, 2017 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib-shape_superformula.html +* +**/ + include <__private__/__ra_to_xy.scad>; include <__private__/__to_degree.scad>; include <__private__/__triangles_radial.scad>;