![]() |
omdl
v1.0
OpenSCAD Mechanical Design Library
|
Roundable polygons generated in 2D space. More...
Collaboration diagram for Polygons:Files | |
| file | polygon.scad |
| Roundable polygons generated in 2D space. | |
Round edge | |
| 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. 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, o=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=5, 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... | |
Roundable polygons generated in 2D space.
| Requires: |
|---|
| include <omdl-base.scad>; |
| 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.
| r | <decimal> The round radius. |
| m | <integer> The round mode. |
| o | <point-2d> The vertex coordinate [x, y] at which the two edge vectors meet (the corner being rounded). |
| v1 | <line-2d | decimal> The first edge direction. A 2d line, vector, or decimal angle. |
| v2 | <line-2d | decimal> The second edge direction. A 2d line, vector, or decimal angle. |
| fn | <integer> The number of facets (optional). |
| cw | <boolean> Coordinate point ordering. When true the list runs from the inflection point on edge 1 toward the inflection point on edge 2; when false the order is reversed. |
v1, followed by the arc (or chamfer) segment, and ending at the inflection point on v2. These points replace the original corner vertex in a polygon path.Computes the replacement coordinate sequence for a single polygon corner at o between edges v1 and v2. Normally, edge angle 1 should be less than edge angle 2.
The round mode may be one of the following:
| mode | name | description |
|---|---|---|
| 1 | fillet | concave arc (inward, tangent to both edges) |
| 2 | round | convex arc (outward, tangent to both edges) |
| 3 | chamfer | straight bevel between the two inflection points |
Object example
Definition at line 563 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module pg_rectangle_rs | ( | size | = 1, |
| o | , | ||
| sr | , | ||
| center | = false |
||
| ) |
A polygon rectangle with side rounding.
| 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 must be greater than the side length. The arch center point is located along a line that starts at the mid-point of the side vertices and extends perpendicularly by the radius distance. The arch is swept about the center point with constant radius from one vertex to the next.
Object example
Definition at line 615 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module pg_elliptical_sector | ( | r | = 1, |
| o | = origin2d, |
||
| v1 | = x_axis2d_uv, |
||
| v2 | = x_axis2d_uv, |
||
| s | = true |
||
| ) |
A polygon elliptical sector.
| r | <decimal-list-2 | decimal> The elliptical radius. A list [rx, ry] of decimals where rx is the x-axis radius and ry is the y-axis radius, or a single decimal for (rx=ry). |
| o | <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> Coordinate point ordering. When true the returned list is in the natural computed order; when false the list is reversed. |
The coordinates sweep from angle v1 to angle v2. When v1 and v2 are equal, a full ellipse is returned. The sweep direction is determined by the signs of the angles; a positive delta sweeps counter-clockwise and a negative delta sweeps clockwise, regardless of the cw ordering parameter (which only controls whether the returned list is reversed).
When v1 and v2 are not equal, the origin point o is prepended to the coordinate list, forming a closed pie-sector shape when passed directly to polygon(). For a full ellipse, o is omitted and the result is a closed ring of perimeter points.
The parameter s controls how vector angles are converted to decimal degrees. When s = true (default), signed angle conversion is used, so vectors below the x-axis yield negative angles. When s = false, all angles are mapped to [0, 360). This affects sector orientation when v1 or v2 are given as 2d lines or vectors rather than explicit decimal angles.
When fn is undefined, its value is determined by get_fn().
Object example
Definition at line 684 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| 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. Takes precedence over l when both are specified. When neither h nor l is specified, l defaults to 1. |
| l | <decimal> The left side leg length. Used only when h is not specified; the resulting height is l × sin(a). |
| a | <decimal> The angle in degrees between the lower base and the left leg. When h is specified, restricted to [45, 135] to keep the upper-left vertex above the lower base. |
| o | <point-2d> The origin offset coordinate [x, y]. |
| cw | <boolean> Polygon vertex ordering. |
The four vertices are computed from the origin o as follows: p1 = o (lower-left), p2 = upper-left leg endpoint, p3 = p2 + [b2, 0] (upper-right), p4 = o + [b1, 0] (lower-right). The lower base has length b1 and the upper base has length b2.
When both h and l are specified, h takes precedence and the actual leg length is derived from h and a. When only l is given, the perpendicular height is l × sin(a). If h is specified, the angle a is restricted to the range [45, 135] to keep the upper-left vertex above the lower base.
Special cases: when b is a single decimal (b1 = b2) and a = 90 the result is a rectangle; when additionally b1 = h the result is a square. When a ≠ 90 and b1 = b2 the result is a parallelogram.
See Wikipedia for more general information on trapezoids.
| 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
Definition at line 723 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module pg_rectangle | ( | size | = 1, |
| o | , | ||
| vr | , | ||
| vrm | = 1, |
||
| vfn | , | ||
| center | = false |
||
| ) |
A polygon rectangle with vertex rounding.
| 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
Definition at line 772 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module pg_rhombus | ( | size | = 1, |
| o | , | ||
| vr | , | ||
| vrm | = 1, |
||
| vfn | , | ||
| center | = false |
||
| ) |
A polygon rhombus with vertex rounding.
| 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
Definition at line 823 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module pg_ngon | ( | n | = 5, |
| r | = 1, |
||
| o | , | ||
| vr | , | ||
| vrm | = 1, |
||
| vfn | , | ||
| center | = true |
||
| ) |
A n-sided regular polygon with vertex rounding.
| 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
Definition at line 873 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| module pg_triangle_ppp | ( | c | , |
| o | , | ||
| vr | , | ||
| vrm | = 1, |
||
| vfn | , | ||
| cm | = 0 |
||
| ) |
A polygon triangle specified by three coordinate points with vertex rounding.
| c | <points-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
Object example
Definition at line 974 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| 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
Object example
Definition at line 1046 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| 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
Object example
Definition at line 1111 of file polygon.scad.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| 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
Object example
Definition at line 1176 of file polygon.scad.
Here is the call graph for this function:| 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.
| 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
Object example
Definition at line 1241 of file polygon.scad.
Here is the call graph for this function: