diff --git a/docs/images/lib-triangulate-1.JPG b/docs/images/lib-triangulate-1.JPG new file mode 100644 index 00000000..b7d379b8 Binary files /dev/null and b/docs/images/lib-triangulate-1.JPG differ diff --git a/docs/lib-triangulate.md b/docs/lib-triangulate.md new file mode 100644 index 00000000..69e6aa99 --- /dev/null +++ b/docs/lib-triangulate.md @@ -0,0 +1,42 @@ +# triangulate + +Given a 2D shape. This function performs a simple polygon triangulation algorithm and returns the indices of each triangle. + +**Since:** 1.3. + +## Parameters + +- `shape_pts` : The shape points. +- `epsilon` : An upper bound on the relative error due to rounding in floating point arithmetic. Default to 0.0001. + +## Examples + + include ; + + shape = [ + [0, 0], + [10, 0], + [12, 5], + [5, 10], + [10, 15], + [0, 20], + [-5, 18], + [-18, 3], + [-4, 10] + ]; + + tris = triangulate(shape); + + difference() { + polygon(shape); + + for(tri = tris) { + offset(-.2) + polygon([for(idx = tri) shape[idx]]); + + } + } + + +![triangulate](images/lib-triangulate-1.JPG) + diff --git a/undocumented_features/triangulate_demo.scad b/undocumented_features/triangulate_demo.scad deleted file mode 100644 index 4beeb44b..00000000 --- a/undocumented_features/triangulate_demo.scad +++ /dev/null @@ -1,23 +0,0 @@ -include ; - -shape = [ - [0, 0], - [10, 0], - [12, 5], - [5, 10], - [10, 15], - [0, 20], - [-5, 18], - [-8, 3], - [-4, 10] -]; - -tris = triangulate(shape); - -polygon(shape); - -for(tri = tris) { - #offset(-.1) - polygon([for(idx = tri) shape[idx]]); - -} \ No newline at end of file diff --git a/undocumented_features/undocumented_note.md b/undocumented_features/undocumented_note.md index d4e90f6a..6b23206d 100644 --- a/undocumented_features/undocumented_note.md +++ b/undocumented_features/undocumented_note.md @@ -1,6 +1,3 @@ -triangulate - triangulate_demo.scad - shape_taiwan: new `dt` parameter bijection_offset: new `epsilon` parameter