omdl  v0.9.5
OpenSCAD Mechanical Design Library
Polygons

Roundable polygons generated in 2D space. More...

+ Collaboration diagram for Polygons:

Files

file  polygon.scad
 Roundable polygons generated in 2D space.
 

Rounding

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. More...
 

Round side general

module pg_rectangle_rs (size=1, o, sr, center=false)
 A polygon rectangle with side rounding. More...
 

Round vertex general

module pg_elliptical_sector (r=1, c=origin2d, v1=x_axis2d_uv, v2=x_axis2d_uv, s=true)
 A polygon elliptical sector. More...
 
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. More...
 
module pg_rectangle (size=1, o, vr, vrm=1, vfn, center=false)
 A polygon rectangle with vertex rounding. More...
 
module pg_rhombus (size=1, o, vr, vrm=1, vfn, center=false)
 A polygon rhombus with vertex rounding. More...
 
module pg_ngon (n=3, r=1, o, vr, vrm=1, vfn, center=true)
 A n-sided regular polygon with vertex rounding. More...
 

Round vertex triangles

module pg_triangle_ppp (c, o, vr, vrm=1, vfn, cm=0)
 A polygon triangle specified by three coordinate points with vertex rounding. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Roundable polygons generated in 2D space.

Requires:
include <omdl-base.scad>;
Polygons
IIIIII
pg_corner_round()
pg_elliptical_sector()
pg_ngon()
IVVVI
pg_rectangle()
pg_rectangle_rs()
pg_rhombus()
VIIVIIIIX
pg_trapezoid()
pg_triangle_aas()
pg_triangle_asa()
XXIXII
pg_triangle_ppp()
pg_triangle_sas()
pg_triangle_sss()

Function Documentation

◆ pg_corner_round()

module pg_corner_round ( = 1,
= 1,
= origin2d,
v1  = x_axis2d_uv,
v2  = y_axis2d_uv 
)

A polygon edge round with constant radius between two vectors.

Parameters
r<decimal> The round radius.
m<integer> The round mode.
c<point-2d> The round center coordinate [x, y].
v1<line-2d | decimal> The round start angle. A 2d line, vector, or decimal angle 1.
v2<line-2d | decimal> The round end angle. A 2d line, vector, or decimal angle 2.
fn<integer> The number of facets.
cw<boolean> The coordinate point ordering.
Returns
<coords-2d> A list of coordinates points [[x, y], ...].

Normally, angle 1 should be less than angle 2. The edge coordinates will start at angle 1, end at angle 2, and will have radius r along a rounded transition from edge 1 to 2. When cw = true the coordinates will start at edge 1 and increase toward edge 2. When cw = false this ordering is reversed.

The round mode may be one of the following:

mode name description
1 fillet fillet from one edge to the next
2 round round from one edge to the next
3 chamfer bevel from one edge to the next

Object example

pg_corner_round( r=20, v1=[1,1], v2=135 );
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
pg_corner_round

Definition at line 560 of file polygon.scad.

+ Here is the call graph for this function:

◆ pg_elliptical_sector()

module pg_elliptical_sector ( = 1,
= origin2d,
v1  = x_axis2d_uv,
v2  = x_axis2d_uv,
= true 
)

A polygon elliptical sector.

Parameters
r<decimal-list-2 | decimal> The elliptical radius. A list [rx, ry] of decimals or a single decimal for (rx=ry).
c<point-2d> The center coordinate [x, y].
v1<line-2d | decimal> The sector angle 1. A 2d line, vector, or decimal.
v2<line-2d | decimal> The sector angle 2. A 2d line, vector, or decimal.
s<boolean> Use signed vector angle conversions. When false, positive angle conversion will be used.
fn<integer> The number of [facets] (optional).
cw<boolean> The coordinate point ordering.
Returns
<coords-2d> A list of coordinates points [[x, y], ...].

The coordinates will be between angle 1 and angle 2 and will be ordered clockwise. The sector sweep direction can be controlled by the sign of the angles. When fn is undefined, its value is determined by get_fn().

Object example

pg_elliptical_sector( r=[20, 15], v1=115, v2=-115 );
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
pg_elliptical_sector

Definition at line 670 of file polygon.scad.

+ Here is the call graph for this function:

◆ pg_ngon()

module pg_ngon ( = 3,
= 1,
,
vr  ,
vrm  = 1,
vfn  ,
center  = true 
)

A n-sided regular polygon with vertex rounding.

Parameters
n<integer> The number of sides.
r<decimal> The radius.
o<point-2d> The origin offset coordinate [x, y].
vr<decimal-list-n | decimal> The vertices rounding radius.
vrm<integer-list-n | integer> The vertices rounding mode.
vfn<integer-list-n | integer> The vertices arc fragment number.
center<boolean> Center about origin.

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Object example

pg_ngon( n=6, r=10, vr=1, center=true );
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
pg_ngon

Definition at line 859 of file polygon.scad.

+ Here is the call graph for this function:

◆ pg_rectangle()

module pg_rectangle ( size  = 1,
,
vr  ,
vrm  = 1,
vfn  ,
center  = false 
)

A polygon rectangle with vertex rounding.

Parameters
size<decimal-list-2 | decimal> A list [x, y] of decimals or a single decimal for (x=y).
o<point-2d> The origin offset coordinate [x, y].
vr<decimal-list-4 | decimal> The vertices rounding radius.
vrm<integer-list-4 | integer> The vertices rounding mode.
vfn<integer-list-4> The vertices arc fragment number.
center<boolean> Center about origin.

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Object example

pg_rectangle( size=[30,10], vr=2, center=true );
module pg_rectangle(size=1, o, vr, vrm=1, vfn, center=false)
A polygon rectangle with vertex rounding.
Definition: polygon.scad:759
pg_rectangle

Definition at line 758 of file polygon.scad.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pg_rectangle_rs()

module pg_rectangle_rs ( size  = 1,
,
sr  ,
center  = false 
)

A polygon rectangle with side rounding.

Parameters
size<decimal-list-2 | decimal> A list [x, y] of decimals or a single decimal for (x=y).
o<point-2d> The origin offset coordinate [x, y].
sr<decimal-list-2 | decimal> The side rounding radius.
center<boolean> Center about origin.

The side rounding radius may be zero, positive, or negative. When positive, the rounding arc is swept clockwise. When negative, the arc is swept counter clockwise. A positive radius much be greater than the side length.

Object example

pg_rectangle_rs( [60,30], sr=[60,-100], center=true );
module pg_rectangle_rs(size=1, o, sr, center=false)
A polygon rectangle with side rounding.
Definition: polygon.scad:610
pg_rectangle_rs

Definition at line 609 of file polygon.scad.

+ Here is the call graph for this function:

◆ pg_rhombus()

module pg_rhombus ( size  = 1,
,
vr  ,
vrm  = 1,
vfn  ,
center  = false 
)

A polygon rhombus with vertex rounding.

Parameters
size<decimal-list-2 | decimal> A list [x, y] of decimals or a single decimal for (x=y).
o<point-2d> The origin offset coordinate [x, y].
vr<decimal-list-4 | decimal> The vertices rounding radius.
vrm<integer-list-4 | integer> The vertices rounding mode.
vfn<integer-list-4> The vertices arc fragment number.
center<boolean> Center about origin.

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Object example

pg_rhombus( size=[30, 15], vr=[3,1,3,1], center=true );
module pg_rhombus(size=1, o, vr, vrm=1, vfn, center=false)
A polygon rhombus with vertex rounding.
Definition: polygon.scad:810
pg_rhombus

Definition at line 809 of file polygon.scad.

+ Here is the call graph for this function:

◆ pg_trapezoid()

module pg_trapezoid ( = 1,
,
= 1,
= 90,
= origin2d,
vr  ,
vrm  = 1,
vfn  ,
center  = false 
)

A polygon trapezoid with individual vertex rounding and arc facets.

Parameters
b<decimal-list-2 | decimal> The base lengths. A list [b1, b2] of 2 decimals or a single decimal for (b1=b2).
h<decimal> The perpendicular height between bases.
l<decimal> The left side leg length.
a<decimal> The angle between the lower base and left leg.
o<point-2d> The origin offset coordinate [x, y].
cw<boolean> Polygon vertex ordering.
Returns
<coords-2d> A list of coordinates points [[x, y], ...].

When both h and l are specified, h has precedence. The function generates parallelograms, rectangles, and squares with the appropriate parameter assignments. See Wikipedia for more general information on trapezoids.

Parameters
vr<decimal-list-4 | decimal> The vertices rounding radius.
vrm<integer-list-4 | integer> The vertices rounding mode.
vfn<integer-list-4> The vertices arc fragment number.
center<boolean> Center origin at trapezoid centroid.

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Object example

pg_trapezoid( b=[50,20], l=25, a=45, vr=2, center=true);
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
pg_trapezoid

Definition at line 709 of file polygon.scad.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pg_triangle_aas()

module pg_triangle_aas ( ,
= x_axis_ci,
,
vr  ,
vrm  = 1,
vfn  ,
cm  = 0 
)

A polygon triangle specified by angle-angle-size with vertex rounding.

Parameters
v<decimal-list-3> A list, [a1, a2, s1], a side length, one adjacent and the opposite angle.
a<integer> The triangle side alignment axis index < x_axis_ci | y_axis_ci >.
o<point-2d> The origin offset coordinate [x, y].
vr<decimal-list-3 | decimal> The vertices rounding radius.
vrm<integer-list-3 | integer> The vertices rounding mode.
vfn<integer-list-3 | integer> The vertices arc fragment number.
cm<integer> The center mode; [0,1,2, or 3].
cm value description
0 origin at vertex v1
1 origin at triangle centroid
2 origin at triangle incenter
3 origin at triangle circumcenter

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Parameter location

aas

Object example

pg_triangle_aas( v=[30,40,25], vr=1, cm=1);
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
pg_triangle_aas

Definition at line 1227 of file polygon.scad.

+ Here is the call graph for this function:

◆ pg_triangle_asa()

module pg_triangle_asa ( ,
= x_axis_ci,
,
vr  ,
vrm  = 1,
vfn  ,
cm  = 0 
)

A polygon triangle specified by angle-size-angle with vertex rounding.

Parameters
v<decimal-list-3> A list, [a1, s3, a2], the side length and two adjacent angles.
a<integer> The triangle side alignment axis index < x_axis_ci | y_axis_ci >.
o<point-2d> The origin offset coordinate [x, y].
vr<decimal-list-3 | decimal> The vertices rounding radius.
vrm<integer-list-3 | integer> The vertices rounding mode.
vfn<integer-list-3 | integer> The vertices arc fragment number.
cm<integer> The center mode; [0,1,2, or 3].
cm value description
0 origin at vertex v1
1 origin at triangle centroid
2 origin at triangle incenter
3 origin at triangle circumcenter

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Parameter location

asa

Object example

pg_triangle_asa( v=[60,30,25], vr=1, cm=1);
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
pg_triangle_asa

Definition at line 1162 of file polygon.scad.

+ Here is the call graph for this function:

◆ pg_triangle_ppp()

module pg_triangle_ppp ( ,
,
vr  ,
vrm  = 1,
vfn  ,
cm  = 0 
)

A polygon triangle specified by three coordinate points with vertex rounding.

Parameters
c<coords-list-3> A list, [v1, v2, v3], the vertex coordinates in 2d.
o<point-2d> The origin offset coordinate [x, y].
vr<decimal-list-3 | decimal> The vertices rounding radius.
vrm<integer-list-3 | integer> The vertices rounding mode.
vfn<integer-list-3 | integer> The vertices arc fragment number.
cm<integer> The center mode; [0,1,2, or 3].
cm value description
0 origin at vertex v1
1 origin at triangle centroid
2 origin at triangle incenter
3 origin at triangle circumcenter

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Parameter location

ppp

Object example

pg_triangle_ppp( c=[[-15,-5],[10,15], [10,-10]], vr=1 );
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
pg_triangle_ppp

Definition at line 960 of file polygon.scad.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pg_triangle_sas()

module pg_triangle_sas ( ,
= x_axis_ci,
,
vr  ,
vrm  = 1,
vfn  ,
cm  = 0 
)

A polygon triangle specified by size-angle-size with vertex rounding.

Parameters
v<decimal-list-3> A list, [s1, a3, s2], the side lengths and the included angle.
a<integer> The triangle side alignment axis index < x_axis_ci | y_axis_ci >.
o<point-2d> The origin offset coordinate [x, y].
vr<decimal-list-3 | decimal> The vertices rounding radius.
vrm<integer-list-3 | integer> The vertices rounding mode.
vfn<integer-list-3 | integer> The vertices arc fragment number.
cm<integer> The center mode; [0,1,2, or 3].
cm value description
0 origin at vertex v1
1 origin at triangle centroid
2 origin at triangle incenter
3 origin at triangle circumcenter

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Parameter location

sas

Object example

pg_triangle_sas( v=[15,30,20], vr=1, cm=1);
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
pg_triangle_sas

Definition at line 1097 of file polygon.scad.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pg_triangle_sss()

module pg_triangle_sss ( ,
= x_axis_ci,
,
vr  ,
vrm  = 1,
vfn  ,
cm  = 0 
)

A polygon triangle specified by three side lengths with vertex rounding.

Parameters
v<decimal-list-3> A list, [s1, s2, s3], the side lengths.
a<integer> The triangle side alignment axis index < x_axis_ci | y_axis_ci >.
o<point-2d> The origin offset coordinate [x, y].
vr<decimal-list-3 | decimal> The vertices rounding radius.
vrm<integer-list-3 | integer> The vertices rounding mode.
vfn<integer-list-3 | integer> The vertices arc fragment number.
cm<integer> The center mode; [0,1,2, or 3].
cm value description
0 origin at vertex v1
1 origin at triangle centroid
2 origin at triangle incenter
3 origin at triangle circumcenter

Each vertex may be assigned an individual rounding radius, rounding mode, and facet number as described in polygon_round_eve_all_p by using the parameters: vr, vrm, and vfn. When vr is undefined, no rounding is performed on the polygon vertices.

Parameter location

sss

Object example

pg_triangle_sss( v=[10,20,25], vr=1, cm=1);
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
pg_triangle_sss

Definition at line 1032 of file polygon.scad.

+ Here is the call graph for this function: