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