diff --git a/README.md b/README.md index 4c55f9af..aec561e1 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ 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_trapezium](https://openhome.cc/eGossip/OpenSCAD/lib-shape_trapezium.html) - [shape_pentagram](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pentagram.html) - [shape_superformula](https://openhome.cc/eGossip/OpenSCAD/lib-shape_superformula.html) diff --git a/docs/images/lib-shape_trapezium-1.JPG b/docs/images/lib-shape_trapezium-1.JPG new file mode 100644 index 00000000..d09cfabc Binary files /dev/null and b/docs/images/lib-shape_trapezium-1.JPG differ diff --git a/docs/images/lib-shape_trapezium-2.JPG b/docs/images/lib-shape_trapezium-2.JPG new file mode 100644 index 00000000..e500e8b2 Binary files /dev/null and b/docs/images/lib-shape_trapezium-2.JPG differ diff --git a/docs/lib-shape_trapezium.md b/docs/lib-shape_trapezium.md new file mode 100644 index 00000000..7293b45c --- /dev/null +++ b/docs/lib-shape_trapezium.md @@ -0,0 +1,51 @@ +# shape_trapezium + +Returns shape points of an isosceles trapezoid. They can be used with xxx_extrude modules of dotSCAD. The shape points can be also used with the built-in polygon module. + +## Parameters + +- `length` : The base length of an isosceles trapezium. It also accepts a vector `[a, b]`. `a` is the bottom base and `b` is the top base. +- `h` : The height of the cylinder or cone. +- `corner_r` : The circle radius which fits the edges of the bottom and the top. +- `$fa`, `$fs`, `$fn` : Used to control the corner fragments. Check [the circle module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circle) for more details. + +## Examples + + include ; + + polygon( + shape_trapezium([20, 10], + h = 20, + corner_r = 2) + ); + +![shape_trapezium](images/lib-shape_trapezium-1.JPG) + + include ; + include ; + include ; + include ; + include ; + + t_step = 0.05; + width = 2; + + shape_pts = shape_trapezium( + [20, 10], + h = 20, + corner_r = 2 + ); + + p0 = [0, 0, 0]; + p1 = [40, 60, 35]; + p2 = [-50, 70, 45]; + p3 = [20, 150, 55]; + p4 = [80, 50, 60]; + + path_pts = bezier_curve(t_step, + [p0, p1, p2, p3, p4] + ); + + path_extrude(shape_pts, path_pts); + +![shape_trapezium](images/lib-shape_trapezium-2.JPG) \ No newline at end of file diff --git a/src/shape_trapezium.scad b/src/shape_trapezium.scad new file mode 100644 index 00000000..08f3cf6d --- /dev/null +++ b/src/shape_trapezium.scad @@ -0,0 +1,27 @@ +/** +* shape_trapezium.scad +* +* Returns shape points of an isosceles trapezium. +* 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_trapezium.html +* +**/ + +include <__private__/__is_vector.scad>; +include <__private__/__frags.scad>; +include <__private__/__pie_for_rounding.scad>; +include <__private__/__half_trapezium.scad>; +include <__private__/__trapezium.scad>; + +function shape_trapezium(radius, h, corner_r = 0) = + __trapezium( + radius = radius, + h = h, + round_r = corner_r + ); + \ No newline at end of file