omdl  v0.5
OpenSCAD Mechanical Design Library
shapes2de.scad
Go to the documentation of this file.
1 //! Linearly extruded two-dimensional basic shapes.
2 /***************************************************************************//**
3  \file shapes2de.scad
4  \author Roy Allen Sutton
5  \date 2015-2017
6 
7  \copyright
8 
9  This file is part of [omdl] (https://github.com/royasutton/omdl),
10  an OpenSCAD mechanical design library.
11 
12  The \em omdl is free software; you can redistribute it and/or modify
13  it under the terms of the [GNU Lesser General Public License]
14  (http://www.gnu.org/licenses/lgpl.html) as published by the Free
15  Software Foundation; either version 2.1 of the License, or (at
16  your option) any later version.
17 
18  The \em omdl is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with the \em omdl; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26  02110-1301, USA; or see <http://www.gnu.org/licenses/>.
27 
28  \details
29 
30  \ingroup shapes shapes_2de
31 *******************************************************************************/
32 
33 include <shapes2d.scad>;
34 
35 //----------------------------------------------------------------------------//
36 /***************************************************************************//**
37  \addtogroup shapes
38  @{
39 
40  \amu_define caption (2D Extrusions)
41 
42  \amu_make png_files (append=dim extension=png)
43  \amu_make eps_files (append=dim extension=png2eps)
44  \amu_shell file_cnt ("echo ${png_files} | wc -w")
45  \amu_shell cell_num ("seq -f '(%g)' -s '^' ${file_cnt}")
46 
47  \htmlonly
48  \amu_image_table
49  (
50  type=html columns=4 image_width="200" cell_files="${png_files}"
51  table_caption="${caption}" cell_captions="${cell_num}"
52  )
53  \endhtmlonly
54  \latexonly
55  \amu_image_table
56  (
57  type=latex columns=4 image_width="1.25in" cell_files="${eps_files}"
58  table_caption="${caption}" cell_captions="${cell_num}"
59  )
60  \endlatexonly
61 
62  \defgroup shapes_2de 2D Extrusions
63  \brief Extruded two dimensional geometric shapes.
64  @{
65 *******************************************************************************/
66 //----------------------------------------------------------------------------//
67 
68 //----------------------------------------------------------------------------//
69 // amu macros
70 //----------------------------------------------------------------------------//
71 /***************************************************************************//**
72  \amu_define scope (shapes2de_dim)
73  \amu_define tuple (qvga_diag)
74 
75  \amu_define example_dim
76  (
77  \image html ${scope}_${tuple}_${function}.png "${function}"
78  \image latex ${scope}_${tuple}_${function}.eps "${function}" width=2.5in
79  \dontinclude ${scope}.scad \skipline ${function}(
80  )
81 *******************************************************************************/
82 //----------------------------------------------------------------------------//
83 
84 //! An extruded rectangle with edge, fillet, and/or chamfer corners.
85 /***************************************************************************//**
86  \param size <vector|decimal> A vector [x, y] of decimals
87  or a single decimal for (x=y).
88 
89  \param h <vector|decimal> A vector of decimals or a single decimal to
90  specify simple extrusion height.
91 
92  \param vr <vector|decimal> The corner rounding radius.
93  A vector [v1r, v2r, v3r, v4r] of decimals or a single decimal
94  for (v1r=v2r=v3r=v4r). Unspecified corners are not rounded.
95 
96  \param vrm <integer> The corner radius mode.
97  A 4-bit encoded integer that indicates each corner finish.
98  Use bit value \b 0 for \em fillet and \b 1 for \em chamfer.
99 
100  \param center <boolean> Center about origin.
101 
102  \details
103 
104  \sa st_linear_extrude_scale for a description on specifying \p h.
105 
106  \b Example
107  \amu_eval ( function=erectangle ${example_dim} )
108 *******************************************************************************/
109 module erectangle
110 (
111  size,
112  h,
113  vr,
114  vrm = 0,
115  center = false
116 )
117 {
118  st_linear_extrude_scale(h=h, center=center)
119  rectangle(size=size, vr=vr, vrm=vrm, center=center);
120 }
121 
122 //! An extruded rectangle with a removed rectangular core.
123 /***************************************************************************//**
124  \param size <vector|decimal> A vector [x, y] of decimals
125  or a single decimal for (x=y).
126  \param core <vector|decimal> A vector [x, y] of decimals
127  or a single decimal for (x=y).
128 
129  \param h <vector|decimal> A vector of decimals or a single decimal to
130  specify simple extrusion height.
131 
132  \param t <vector|decimal> A vector [x, y] of decimals
133  or a single decimal for (x=y).
134 
135  \param co <vector> Core offset. A vector [x, y] of decimals.
136  \param cr <decimal> Core z-rotation.
137 
138  \param vr <vector|decimal> The default corner rounding radius.
139  A vector [v1r, v2r, v3r, v4r] of decimals or a single decimal
140  for (v1r=v2r=v3r=v4r). Unspecified corners are not rounded.
141  \param vr1 <vector|decimal> The outer corner rounding radius.
142  \param vr2 <vector|decimal> The core corner rounding radius.
143 
144  \param vrm <integer> The default corner radius mode.
145  A 4-bit encoded integer that indicates each corner finish.
146  Use bit value \b 0 for \em fillet and \b 1 for \em chamfer.
147  \param vrm1 <integer> The outer corner radius mode.
148  \param vrm2 <integer> The core corner radius mode.
149 
150  \param center <boolean> Center about origin.
151 
152  \details
153 
154  \sa st_linear_extrude_scale for a description on specifying \p h.
155 
156  Thickness \p t
157  \li <tt>core = size - t</tt>; when \p t and \p size are given.
158  \li <tt>size = core + t</tt>; when \p t and \p core are given.
159 
160  \b Example
161  \amu_eval ( function=erectangle_c ${example_dim} )
162 *******************************************************************************/
163 module erectangle_c
164 (
165  size,
166  core,
167  h,
168  t,
169  co,
170  cr = 0,
171  vr,
172  vr1,
173  vr2,
174  vrm = 0,
175  vrm1,
176  vrm2,
177  center = false
178 )
179 {
180  st_linear_extrude_scale(h=h, center=center)
182  (
183  size=size, core=core, t=t,
184  co=co, cr=cr,
185  vr=vr, vr1=vr1, vr2=vr2,
186  vrm=vrm, vrm1=vrm1, vrm2=vrm2,
187  center=center
188  );
189 }
190 
191 //! An extruded rhombus.
192 /***************************************************************************//**
193  \param size <vector|decimal> A vector [w, h] of decimals
194  or a single decimal for (w=h).
195 
196  \param h <vector|decimal> A vector of decimals or a single decimal to
197  specify simple extrusion height.
198 
199  \param vr <vector|decimal> The corner rounding radius.
200  A vector [v1r, v2r, v3r, v4r] of decimals or a single decimal
201  for (v1r=v2r=v3r=v4r). Unspecified corners are not rounded.
202 
203  \param center <boolean> Center about origin.
204 
205  \details
206 
207  \sa st_linear_extrude_scale for a description on specifying \p h.
208 
209  \b Example
210  \amu_eval ( function=erhombus ${example_dim} )
211 *******************************************************************************/
212 module erhombus
213 (
214  size,
215  h,
216  vr,
217  center = false
218 )
219 {
220  st_linear_extrude_scale(h=h, center=center)
221  rhombus(size=size, vr=vr, center=center);
222 }
223 
224 //! An extruded general triangle specified by three vertices.
225 /***************************************************************************//**
226  \param v1 <vector> A vector [x, y] for vertex 1.
227  \param v2 <vector> A vector [x, y] for vertex 2.
228  \param v3 <vector> A vector [x, y] for vertex 3.
229 
230  \param h <vector|decimal> A vector of decimals or a single decimal to
231  specify simple extrusion height.
232 
233  \param vr <decimal> The default vertex rounding radius.
234  \param v1r <decimal> Vertex 1 rounding radius.
235  \param v2r <decimal> Vertex 2 rounding radius.
236  \param v3r <decimal> Vertex 3 rounding radius.
237 
238  \param centroid <boolean> Center centroid at origin.
239  \param incenter <boolean> Center incenter at origin.
240  \param center <boolean> Center about origin.
241 
242  \details
243 
244  \sa st_linear_extrude_scale for a description on specifying \p h.
245 
246  \b Example
247  \amu_eval ( function=etriangle_ppp ${example_dim} )
248 *******************************************************************************/
249 module etriangle_ppp
250 (
251  v1,
252  v2,
253  v3,
254  h,
255  vr,
256  v1r,
257  v2r,
258  v3r,
259  centroid = false,
260  incenter = false,
261  center = false
262 )
263 {
264  st_linear_extrude_scale(h=h, center=center)
266  (
267  v1=v1, v2=v2, v3=v3,
268  vr=vr, v1r=v1r, v2r=v2r, v3r=v3r,
269  centroid=centroid, incenter=incenter
270  );
271 }
272 
273 //! An extruded general triangle specified by a vector of its three vertices.
274 /***************************************************************************//**
275  \param v <vector> A vector [v1, v2, v3] of vectors [x, y].
276 
277  \param h <vector|decimal> A vector of decimals or a single decimal to
278  specify simple extrusion height.
279 
280  \param vr <vector|decimal> The vertex rounding radius. A vector
281  [v1r, v2r, v3r] of decimals or a single decimal for (v1r=v2r=v3r).
282 
283  \param centroid <boolean> Center centroid at origin.
284  \param incenter <boolean> Center incenter at origin.
285  \param center <boolean> Center about origin.
286 
287  \details
288 
289  \sa st_linear_extrude_scale for a description on specifying \p h.
290 
291  \b Example
292  \code{.C}
293  t = triangle_lll2vp( 30, 40, 50 );
294  r = [2, 4, 6];
295  etriangle_vp( v=t, h=5, vr=r );
296  \endcode
297 *******************************************************************************/
298 module etriangle_vp
299 (
300  v,
301  h,
302  vr,
303  centroid = false,
304  incenter = false,
305  center = false
306 )
307 {
308  st_linear_extrude_scale(h=h, center=center)
309  triangle_vp(v=v, vr=vr, centroid=centroid, incenter=incenter);
310 }
311 
312 //! An extruded general triangle specified by its three side lengths.
313 /***************************************************************************//**
314  \param s1 <decimal> The length of the side 1 (along the x-axis).
315  \param s2 <decimal> The length of the side 2.
316  \param s3 <decimal> The length of the side 3.
317 
318  \param h <vector|decimal> A vector of decimals or a single decimal to
319  specify simple extrusion height.
320 
321  \param vr <decimal> The default vertex rounding radius.
322  \param v1r <decimal> Vertex 1 rounding radius.
323  \param v2r <decimal> Vertex 2 rounding radius.
324  \param v3r <decimal> Vertex 3 rounding radius.
325 
326  \param centroid <boolean> Center centroid at origin.
327  \param incenter <boolean> Center incenter at origin.
328  \param center <boolean> Center about origin.
329 
330  \details
331 
332  \sa st_linear_extrude_scale for a description on specifying \p h.
333 
334  \b Example
335  \amu_eval ( function=etriangle_lll ${example_dim} )
336 *******************************************************************************/
337 module etriangle_lll
338 (
339  s1,
340  s2,
341  s3,
342  h,
343  vr,
344  v1r,
345  v2r,
346  v3r,
347  centroid = false,
348  incenter = false,
349  center = false
350 )
351 {
352  st_linear_extrude_scale(h=h, center=center)
354  (
355  s1=s1, s2=s2, s3=s3,
356  vr=vr, v1r=v1r, v2r=v2r, v3r=v3r,
357  centroid=centroid, incenter=incenter
358  );
359 }
360 
361 //! An extruded general triangle specified by a vector of its three side lengths.
362 /***************************************************************************//**
363  \param v <vector> A vector [s1, s2, s3] of decimals.
364 
365  \param h <vector|decimal> A vector of decimals or a single decimal to
366  specify simple extrusion height.
367 
368  \param vr <vector|decimal> The vertex rounding radius. A vector
369  [v1r, v2r, v3r] of decimals or a single decimal for (v1r=v2r=v3r).
370 
371  \param centroid <boolean> Center centroid at origin.
372  \param incenter <boolean> Center incenter at origin.
373  \param center <boolean> Center about origin.
374 
375  \details
376 
377  \sa st_linear_extrude_scale for a description on specifying \p h.
378 
379  \b Example
380  \code{.C}
381  t = triangle_lll2vp( 3, 4, 5 );
382  s = triangle_vp2vl( t );
383  etriangle_vl( v=s, h=5, vr=2 );
384  \endcode
385 *******************************************************************************/
386 module etriangle_vl
387 (
388  v,
389  h,
390  vr,
391  centroid = false,
392  incenter = false,
393  center = false
394 )
395 {
396  st_linear_extrude_scale(h=h, center=center)
397  triangle_vl(v=v, vr=vr, centroid=centroid, incenter=incenter);
398 }
399 
400 //! A general triangle specified by its sides with a removed triangular core.
401 /***************************************************************************//**
402  \param vs <vector|decimal> The size. A vector [s1, s2, s3] of decimals
403  or a single decimal for (s1=s2=s3).
404  \param vc <vector|decimal> The core. A vector [s1, s2, s3] of decimals
405  or a single decimal for (s1=s2=s3).
406 
407  \param h <vector|decimal> A vector of decimals or a single decimal to
408  specify simple extrusion height.
409 
410  \param co <vector> Core offset. A vector [x, y] of decimals.
411  \param cr <decimal> Core z-rotation.
412 
413  \param vr <vector|decimal> The default vertex rounding radius. A vector
414  [v1r, v2r, v3r] of decimals or a single decimal for (v1r=v2r=v3r).
415  \param vr1 <vector|decimal> The outer vertex rounding radius.
416  \param vr2 <vector|decimal> The core vertex rounding radius.
417 
418  \param centroid <boolean> Center centroid at origin.
419  \param incenter <boolean> Center incenter at origin.
420  \param center <boolean> Center about origin.
421 
422  \details
423 
424  \sa st_linear_extrude_scale for a description on specifying \p h.
425 
426  \b Example
427  \amu_eval ( function=etriangle_vl_c ${example_dim} )
428 
429  \note The outer and inner triangles centroids are aligned prior to the
430  core removal.
431 *******************************************************************************/
432 module etriangle_vl_c
433 (
434  vs,
435  vc,
436  h,
437  co,
438  cr = 0,
439  vr,
440  vr1,
441  vr2,
442  centroid = false,
443  incenter = false,
444  center = false
445 )
446 {
447  st_linear_extrude_scale(h=h, center=center)
449  (
450  vs=vs, vc=vc,
451  co=co, cr=cr,
452  vr=vr, vr1=vr1, vr2=vr2,
453  centroid=centroid, incenter=incenter
454  );
455 }
456 
457 //! An extruded general triangle specified by two sides and the included angle.
458 /***************************************************************************//**
459  \param s1 <decimal> The length of the side 1.
460  \param a <decimal> The included angle in degrees.
461  \param s2 <decimal> The length of the side 2.
462 
463  \param h <vector|decimal> A vector of decimals or a single decimal to
464  specify simple extrusion height.
465 
466  \param x <decimal> The side to draw on the positive x-axis (\p x=1 for \p s1).
467 
468  \param vr <decimal> The default vertex rounding radius.
469  \param v1r <decimal> Vertex 1 rounding radius.
470  \param v2r <decimal> Vertex 2 rounding radius.
471  \param v3r <decimal> Vertex 3 rounding radius.
472 
473  \param centroid <boolean> Center centroid at origin.
474  \param incenter <boolean> Center incenter at origin.
475  \param center <boolean> Center about origin.
476 
477  \details
478 
479  \sa st_linear_extrude_scale for a description on specifying \p h.
480 
481  \b Example
482  \amu_eval ( function=etriangle_lal ${example_dim} )
483 *******************************************************************************/
484 module etriangle_lal
485 (
486  s1,
487  a,
488  s2,
489  h,
490  x = 1,
491  vr,
492  v1r,
493  v2r,
494  v3r,
495  centroid = false,
496  incenter = false,
497  center = false
498 )
499 {
500  st_linear_extrude_scale(h=h, center=center)
502  (
503  s1=s1, a=a, s2=s2, x=x,
504  vr=vr, v1r=v1r, v2r=v2r, v3r=v3r,
505  centroid=centroid, incenter=incenter
506  );
507 }
508 
509 //! An extruded general triangle specified by a side and two adjacent angles.
510 /***************************************************************************//**
511  \param a1 <decimal> The adjacent angle 1 in degrees.
512  \param s <decimal> The side length adjacent to the angles.
513  \param a2 <decimal> The adjacent angle 2 in degrees.
514 
515  \param h <vector|decimal> A vector of decimals or a single decimal to
516  specify simple extrusion height.
517 
518  \param x <decimal> The side to draw on the positive x-axis (\p x=1 for \p s).
519 
520  \param vr <decimal> The default vertex rounding radius.
521  \param v1r <decimal> Vertex 1 rounding radius.
522  \param v2r <decimal> Vertex 2 rounding radius.
523  \param v3r <decimal> Vertex 3 rounding radius.
524 
525  \param centroid <boolean> Center centroid at origin.
526  \param incenter <boolean> Center incenter at origin.
527  \param center <boolean> Center about origin.
528 
529  \details
530 
531  \sa st_linear_extrude_scale for a description on specifying \p h.
532 
533  \b Example
534  \amu_eval ( function=etriangle_ala ${example_dim} )
535 *******************************************************************************/
536 module etriangle_ala
537 (
538  a1,
539  s,
540  a2,
541  h,
542  x = 1,
543  vr,
544  v1r,
545  v2r,
546  v3r,
547  centroid = false,
548  incenter = false,
549  center = false
550 )
551 {
552  st_linear_extrude_scale(h=h, center=center)
554  (
555  a1=a1, s=s, a2=a2, x=x,
556  vr=vr, v1r=v1r, v2r=v2r, v3r=v3r,
557  centroid=centroid, incenter=incenter
558  );
559 }
560 
561 //! An extruded general triangle specified by a side, one adjacent angle and the opposite angle.
562 /***************************************************************************//**
563  \param a1 <decimal> The opposite angle 1 in degrees.
564  \param a2 <decimal> The adjacent angle 2 in degrees.
565  \param s <decimal> The side length.
566 
567  \param h <vector|decimal> A vector of decimals or a single decimal to
568  specify simple extrusion height.
569 
570  \param x <decimal> The side to draw on the positive x-axis (\p x=1 for \p s).
571 
572  \param vr <decimal> The default vertex rounding radius.
573  \param v1r <decimal> Vertex 1 rounding radius.
574  \param v2r <decimal> Vertex 2 rounding radius.
575  \param v3r <decimal> Vertex 3 rounding radius.
576 
577  \param centroid <boolean> Center centroid at origin.
578  \param incenter <boolean> Center incenter at origin.
579  \param center <boolean> Center about origin.
580 
581  \details
582 
583  \sa st_linear_extrude_scale for a description on specifying \p h.
584 
585  \b Example
586  \amu_eval ( function=etriangle_aal ${example_dim} )
587 *******************************************************************************/
588 module etriangle_aal
589 (
590  a1,
591  a2,
592  s,
593  h,
594  x = 1,
595  vr,
596  v1r,
597  v2r,
598  v3r,
599  centroid = false,
600  incenter = false,
601  center = false
602 )
603 {
604  st_linear_extrude_scale(h=h, center=center)
606  (
607  a1=a1, a2=a2, s=s, x=x,
608  vr=vr, v1r=v1r, v2r=v2r, v3r=v3r,
609  centroid=centroid, incenter=incenter
610  );
611 }
612 
613 //! An extruded right-angled triangle specified by its opposite and adjacent side lengths.
614 /***************************************************************************//**
615  \param x <decimal> The length of the side along the x-axis.
616  \param y <decimal> The length of the side along the y-axis.
617 
618  \param h <vector|decimal> A vector of decimals or a single decimal to
619  specify simple extrusion height.
620 
621  \param vr <decimal> The default vertex rounding radius.
622  \param v1r <decimal> Vertex 1 rounding radius.
623  \param v2r <decimal> Vertex 2 rounding radius.
624  \param v3r <decimal> Vertex 3 rounding radius.
625 
626  \param centroid <boolean> Center centroid at origin.
627  \param incenter <boolean> Center incenter at origin.
628  \param center <boolean> Center about origin.
629 
630  \details
631 
632  \sa st_linear_extrude_scale for a description on specifying \p h.
633 
634  \b Example
635  \amu_eval ( function=etriangle_ll ${example_dim} )
636 *******************************************************************************/
637 module etriangle_ll
638 (
639  x,
640  y,
641  h,
642  vr,
643  v1r,
644  v2r,
645  v3r,
646  centroid = false,
647  incenter = false,
648  center = false
649 )
650 {
651  st_linear_extrude_scale(h=h, center=center)
653  (
654  x=x, y=y,
655  vr=vr, v1r=v1r, v2r=v2r, v3r=v3r,
656  centroid=centroid, incenter=incenter
657  );
658 }
659 
660 //! An extruded right-angled triangle specified by a side length and an angle.
661 /***************************************************************************//**
662  \param x <decimal> The length of the side along the x-axis.
663  \param y <decimal> The length of the side along the y-axis.
664  \param aa <decimal> The adjacent angle in degrees.
665  \param oa <decimal> The opposite angle in degrees.
666 
667  \param h <vector|decimal> A vector of decimals or a single decimal to
668  specify simple extrusion height.
669 
670  \param vr <decimal> The default vertex rounding radius.
671  \param v1r <decimal> Vertex 1 rounding radius.
672  \param v2r <decimal> Vertex 2 rounding radius.
673  \param v3r <decimal> Vertex 3 rounding radius.
674 
675  \param centroid <boolean> Center centroid at origin.
676  \param incenter <boolean> Center incenter at origin.
677  \param center <boolean> Center about origin.
678 
679  \details
680 
681  \sa st_linear_extrude_scale for a description on specifying \p h.
682 
683  \b Example
684  \amu_eval ( function=etriangle_la ${example_dim} )
685 
686  \note When both \p x and \p y are given, both triangles are rendered.
687  \note When both \p aa and \p oa are given, \p aa is used.
688 *******************************************************************************/
689 module etriangle_la
690 (
691  x,
692  y,
693  aa,
694  oa,
695  h,
696  vr,
697  v1r,
698  v2r,
699  v3r,
700  centroid = false,
701  incenter = false,
702  center = false
703 )
704 {
705  st_linear_extrude_scale(h=h, center=center)
707  (
708  x=x, y=y, aa=aa, oa=oa,
709  vr=vr, v1r=v1r, v2r=v2r, v3r=v3r,
710  centroid=centroid, incenter=incenter
711  );
712 }
713 
714 //! An extruded n-sided equiangular/equilateral regular polygon.
715 /***************************************************************************//**
716  \param n <decimal> The number of sides.
717  \param r <decimal> The ngon vertex radius.
718 
719  \param h <vector|decimal> A vector of decimals or a single decimal to
720  specify simple extrusion height.
721 
722  \param vr <decimal> The vertex rounding radius.
723 
724  \param center <boolean> Center about origin.
725 
726  \details
727 
728  \sa st_linear_extrude_scale for a description on specifying \p h.
729 
730  \b Example
731  \amu_eval ( function=engon ${example_dim} )
732 
733  See [Wikipedia](https://en.wikipedia.org/wiki/Regular_polygon)
734  for more information.
735 *******************************************************************************/
736 module engon
737 (
738  n,
739  r,
740  h,
741  vr,
742  center = false
743 )
744 {
745  st_linear_extrude_scale(h=h, center=center)
746  ngon(n=n, r=r, vr=vr);
747 }
748 
749 //! An extruded ellipse.
750 /***************************************************************************//**
751  \param size <vector|decimal> A vector [rx, ry] of decimals
752  or a single decimal for (rx=ry).
753 
754  \param h <vector|decimal> A vector of decimals or a single decimal to
755  specify simple extrusion height.
756 
757  \param center <boolean> Center about origin.
758 
759  \details
760 
761  \sa st_linear_extrude_scale for a description on specifying \p h.
762 
763  \b Example
764  \amu_eval ( function=eellipse ${example_dim} )
765 *******************************************************************************/
766 module eellipse
767 (
768  size,
769  h,
770  center = false
771 )
772 {
773  st_linear_extrude_scale(h=h, center=center)
774  ellipse(size=size);
775 }
776 
777 //! An extruded ellipse with a removed elliptical core.
778 /***************************************************************************//**
779  \param size <vector|decimal> A vector [rx, ry] of decimals
780  or a single decimal for (rx=ry).
781  \param core <vector|decimal> A vector [rx, ry] of decimals
782  or a single decimal for (rx=ry).
783 
784  \param h <vector|decimal> A vector of decimals or a single decimal to
785  specify simple extrusion height.
786 
787  \param t <vector|decimal> A vector [x, y] of decimals
788  or a single decimal for (x=y).
789 
790  \param co <vector> Core offset. A vector [x, y] of decimals.
791  \param cr <decimal> Core z-rotation.
792 
793  \param center <boolean> Center about origin.
794 
795  \details
796 
797  \sa st_linear_extrude_scale for a description on specifying \p h.
798 
799  Thickness \p t
800  \li <tt>core = size - t</tt>; when \p t and \p size are given.
801  \li <tt>size = core + t</tt>; when \p t and \p core are given.
802 
803  \b Example
804  \amu_eval ( function=eellipse_c ${example_dim} )
805 *******************************************************************************/
806 module eellipse_c
807 (
808  size,
809  core,
810  h,
811  t,
812  co,
813  cr = 0,
814  center = false
815 )
816 {
817  st_linear_extrude_scale(h=h, center=center)
818  ellipse_c(size=size, core=core, t=t, co=co, cr=cr);
819 }
820 
821 //! An extruded ellipse sector.
822 /***************************************************************************//**
823  \param size <vector|decimal> A vector [rx, ry] of decimals
824  or a single decimal for (rx=ry).
825 
826  \param h <vector|decimal> A vector of decimals or a single decimal to
827  specify simple extrusion height.
828 
829  \param a1 <decimal> The start angle in degrees.
830  \param a2 <decimal> The stop angle in degrees.
831 
832  \param center <boolean> Center about origin.
833 
834  \details
835 
836  \sa st_linear_extrude_scale for a description on specifying \p h.
837 
838  \b Example
839  \amu_eval ( function=eellipse_s ${example_dim} )
840 *******************************************************************************/
841 module eellipse_s
842 (
843  size,
844  h,
845  a1 = 0,
846  a2 = 0,
847  center = false
848 )
849 {
850  st_linear_extrude_scale(h=h, center=center)
851  ellipse_s(size=size, a1=a1, a2=a2);
852 }
853 
854 //! An extruded sector of an ellipse with a removed elliptical core.
855 /***************************************************************************//**
856  \param size <vector|decimal> A vector [rx, ry] of decimals
857  or a single decimal for (rx=ry).
858  \param core <vector|decimal> A vector [rx, ry] of decimals
859  or a single decimal for (rx=ry).
860 
861  \param h <vector|decimal> A vector of decimals or a single decimal to
862  specify simple extrusion height.
863 
864  \param t <vector|decimal> A vector [x, y] of decimals
865  or a single decimal for (x=y).
866 
867  \param a1 <decimal> The start angle in degrees.
868  \param a2 <decimal> The stop angle in degrees.
869 
870  \param co <vector> Core offset. A vector [x, y] of decimals.
871  \param cr <decimal> Core z-rotation.
872 
873  \param center <boolean> Center about origin.
874 
875  \details
876 
877  \sa st_linear_extrude_scale for a description on specifying \p h.
878 
879  Thickness \p t
880  \li <tt>core = size - t</tt>; when \p t and \p size are given.
881  \li <tt>size = core + t</tt>; when \p t and \p core are given.
882 
883  \b Example
884  \amu_eval ( function=eellipse_cs ${example_dim} )
885 *******************************************************************************/
886 module eellipse_cs
887 (
888  size,
889  core,
890  h,
891  t,
892  a1 = 0,
893  a2 = 0,
894  co,
895  cr = 0,
896  center = false
897 )
898 {
899  st_linear_extrude_scale(h=h, center=center)
900  ellipse_cs(a1=a1, a2=a2, size=size, core=core, t=t, co=co, cr=cr);
901 }
902 
903 //! An extruded two dimensional star.
904 /***************************************************************************//**
905  \param size <vector|decimal> A vector [l, w] of decimals
906  or a single decimal for (size=l=2*w).
907 
908  \param h <vector|decimal> A vector of decimals or a single decimal to
909  specify simple extrusion height.
910 
911  \param n <decimal> The number of points.
912 
913  \param vr <vector|decimal> The vertex rounding radius. A vector
914  [v1r, v2r, v3r] of decimals or a single decimal for (v1r=v2r=v3r).
915 
916  \param center <boolean> Center about origin.
917 
918  \details
919 
920  \sa st_linear_extrude_scale for a description on specifying \p h.
921 
922  \b Example
923  \amu_eval ( function=estar2d ${example_dim} )
924 *******************************************************************************/
925 module estar2d
926 (
927  size,
928  h,
929  n = 5,
930  vr,
931  center = false
932 )
933 {
934  st_linear_extrude_scale(h=h, center=center)
935  star2d(size=size, n=n, vr=vr);
936 }
937 
938 //! @}
939 //! @}
940 
941 //----------------------------------------------------------------------------//
942 // openscad-amu auxiliary scripts
943 //----------------------------------------------------------------------------//
944 
945 /*
946 BEGIN_SCOPE dim;
947  BEGIN_OPENSCAD;
948  include <shapes2de.scad>;
949 
950  shape = "eellipse_cs";
951  $fn = 72;
952 
953  if (shape == "erectangle")
954  erectangle( size=[25,40], vr=5, vrm=3, h=20, center=true );
955  else if (shape == "erectangle_c")
956  erectangle_c( size=[40,20], t=[10,1], co=[0,-6], cr=10, vr=5, vrm1=12, h=30, center=true );
957  else if (shape == "erhombus")
958  erhombus( size=[40,25], h=10, vr=[3,0,3,9], center=true );
959  else if (shape == "etriangle_ppp")
960  etriangle_ppp( v1=[0,0], v2=[5,25], v3=[40,5], h=20, vr=2, centroid=true, center=true );
961  else if (shape == "etriangle_lll")
962  etriangle_lll( s1=30, s2=40, s3=50, h=20, vr=2, centroid=true, center=true );
963  else if (shape == "etriangle_vl_c")
964  etriangle_vl_c(vs=50, vc=30, h=15, co=[0,-10], cr=180, vr=[2,2,8], centroid=true, center=true);
965  else if (shape == "etriangle_lal")
966  etriangle_lal( s1=50, a=60, s2=30, h=20, vr=2, centroid=true, center=true );
967  else if (shape == "etriangle_ala")
968  etriangle_ala( a1=30, s=50, a2=60, h=20, vr=2, centroid=true, center=true );
969  else if (shape == "etriangle_aal")
970  etriangle_aal( a1=60, a2=30, s=40, h=20, vr=2, centroid=true, center=true );
971  else if (shape == "etriangle_ll")
972  etriangle_ll( x=30, y=40, h=20, vr=2, centroid=true, center=true );
973  else if (shape == "etriangle_la")
974  etriangle_la( x=40, aa=30, h=20, vr=2, centroid=true, center=true );
975  else if (shape == "engon")
976  engon( n=6, r=25, h=20, vr=6, center=true );
977  else if (shape == "eellipse")
978  eellipse( size=[25, 40], h=20, center=true );
979  else if (shape == "eellipse_c")
980  eellipse_c( size=[25,40], core=[16,10], co=[0,10], cr=45, h=20, center=true );
981  else if (shape == "eellipse_s")
982  eellipse_s( size=[25,40], h=20, a1=90, a2=180, center=true );
983  else if (shape == "eellipse_cs")
984  eellipse_cs( size=[25,40], t=[10,5], a1=90, a2=180, co=[10,0], cr=45, h=20, center=true );
985  else if (shape == "estar2d")
986  estar2d( size=[40, 15], h=15, n=5, vr=2, center=true );
987  END_OPENSCAD;
988 
989  BEGIN_MFSCRIPT;
990  include --path "${INCLUDE_PATH}" {config_base,config_png}.mfs;
991 
992  views name "views" views "diag";
993  defines name "shapes" define "shape"
994  strings "
995  erectangle
996  erectangle_c
997  erhombus
998  etriangle_ppp
999  etriangle_lll
1000  etriangle_vl_c
1001  etriangle_lal
1002  etriangle_ala
1003  etriangle_aal
1004  etriangle_ll
1005  etriangle_la
1006  engon
1007  eellipse
1008  eellipse_c
1009  eellipse_s
1010  eellipse_cs
1011  estar2d
1012  ";
1013  variables add_opts_combine "views shapes";
1014  variables add_opts "--viewall --autocenter";
1015 
1016  include --path "${INCLUDE_PATH}" script_std.mfs;
1017  END_MFSCRIPT;
1018 END_SCOPE;
1019 
1020 BEGIN_SCOPE manifest;
1021  BEGIN_OPENSCAD;
1022  include <shapes2de.scad>;
1023 
1024  $fn = 72;
1025 
1026  st_cartesian_copy( grid=5, incr=60, center=true )
1027  {
1028  erectangle( size=[25,40], vr=5, vrm=3, h=20, center=true );
1029  erectangle_c( size=[40,20], t=[10,1], co=[0,-6], cr=10, vr=5, vrm1=12, h=30, center=true );
1030  erhombus( size=[40,25], h=10, vr=[3,0,3,9], center=true );
1031  etriangle_ppp( v1=[0,0], v2=[5,25], v3=[40,5], h=20, vr=2, centroid=true, center=true );
1032  etriangle_lll( s1=30, s2=40, s3=50, h=20, vr=2, centroid=true, center=true );
1033  etriangle_vl_c( vs=50, vc=30, h=15, co=[0,-10], cr=180, vr=[2,2,8], centroid=true, center=true );
1034  etriangle_lal( s1=50, a=60, s2=30, h=20, vr=2, centroid=true, center=true );
1035  etriangle_ala( a1=30, s=50, a2=60, h=20, vr=2, centroid=true, center=true );
1036  etriangle_aal( a1=60, a2=30, s=40, h=20, vr=2, centroid=true, center=true );
1037  etriangle_ll( x=30, y=40, h=20, vr=2, centroid=true, center=true );
1038  etriangle_la( x=40, aa=30, h=20, vr=2, centroid=true, center=true );
1039  engon( n=6, r=25, h=20, vr=6, center=true );
1040  eellipse( size=[25, 40], h=20, center=true );
1041  eellipse_c( size=[25,40], core=[16,10], co=[0,10], cr=45, h=20, center=true );
1042  eellipse_s( size=[25,40], h=20, a1=90, a2=180, center=true );
1043  eellipse_cs( size=[25,40], t=[10,5], a1=90, a2=180, co=[10,0], cr=45, h=20, center=true );
1044  estar2d( size=[40, 15], h=15, n=5, vr=2, center=true );
1045  }
1046  END_OPENSCAD;
1047 
1048  BEGIN_MFSCRIPT;
1049  include --path "${INCLUDE_PATH}" {config_base,config_stl}.mfs;
1050  include --path "${INCLUDE_PATH}" script_std.mfs;
1051  END_MFSCRIPT;
1052 END_SCOPE;
1053 */
1054 
1055 //----------------------------------------------------------------------------//
1056 // end of file
1057 //----------------------------------------------------------------------------//
module rectangle(size, vr, vrm=0, center=false)
A rectangle with edge, fillet, and/or chamfer corners.
Definition: shapes2d.scad:112
module eellipse(size, h, center=false)
An extruded ellipse.
Definition: shapes2de.scad:767
module etriangle_vl(v, h, vr, centroid=false, incenter=false, center=false)
An extruded general triangle specified by a vector of its three side lengths.
Definition: shapes2de.scad:387
module ellipse_cs(size, core, t, a1=0, a2=0, co, cr=0)
A sector of an ellipse with a removed elliptical core.
Definition: shapes2d.scad:1239
module ngon(n, r, vr)
An n-sided equiangular/equilateral regular polygon.
Definition: shapes2d.scad:1054
module triangle_vl_c(vs, vc, co, cr=0, vr, vr1, vr2, centroid=false, incenter=false)
A general triangle specified by its sides with a removed triangular core.
Definition: shapes2d.scad:638
module triangle_lal(s1, a, s2, x=1, vr, v1r, v2r, v3r, centroid=false, incenter=false)
A general triangle specified by two sides and the included angle.
Definition: shapes2d.scad:730
module triangle_la(x, y, aa, oa, vr, v1r, v2r, v3r, centroid=false, incenter=false)
A right-angled triangle specified by a side length and an angle.
Definition: shapes2d.scad:1002
module rectangle_c(size, core, t, co, cr=0, vr, vr1, vr2, vrm=0, vrm1, vrm2, center=false)
A rectangle with a removed rectangular core.
Definition: shapes2d.scad:232
module erectangle(size, h, vr, vrm=0, center=false)
An extruded rectangle with edge, fillet, and/or chamfer corners.
Definition: shapes2de.scad:110
module etriangle_aal(a1, a2, s, h, x=1, vr, v1r, v2r, v3r, centroid=false, incenter=false, center=false)
An extruded general triangle specified by a side, one adjacent angle and the opposite angle...
Definition: shapes2de.scad:589
module etriangle_ala(a1, s, a2, h, x=1, vr, v1r, v2r, v3r, centroid=false, incenter=false, center=false)
An extruded general triangle specified by a side and two adjacent angles.
Definition: shapes2de.scad:537
module ellipse_c(size, core, t, co, cr=0)
An ellipse with a removed elliptical core.
Definition: shapes2d.scad:1129
module ellipse_s(size, a1=0, a2=0)
An ellipse sector.
Definition: shapes2d.scad:1171
module st_linear_extrude_scale(h, center=false)
Linearly extrude 2D shape with extrusion upper and lower scaling.
Definition: transform.scad:230
module triangle_ala(a1, s, a2, x=1, vr, v1r, v2r, v3r, centroid=false, incenter=false)
A general triangle specified by a side and two adjacent angles.
Definition: shapes2d.scad:799
module etriangle_lal(s1, a, s2, h, x=1, vr, v1r, v2r, v3r, centroid=false, incenter=false, center=false)
An extruded general triangle specified by two sides and the included angle.
Definition: shapes2de.scad:485
module estar2d(size, h, n=5, vr, center=false)
An extruded two dimensional star.
Definition: shapes2de.scad:926
module triangle_aal(a1, a2, s, x=1, vr, v1r, v2r, v3r, centroid=false, incenter=false)
A general triangle specified by a side, one adjacent angle and the opposite angle.
Definition: shapes2d.scad:882
module eellipse_cs(size, core, h, t, a1=0, a2=0, co, cr=0, center=false)
An extruded sector of an ellipse with a removed elliptical core.
Definition: shapes2de.scad:887
module etriangle_lll(s1, s2, s3, h, vr, v1r, v2r, v3r, centroid=false, incenter=false, center=false)
An extruded general triangle specified by its three side lengths.
Definition: shapes2de.scad:338
module triangle_vp(v, vr, centroid=false, incenter=false)
A general triangle specified by a vector of its three vertices.
Definition: shapes2d.scad:474
module etriangle_vl_c(vs, vc, h, co, cr=0, vr, vr1, vr2, centroid=false, incenter=false, center=false)
A general triangle specified by its sides with a removed triangular core.
Definition: shapes2de.scad:433
module triangle_vl(v, vr, centroid=false, incenter=false)
A general triangle specified by a vector of its three side lengths.
Definition: shapes2d.scad:584
module etriangle_ll(x, y, h, vr, v1r, v2r, v3r, centroid=false, incenter=false, center=false)
An extruded right-angled triangle specified by its opposite and adjacent side lengths.
Definition: shapes2de.scad:638
module etriangle_la(x, y, aa, oa, h, vr, v1r, v2r, v3r, centroid=false, incenter=false, center=false)
An extruded right-angled triangle specified by a side length and an angle.
Definition: shapes2de.scad:690
module eellipse_c(size, core, h, t, co, cr=0, center=false)
An extruded ellipse with a removed elliptical core.
Definition: shapes2de.scad:807
module triangle_ppp(v1, v2, v3, vr, v1r, v2r, v3r, centroid=false, incenter=false)
A general triangle specified by three vertices.
Definition: shapes2d.scad:398
module etriangle_vp(v, h, vr, centroid=false, incenter=false, center=false)
An extruded general triangle specified by a vector of its three vertices.
Definition: shapes2de.scad:299
module eellipse_s(size, h, a1=0, a2=0, center=false)
An extruded ellipse sector.
Definition: shapes2de.scad:842
module star2d(size, n=5, vr)
A two dimensional star.
Definition: shapes2d.scad:1285
module etriangle_ppp(v1, v2, v3, h, vr, v1r, v2r, v3r, centroid=false, incenter=false, center=false)
An extruded general triangle specified by three vertices.
Definition: shapes2de.scad:250
module triangle_ll(x, y, vr, v1r, v2r, v3r, centroid=false, incenter=false)
A right-angled triangle specified by its opposite and adjacent side lengths.
Definition: shapes2d.scad:959
module triangle_lll(s1, s2, s3, vr, v1r, v2r, v3r, centroid=false, incenter=false)
A general triangle specified by its three side lengths.
Definition: shapes2d.scad:524
module rhombus(size, vr, center=false)
A rhombus.
Definition: shapes2d.scad:297
module ellipse(size)
An ellipse.
Definition: shapes2d.scad:1088
module erhombus(size, h, vr, center=false)
An extruded rhombus.
Definition: shapes2de.scad:213
module engon(n, r, h, vr, center=false)
An extruded n-sided equiangular/equilateral regular polygon.
Definition: shapes2de.scad:737
module erectangle_c(size, core, h, t, co, cr=0, vr, vr1, vr2, vrm=0, vrm1, vrm2, center=false)
An extruded rectangle with a removed rectangular core.
Definition: shapes2de.scad:164