omdl  v0.9.5
OpenSCAD Mechanical Design Library
polygon.scad
Go to the documentation of this file.
1 //! Roundable polygons generated in 2D space.
2 /***************************************************************************//**
3  \file
4  \author Roy Allen Sutton
5  \date 2019-2024
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  \amu_define group_name (Polygons)
31  \amu_define group_brief (Roundable polygons generated in 2D space.)
32 
33  \amu_include (include/amu/pgid_path_pstem_pg.amu)
34 *******************************************************************************/
35 
36 //----------------------------------------------------------------------------//
37 // group and macros.
38 //----------------------------------------------------------------------------//
39 
40 /***************************************************************************//**
41  \amu_include (include/amu/group_in_parent_start.amu)
42  \amu_include (include/amu/includes_required.amu)
43 
44  \amu_define image_view (top)
45 
46  \amu_define group_id (${parent})
47  \amu_include (include/amu/scope_diagrams_3d_in_group.amu)
48 
49  \amu_define group_id (${group})
50  \amu_include (include/amu/scope_diagrams_3d_in_group.amu)
51 
52  \amu_include (include/amu/scope_diagram_3d_object.amu)
53  \amu_include (include/amu/scope_diagram_2d_object.amu)
54 *******************************************************************************/
55 
56 //----------------------------------------------------------------------------//
57 // rounding
58 //----------------------------------------------------------------------------//
59 
60 //! \name Rounding
61 //! @{
62 
63 /***************************************************************************//**
64  \amu_define round_sr_common_api
65  (
66  The side rounding radius may be zero, positive, or negative. When
67  positive, the rounding arc is swept clockwise. When negative, the
68  arc is swept counter clockwise. A positive radius much be greater
69  than the side length.
70  )
71 *******************************************************************************/
72 
73 /***************************************************************************//**
74  \amu_define round_vr_common_api
75  (
76  Each vertex may be assigned an individual rounding radius, rounding
77  mode, and facet number as described in \ref polygon_round_eve_all_p
78  by using the parameters: \p vr, \p vrm, and \p vfn. When \p vr is
79  undefined, no rounding is performed on the polygon vertices.
80  )
81 *******************************************************************************/
82 
83 //! A polygon edge round with constant radius between two vectors.
84 /***************************************************************************//**
85  \copydetails polygon_round_eve_p()
86 
87  \details
88 
89  \amu_eval ( object=pg_corner_round ${object_ex_diagram_3d} )
90 *******************************************************************************/
91 module pg_corner_round
92 (
93  r = 1,
94  m = 1,
95  c = origin2d,
96  v1 = x_axis2d_uv,
97  v2 = y_axis2d_uv
98 )
99 {
100  p = concat([c], polygon_round_eve_p(r=r, m=m, c=c, v1=v1, v2=v2));
101 
102  polygon(p);
103 }
104 
105 //! @}
106 
107 //----------------------------------------------------------------------------//
108 // round side general
109 //----------------------------------------------------------------------------//
110 
111 //! \name Round side general
112 //! @{
113 
114 //! A polygon rectangle with side rounding.
115 /***************************************************************************//**
116  \param size <decimal-list-2 | decimal> A list [x, y] of decimals
117  or a single decimal for (x=y).
118 
119  \param o <point-2d> The origin offset coordinate [x, y].
120 
121  \param sr <decimal-list-2 | decimal> The side rounding radius.
122 
123  \param center <boolean> Center about origin.
124 
125  \details
126 
127  \amu_eval ( ${round_sr_common_api} )
128  \amu_eval ( object=pg_rectangle_rs ${object_ex_diagram_3d} )
129 *******************************************************************************/
130 module pg_rectangle_rs
131 (
132  size = 1,
133  o,
134  sr,
135  center = false
136 )
137 {
138  sx = defined_e_or(size, 0, size);
139  sy = defined_e_or(size, 1, sx);
140 
141  rd = defined_or(sr, 1/grid_fine);
142  rx = defined_e_or(sr, 0, rd);
143  ry = defined_e_or(sr, 1, rx);
144 
145  assert( (rx <= 0) || (rx > 0) && (rx >= sx), "(+) x-radius less than x-side" );
146  assert( (ry <= 0) || (ry > 0) && (ry >= sy), "(+) y-radius less than y-side" );
147 
148  cwx = (ry > 0) ? true : false;
149  cwy = (rx > 0) ? true : false;
150 
151  ts =
152  [ // centered around origin
153  ["arc_pv", [[ 0, +ry], [-sx, +sy]/2, cwx]],
154  ["arc_pv", [[-rx, 0], [-sx, -sy]/2, cwy]],
155  ["arc_pv", [[ 0, -ry], [+sx, -sy]/2, cwx]],
156  ["arc_pv", [[+rx, 0], [+sx, +sy]/2, cwy]]
157  ];
158 
159  c = polygon_turtle_p( ts, i=[sx,sy]/2 );
160 
161  p = (center == true) && is_undef( o ) ? c
162  : (center == true) && !is_undef( o ) ? translate_p(c, o)
163  : (center == false) && is_undef( o ) ? translate_p(c, [sx, sy]/2)
164  : translate_p(c, o + [sx, sy]/2);
165 
166  polygon(p);
167 }
168 
169 //! @}
170 
171 //----------------------------------------------------------------------------//
172 // round vertex general
173 //----------------------------------------------------------------------------//
174 
175 //! \name Round vertex general
176 //! @{
177 
178 //! A polygon elliptical sector.
179 /***************************************************************************//**
180  \copydetails polygon_elliptical_sector_p()
181 
182  \details
183 
184  \amu_eval ( object=pg_elliptical_sector ${object_ex_diagram_3d} )
185 *******************************************************************************/
187 (
188  r = 1,
189  c = origin2d,
190  v1 = x_axis2d_uv,
191  v2 = x_axis2d_uv,
192  s = true
193 )
194 {
195  p = polygon_elliptical_sector_p(r=r, c=c, v1=v1, v2=v2, s=s);
196 
197  polygon(p);
198 }
199 
200 //! A polygon trapezoid with individual vertex rounding and arc facets.
201 /***************************************************************************//**
202  \copydetails polygon_trapezoid_p()
203 
204  \param vr <decimal-list-4 | decimal> The vertices rounding radius.
205  \param vrm <integer-list-4 | integer> The vertices rounding mode.
206  \param vfn <integer-list-4> The vertices arc fragment number.
207 
208  \param center <boolean> Center origin at trapezoid centroid.
209 
210  \details
211 
212  \amu_eval ( ${round_vr_common_api} )
213  \amu_eval ( object=pg_trapezoid ${object_ex_diagram_3d} )
214 *******************************************************************************/
215 module pg_trapezoid
216 (
217  b = 1,
218  h,
219  l = 1,
220  a = 90,
221  o = origin2d,
222  vr,
223  vrm = 1,
224  vfn,
225  center = false
226 )
227 {
228  c = polygon_trapezoid_p(b=b, h=h, l=l, a=a, o=o);
229 
230  m = (center == false) ? c : translate_p(c, o-polygon_centroid(c));
231  p = is_undef( vr ) ? m : polygon_round_eve_all_p(c=m, vr=vr, vrm=vrm, vfn=vfn);
232 
233  polygon(p);
234 }
235 
236 //! A polygon rectangle with vertex rounding.
237 /***************************************************************************//**
238  \param size <decimal-list-2 | decimal> A list [x, y] of decimals
239  or a single decimal for (x=y).
240 
241  \param o <point-2d> The origin offset coordinate [x, y].
242 
243  \param vr <decimal-list-4 | decimal> The vertices rounding radius.
244  \param vrm <integer-list-4 | integer> The vertices rounding mode.
245  \param vfn <integer-list-4> The vertices arc fragment number.
246 
247  \param center <boolean> Center about origin.
248 
249  \details
250 
251  \amu_eval ( ${round_vr_common_api} )
252  \amu_eval ( object=pg_rectangle ${object_ex_diagram_3d} )
253 *******************************************************************************/
254 module pg_rectangle
255 (
256  size = 1,
257  o,
258  vr,
259  vrm = 1,
260  vfn,
261  center = false
262 )
263 {
264  rx = defined_e_or(size, 0, size);
265  ry = defined_e_or(size, 1, rx);
266 
267  c = (center == true)
268  ? [[-rx,-ry], [-rx,ry], [rx,ry], [rx,-ry]]/2
269  : [[0,0], [0,ry], [rx,ry], [rx,0]];
270 
271  m = is_undef( o ) ? c : translate_p(c, o);
272  p = is_undef( vr ) ? m : polygon_round_eve_all_p(c=m, vr=vr, vrm=vrm, vfn=vfn);
273 
274  polygon(p);
275 }
276 
277 //! A polygon rhombus with vertex rounding.
278 /***************************************************************************//**
279  \param size <decimal-list-2 | decimal> A list [x, y] of decimals
280  or a single decimal for (x=y).
281 
282  \param o <point-2d> The origin offset coordinate [x, y].
283 
284  \param vr <decimal-list-4 | decimal> The vertices rounding radius.
285  \param vrm <integer-list-4 | integer> The vertices rounding mode.
286  \param vfn <integer-list-4> The vertices arc fragment number.
287 
288  \param center <boolean> Center about origin.
289 
290  \details
291 
292  \amu_eval ( ${round_vr_common_api} )
293  \amu_eval ( object=pg_rhombus ${object_ex_diagram_3d} )
294 *******************************************************************************/
295 module pg_rhombus
296 (
297  size = 1,
298  o,
299  vr,
300  vrm = 1,
301  vfn,
302  center = false
303 )
304 {
305  rx = defined_e_or(size, 0, size)/2;
306  ry = defined_e_or(size, 1, rx*2)/2;
307 
308  c = (center == true)
309  ? [[-rx,0], [0,ry], [rx,0], [0,-ry]]
310  : [[rx*2,ry], [rx,ry*2], [0,ry], [rx,0]];
311 
312  m = is_undef( o ) ? c : translate_p(c, o);
313  p = is_undef( vr ) ? m : polygon_round_eve_all_p(c=m, vr=vr, vrm=vrm, vfn=vfn);
314 
315  polygon(p);
316 }
317 
318 //! A n-sided regular polygon with vertex rounding.
319 /***************************************************************************//**
320  \param n <integer> The number of sides.
321  \param r <decimal> The radius.
322  \param o <point-2d> The origin offset coordinate [x, y].
323 
324  \param vr <decimal-list-n | decimal> The vertices rounding radius.
325  \param vrm <integer-list-n | integer> The vertices rounding mode.
326  \param vfn <integer-list-n | integer> The vertices arc fragment number.
327 
328  \param center <boolean> Center about origin.
329 
330  \details
331 
332  \amu_eval ( ${round_vr_common_api} )
333  \amu_eval ( object=pg_ngon ${object_ex_diagram_3d} )
334 *******************************************************************************/
335 module pg_ngon
336 (
337  n = 3,
338  r = 1,
339  o,
340  vr,
341  vrm = 1,
342  vfn,
343  center = true
344 )
345 {
346  z = (center == true) ? origin2d : [r, r];
347 
348  c = polygon_regular_p(n=n, r=r, c=z);
349 
350  m = is_undef( o ) ? c : translate_p(c, o);
351  p = is_undef( vr ) ? m : polygon_round_eve_all_p(c=m, vr=vr, vrm=vrm, vfn=vfn);
352 
353  polygon(p);
354 }
355 
356 //! @}
357 
358 //----------------------------------------------------------------------------//
359 // round vertex triangles
360 //----------------------------------------------------------------------------//
361 
362 //! \name Round vertex triangles
363 //! @{
364 
365 /***************************************************************************//**
366  \amu_define triangle_common_api
367  (
368  \param o <point-2d> The origin offset coordinate [x, y].
369 
370  \param vr <decimal-list-3 | decimal> The vertices rounding radius.
371  \param vrm <integer-list-3 | integer> The vertices rounding mode.
372  \param vfn <integer-list-3 | integer> The vertices arc fragment number.
373 
374  \param cm <integer> The center mode; [0,1,2, or 3].
375 
376  \details
377 
378  cm | value description
379  :---------------|:---------------------------------
380  0 | origin at vertex v1
381  1 | origin at triangle centroid
382  2 | origin at triangle incenter
383  3 | origin at triangle circumcenter
384 
385  ${round_vr_common_api}
386  )
387 *******************************************************************************/
388 
389 //! A polygon triangle specified by three coordinate points with vertex rounding.
390 /***************************************************************************//**
391  \param c <coords-list-3> A list, [v1, v2, v3], the vertex coordinates in 2d.
392 
393  \amu_eval ( ${triangle_common_api} )
394 
395  \amu_eval
396  ( object=ppp
397  title="Parameter location" scope_id=diagram_label
398  html_image_w=384 latex_image_w="2.25in"
399  ${object_diagram_2d}
400  )
401  \amu_eval ( object=pg_triangle_ppp ${object_ex_diagram_3d} )
402 *******************************************************************************/
403 module pg_triangle_ppp
404 (
405  c,
406  o,
407  vr,
408  vrm = 1,
409  vfn,
410  cm = 0
411 )
412 {
413  l = (cm == 0) ? undef
414  : (cm == 1) ? triangle_centroid(c=c, d=2)
415  : (cm == 2) ? triangle2d_incenter(c=c)
416  : (cm == 3) ? triangle_circumcenter(c=c, d=2)
417  : undef;
418 
419  m = is_undef( o ) ? c : translate_p(c, o);
420  n = is_undef( l ) ? m : translate_p(m, -l);
421  p = is_undef( vr ) ? n : polygon_round_eve_all_p(c=n, vr=vr, vrm=vrm, vfn=vfn);
422 
423  polygon(p);
424 }
425 
426 //! A polygon triangle specified by three side lengths with vertex rounding.
427 /***************************************************************************//**
428  \param v <decimal-list-3> A list, [s1, s2, s3], the side lengths.
429  \param a <integer> The triangle side alignment axis index
430  < \b x_axis_ci | \b y_axis_ci >.
431 
432  \amu_eval ( ${triangle_common_api} )
433 
434  \amu_eval
435  ( object=sss
436  title="Parameter location" scope_id=diagram_label
437  html_image_w=384 latex_image_w="2.25in"
438  ${object_diagram_2d}
439  )
440  \amu_eval ( object=pg_triangle_sss ${object_ex_diagram_3d} )
441 *******************************************************************************/
442 module pg_triangle_sss
443 (
444  v,
445  a = x_axis_ci,
446  o,
447  vr,
448  vrm = 1,
449  vfn,
450  cm = 0
451 )
452 {
453  c = triangle2d_sss2ppp(v, a=a);
454  pg_triangle_ppp(c=c, o=o, vr=vr, vrm=vrm, vfn=vfn, cm=cm);
455 }
456 
457 //! A polygon triangle specified by size-angle-size with vertex rounding.
458 /***************************************************************************//**
459  \param v <decimal-list-3> A list, [s1, a3, s2], the side lengths
460  and the included angle.
461  \param a <integer> The triangle side alignment axis index
462  < \b x_axis_ci | \b y_axis_ci >.
463 
464  \amu_eval ( ${triangle_common_api} )
465 
466  \amu_eval
467  ( object=sas
468  title="Parameter location" scope_id=diagram_label
469  html_image_w=384 latex_image_w="2.25in"
470  ${object_diagram_2d}
471  )
472  \amu_eval ( object=pg_triangle_sas ${object_ex_diagram_3d} )
473 *******************************************************************************/
474 module pg_triangle_sas
475 (
476  v,
477  a = x_axis_ci,
478  o,
479  vr,
480  vrm = 1,
481  vfn,
482  cm = 0
483 )
484 {
486  pg_triangle_ppp(c=c, o=o, vr=vr, vrm=vrm, vfn=vfn, cm=cm);
487 }
488 
489 //! A polygon triangle specified by angle-size-angle with vertex rounding.
490 /***************************************************************************//**
491  \param v <decimal-list-3> A list, [a1, s3, a2], the side length
492  and two adjacent angles.
493  \param a <integer> The triangle side alignment axis index
494  < \b x_axis_ci | \b y_axis_ci >.
495 
496  \amu_eval ( ${triangle_common_api} )
497 
498  \amu_eval
499  ( object=asa
500  title="Parameter location" scope_id=diagram_label
501  html_image_w=384 latex_image_w="2.25in"
502  ${object_diagram_2d}
503  )
504  \amu_eval ( object=pg_triangle_asa ${object_ex_diagram_3d} )
505 *******************************************************************************/
506 module pg_triangle_asa
507 (
508  v,
509  a = x_axis_ci,
510  o,
511  vr,
512  vrm = 1,
513  vfn,
514  cm = 0
515 )
516 {
518  pg_triangle_ppp(c=c, o=o, vr=vr, vrm=vrm, vfn=vfn, cm=cm);
519 }
520 
521 //! A polygon triangle specified by angle-angle-size with vertex rounding.
522 /***************************************************************************//**
523  \param v <decimal-list-3> A list, [a1, a2, s1], a side length,
524  one adjacent and the opposite angle.
525  \param a <integer> The triangle side alignment axis index
526  < \b x_axis_ci | \b y_axis_ci >.
527 
528  \amu_eval ( ${triangle_common_api} )
529 
530  \amu_eval
531  ( object=aas
532  title="Parameter location" scope_id=diagram_label
533  html_image_w=384 latex_image_w="2.25in"
534  ${object_diagram_2d}
535  )
536  \amu_eval ( object=pg_triangle_aas ${object_ex_diagram_3d} )
537 *******************************************************************************/
538 module pg_triangle_aas
539 (
540  v,
541  a = x_axis_ci,
542  o,
543  vr,
544  vrm = 1,
545  vfn,
546  cm = 0
547 )
548 {
550  pg_triangle_ppp(c=c, o=o, vr=vr, vrm=vrm, vfn=vfn, cm=cm);
551 }
552 
553 //! @}
554 
555 //! @}
556 //! @}
557 
558 //----------------------------------------------------------------------------//
559 // openscad-amu auxiliary scripts
560 //----------------------------------------------------------------------------//
561 
562 /*
563 BEGIN_SCOPE diagram;
564  BEGIN_OPENSCAD;
565  include <omdl-base.scad>;
566 
567  shape = "pg_corner_round";
568  $fn = 36;
569 
570  if (shape == "pg_corner_round")
571  pg_corner_round( r=20, v1=[1,1], v2=135 );
572  else if (shape == "pg_rectangle_rs")
573  pg_rectangle_rs( [60,30], sr=[60,-100], center=true );
574  else if (shape == "pg_elliptical_sector")
575  pg_elliptical_sector( r=[20, 15], v1=115, v2=-115 );
576  else if (shape == "pg_trapezoid")
577  pg_trapezoid( b=[50,20], l=25, a=45, vr=2, center=true);
578  else if (shape == "pg_rectangle")
579  pg_rectangle( size=[30,10], vr=2, center=true );
580  else if (shape == "pg_rhombus")
581  pg_rhombus( size=[30, 15], vr=[3,1,3,1], center=true );
582  else if (shape == "pg_ngon")
583  pg_ngon( n=6, r=10, vr=1, center=true );
584  else if (shape == "pg_triangle_ppp")
585  pg_triangle_ppp( c=[[-15,-5],[10,15], [10,-10]], vr=1 );
586  else if (shape == "pg_triangle_sss")
587  pg_triangle_sss( v=[10,20,25], vr=1, cm=1);
588  else if (shape == "pg_triangle_sas")
589  pg_triangle_sas( v=[15,30,20], vr=1, cm=1);
590  else if (shape == "pg_triangle_asa")
591  pg_triangle_asa( v=[60,30,25], vr=1, cm=1);
592  else if (shape == "pg_triangle_aas")
593  pg_triangle_aas( v=[30,40,25], vr=1, cm=1);
594  END_OPENSCAD;
595 
596  BEGIN_MFSCRIPT;
597  include --path "${INCLUDE_PATH}" {var_init,var_gen_png2eps}.mfs;
598 
599  views name "views" views "top";
600  defines name "shapes" define "shape"
601  strings "
602  pg_corner_round
603  pg_rectangle_rs
604  pg_elliptical_sector
605  pg_trapezoid
606  pg_rectangle
607  pg_rhombus
608  pg_ngon
609  pg_triangle_ppp
610  pg_triangle_sss
611  pg_triangle_sas
612  pg_triangle_asa
613  pg_triangle_aas
614  ";
615  variables add_opts_combine "views shapes";
616  variables add_opts "--viewall --autocenter --view=axes";
617 
618  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
619  END_MFSCRIPT;
620 END_SCOPE;
621 
622 BEGIN_SCOPE diagram_label;
623  BEGIN_OPENSCAD;
624  include <omdl-base.scad>;
625  include <tools/operation_cs.scad>;
626  include <tools/drafting/draft-base.scad>;
627 
628  module dt (vl = empty_lst, al = empty_lst, sl = empty_lst)
629  {
630  s = 10;
631  t = [6, 8, 7];
632  r = min(t)/len(t)*s;
633 
634  c = triangle2d_sss2ppp(t)*s;
635 
636  draft_polygon(c, w=s*2/3);
637  draft_axes([[0,12], [0,7]]*s, ts=s/2);
638 
639  for (i = [0 : len(c)-1])
640  {
641  cv = c[i];
642  os = shift(shift(v=c, n=i, r=false), 1, r=false, c=false);
643 
644  if ( !is_empty( find( mv=i, v=vl )) )
645  draft_dim_leader(cv, v1=[mean(os), cv], l1=5, t=str("v", i+1), bs=0, cmh=s*1, cmv=s);
646 
647  if ( !is_empty( find( mv=i, v=al )) )
648  draft_dim_angle(c=cv, r=r, v1=[cv, second(os)], v2=[cv, first(os)], t=str("a", i+1), a=0, cmh=s, cmv=s);
649 
650  if ( !is_empty( find( mv=i, v=sl )) )
651  draft_dim_line(p1=first(os), p2=second(os), t=str("s", i+1), cmh=s, cmv=s);
652  }
653  }
654 
655  object = "triangle_sas2sss";
656 
657  if (object == "ppp") dt( vl = [0,1,2]);
658  if (object == "sas") dt( vl = [0,1,2], al = [2], sl = [0,1]);
659  if (object == "asa") dt( vl = [0,1,2], al = [0,1], sl = [2]);
660  if (object == "aas") dt( vl = [0,1,2], al = [0,1], sl = [0]);
661  if (object == "sss") dt( sl = [0,1,2]);
662  END_OPENSCAD;
663 
664  BEGIN_MFSCRIPT;
665  include --path "${INCLUDE_PATH}" {var_init,var_gen_svg}.mfs;
666 
667  defines name "objects" define "object"
668  strings "
669  ppp
670  sas
671  asa
672  aas
673  sss
674  ";
675  variables add_opts_combine "objects";
676  variables add_opts "--viewall --autocenter";
677 
678  include --path "${INCLUDE_PATH}" scr_make_mf.mfs;
679  END_MFSCRIPT;
680 END_SCOPE;
681 */
682 
683 //----------------------------------------------------------------------------//
684 // end of file
685 //----------------------------------------------------------------------------//
x_axis_ci
<integer> The coordinate axis index for the Euclidean space x-axis.
Definition: constants.scad:395
origin2d
<point-2d> The origin point coordinate in 2d Euclidean space.
Definition: constants.scad:407
x_axis2d_uv
<vector-2d> The unit vector of the positive x-axis in 2d Euclidean space.
Definition: constants.scad:410
y_axis2d_uv
<vector-2d> The unit vector of the positive y-axis in 2d Euclidean space.
Definition: constants.scad:413
grid_fine
OpenSCAD fine grid limit.
Definition: constants.scad:310
function defined_e_or(v, i, d)
Return an element of an iterable when it exists or a default value otherwise.
function defined_or(v, d)
Return given value, if defined, or a secondary value, if primary is not defined.
function translate_p(c, v)
Translate all coordinates dimensions.
function polygon_trapezoid_p(b=1, h, l=1, a=90, o=origin2d, cw=true)
Compute the coordinates for a rounded trapezoid in 2D space.
function polygon_regular_p(n, r, a, c=origin2d, o=0, vr, cw=true)
Compute coordinates for an n-sided regular polygon in 2D.
function polygon_round_eve_all_p(c, vr=0, vrm=1, vfn, w=true, cw=true)
Compute coordinates that round all of the vertices between each adjacent edges in 2D.
function polygon_round_eve_p(r=1, m=1, c=origin2d, v1=x_axis2d_uv, v2=y_axis2d_uv, fn, cw=true)
Compute coordinates for a constant radius vertex round between two edge vectors in 2D.
function polygon_centroid(c, p)
Compute the center of mass of a polygon in a Euclidean 2d-space.
function polygon_turtle_p(s, i=origin2d, c=0)
Generate list of coordinate points from simple operation step notation.
function polygon_elliptical_sector_p(r=1, c=origin2d, v1=x_axis2d_uv, v2=x_axis2d_uv, s=true, fn, cw=true)
Compute coordinates for an elliptical sector in 2D.
function triangle_sas2sss(v)
Compute the side lengths of a triangle given two sides and the included angle.
function triangle_asa2sss(v)
Compute the side lengths of a triangle given a side and two adjacent angles.
function triangle_centroid(c, d=2)
Compute the centroid of a triangle.
function triangle_aas2sss(v)
Compute the side lengths of a triangle given a side, one adjacent and the opposite angle.
function triangle_circumcenter(c, d=2)
Compute the coordinate of a triangle's circumcenter.
function triangle2d_sss2ppp(v, a=x_axis_ci, cw=true)
Compute a set of vertex coordinates for a triangle given its side lengths in 2D.
function triangle2d_incenter(c)
Compute the center coordinate of a triangle's incircle in 2D.
module pg_ngon(n=3, r=1, o, vr, vrm=1, vfn, center=true)
A n-sided regular polygon with vertex rounding.
Definition: polygon.scad:860
module pg_trapezoid(b=1, h, l=1, a=90, o=origin2d, vr, vrm=1, vfn, center=false)
A polygon trapezoid with individual vertex rounding and arc facets.
Definition: polygon.scad:710
module pg_elliptical_sector(r=1, c=origin2d, v1=x_axis2d_uv, v2=x_axis2d_uv, s=true)
A polygon elliptical sector.
Definition: polygon.scad:671
module pg_rectangle_rs(size=1, o, sr, center=false)
A polygon rectangle with side rounding.
Definition: polygon.scad:610
module pg_corner_round(r=1, m=1, c=origin2d, v1=x_axis2d_uv, v2=y_axis2d_uv)
A polygon edge round with constant radius between two vectors.
Definition: polygon.scad:561
module pg_triangle_sas(v, a=x_axis_ci, o, vr, vrm=1, vfn, cm=0)
A polygon triangle specified by size-angle-size with vertex rounding.
Definition: polygon.scad:1098
module pg_rhombus(size=1, o, vr, vrm=1, vfn, center=false)
A polygon rhombus with vertex rounding.
Definition: polygon.scad:810
module pg_triangle_asa(v, a=x_axis_ci, o, vr, vrm=1, vfn, cm=0)
A polygon triangle specified by angle-size-angle with vertex rounding.
Definition: polygon.scad:1163
module pg_rectangle(size=1, o, vr, vrm=1, vfn, center=false)
A polygon rectangle with vertex rounding.
Definition: polygon.scad:759
module pg_triangle_sss(v, a=x_axis_ci, o, vr, vrm=1, vfn, cm=0)
A polygon triangle specified by three side lengths with vertex rounding.
Definition: polygon.scad:1033
module pg_triangle_ppp(c, o, vr, vrm=1, vfn, cm=0)
A polygon triangle specified by three coordinate points with vertex rounding.
Definition: polygon.scad:961
module pg_triangle_aas(v, a=x_axis_ci, o, vr, vrm=1, vfn, cm=0)
A polygon triangle specified by angle-angle-size with vertex rounding.
Definition: polygon.scad:1228