From 51532e09c029e4a085859650f292a5087a39906f Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 15 May 2021 09:33:25 +0800 Subject: [PATCH] add docs --- README.md | 6 +-- docs/lib3x-tri_delaunay_indices.md | 42 +++++++++++++++++++ docs/lib3x-tri_delaunay_shapes.md | 42 +++++++++++++++++++ docs/lib3x-tri_delaunay_voronoi.md | 42 +++++++++++++++++++ src/experimental/demo/tri_delaunay_demo2.scad | 23 ---------- src/triangle/tri_delaunay_indices.scad | 10 +++++ src/triangle/tri_delaunay_shapes.scad | 10 +++++ src/triangle/tri_delaunay_voronoi.scad | 10 +++++ 8 files changed, 159 insertions(+), 26 deletions(-) create mode 100644 docs/lib3x-tri_delaunay_indices.md create mode 100644 docs/lib3x-tri_delaunay_shapes.md create mode 100644 docs/lib3x-tri_delaunay_voronoi.md delete mode 100644 src/experimental/demo/tri_delaunay_demo2.scad diff --git a/README.md b/README.md index 96faab82..d0c085c6 100644 --- a/README.md +++ b/README.md @@ -359,6 +359,6 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp [**triangle/tri_incenter**(shape_pts)](https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_incenter.html) | return the incenter of a triangle. [**triangle/tri_ear_clipping**(shape_pts, ret = "TRI_INDICES", ...)](https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_ear_clipping.html) | triangulation by [ear clipping](https://en.wikipedia.org/wiki/Polygon_triangulation#Ear_clipping_method). [**triangle/tri_delaunay**(points, ret = "TRI_INDICES")](https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_delaunay.html) | Join a set of points to make a [Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation). -**triangle/tri_delaunay_indices**(d) | return triangle indices from a delaunay object. -**triangle/tri_delaunay_shapes**(d) | return triangle shapes from a delaunay object. -**triangle/tri_delaunay_voronoi**(d) | return [Voronoi](https://en.wikipedia.org/wiki/Voronoi_diagram) cells from a delaunay object. \ No newline at end of file +[**triangle/tri_delaunay_indices**(d)](https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_delaunay_indices.html) | return triangle indices from a delaunay object. +[**triangle/tri_delaunay_shapes**(d)](https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_delaunay_shapes.html) | return triangle shapes from a delaunay object. +[**triangle/tri_delaunay_voronoi**(d)](https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_delaunay_voronoi.html) | return [Voronoi](https://en.wikipedia.org/wiki/Voronoi_diagram) cells from a delaunay object. \ No newline at end of file diff --git a/docs/lib3x-tri_delaunay_indices.md b/docs/lib3x-tri_delaunay_indices.md new file mode 100644 index 00000000..6c722f10 --- /dev/null +++ b/docs/lib3x-tri_delaunay_indices.md @@ -0,0 +1,42 @@ +# tri_delaunay_indices + +A method of [`tri_delaunay`](lib3x-tri_delaunay.html). Returns the indices from a delaunay object. + +**Since:** 3.0 + +## Parameters + +- `d` : A delaunay object. + +## Examples + + use ; + use ; + use ; + use ; + use ; + + points = [for(i = [0:20]) rands(-100, 100, 2)]; + + delaunay = tri_delaunay(points, ret = "DELAUNAY"); + + tris = [for(ti = tri_delaunay_indices(delaunay)) [for(i = ti) points[i]]]; + linear_extrude(1) + for(t = tris) { + polygon(t); + } + + color("black") + linear_extrude(2) + for(t = tri_delaunay_shapes(delaunay)) { + offset(-1) + polygon(t); + } + + color("red") + linear_extrude(3) + for(t = tri_delaunay_voronoi(delaunay)) { + hull_polyline2d(concat(t, [t[0]]), 2); + } + +![tri_delaunay_indices](images/lib3x-tri_delaunay_indices-1.JPG) diff --git a/docs/lib3x-tri_delaunay_shapes.md b/docs/lib3x-tri_delaunay_shapes.md new file mode 100644 index 00000000..d361990a --- /dev/null +++ b/docs/lib3x-tri_delaunay_shapes.md @@ -0,0 +1,42 @@ +# tri_delaunay_shapes + +A method of [`tri_delaunay`](lib3x-tri_delaunay.html). Returns triangle shapes from a delaunay object. + +**Since:** 3.0 + +## Parameters + +- `d` : A delaunay object. + +## Examples + + use ; + use ; + use ; + use ; + use ; + + points = [for(i = [0:20]) rands(-100, 100, 2)]; + + delaunay = tri_delaunay(points, ret = "DELAUNAY"); + + tris = [for(ti = tri_delaunay_indices(delaunay)) [for(i = ti) points[i]]]; + linear_extrude(1) + for(t = tris) { + polygon(t); + } + + color("black") + linear_extrude(2) + for(t = tri_delaunay_shapes(delaunay)) { + offset(-1) + polygon(t); + } + + color("red") + linear_extrude(3) + for(t = tri_delaunay_voronoi(delaunay)) { + hull_polyline2d(concat(t, [t[0]]), 2); + } + +![tri_delaunay_shapes](images/lib3x-tri_delaunay_shapes-1.JPG) diff --git a/docs/lib3x-tri_delaunay_voronoi.md b/docs/lib3x-tri_delaunay_voronoi.md new file mode 100644 index 00000000..a0ad3ed5 --- /dev/null +++ b/docs/lib3x-tri_delaunay_voronoi.md @@ -0,0 +1,42 @@ +# tri_delaunay_voronoi + +A method of [`tri_delaunay`](lib3x-tri_delaunay.html). Returns voronoi cells from a delaunay object. + +**Since:** 3.0 + +## Parameters + +- `d` : A delaunay object. + +## Examples + + use ; + use ; + use ; + use ; + use ; + + points = [for(i = [0:20]) rands(-100, 100, 2)]; + + delaunay = tri_delaunay(points, ret = "DELAUNAY"); + + tris = [for(ti = tri_delaunay_indices(delaunay)) [for(i = ti) points[i]]]; + linear_extrude(1) + for(t = tris) { + polygon(t); + } + + color("black") + linear_extrude(2) + for(t = tri_delaunay_shapes(delaunay)) { + offset(-1) + polygon(t); + } + + color("red") + linear_extrude(3) + for(t = tri_delaunay_voronoi(delaunay)) { + hull_polyline2d(concat(t, [t[0]]), 2); + } + +![tri_delaunay_voronoi](images/lib3x-tri_delaunay_voronoi-1.JPG) diff --git a/src/experimental/demo/tri_delaunay_demo2.scad b/src/experimental/demo/tri_delaunay_demo2.scad deleted file mode 100644 index 25118239..00000000 --- a/src/experimental/demo/tri_delaunay_demo2.scad +++ /dev/null @@ -1,23 +0,0 @@ -use ; -use ; -use ; -use ; - -points = [for(i = [0:20]) rands(-100, 100, 2)]; - -color("black") -for(p = points) { - translate(p) - circle(2); -} - -delaunay = tri_delaunay(points, ret = "DELAUNAY"); - -%draw(tri_delaunay_shapes(delaunay)); -#draw(tri_delaunay_voronoi(delaunay)); - -module draw(pointsOfTriangles) { - for(t = pointsOfTriangles) { - hull_polyline2d(concat(t, [t[0]])); - } -} \ No newline at end of file diff --git a/src/triangle/tri_delaunay_indices.scad b/src/triangle/tri_delaunay_indices.scad index 6845fbad..db8c9047 100644 --- a/src/triangle/tri_delaunay_indices.scad +++ b/src/triangle/tri_delaunay_indices.scad @@ -1,3 +1,13 @@ +/** +* tri_circumcenter.scad +* +* @copyright Justin Lin, 2021 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_delaunay_indices.html +* +**/ + use <_impl/_tri_delaunay_comm_impl.scad>; use <../util/map/hashmap_keys.scad>; diff --git a/src/triangle/tri_delaunay_shapes.scad b/src/triangle/tri_delaunay_shapes.scad index e6dc1eb2..f5c26844 100644 --- a/src/triangle/tri_delaunay_shapes.scad +++ b/src/triangle/tri_delaunay_shapes.scad @@ -1,3 +1,13 @@ +/** +* tri_circumcenter.scad +* +* @copyright Justin Lin, 2021 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_delaunay_shapes.html +* +**/ + use <_impl/_tri_delaunay_comm_impl.scad>; use <../util/map/hashmap_keys.scad>; diff --git a/src/triangle/tri_delaunay_voronoi.scad b/src/triangle/tri_delaunay_voronoi.scad index 599e6773..e4103194 100644 --- a/src/triangle/tri_delaunay_voronoi.scad +++ b/src/triangle/tri_delaunay_voronoi.scad @@ -1,3 +1,13 @@ +/** +* tri_circumcenter.scad +* +* @copyright Justin Lin, 2021 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_delaunay_voronoi.html +* +**/ + use <_impl/_tri_delaunay_comm_impl.scad>; use <_impl/_tri_delaunay_voronoi_impl.scad>; use <../util/map/hashmap.scad>;