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