mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-04-26 17:13:29 +02:00
add doc
This commit is contained in:
parent
6044aaeb75
commit
c0ad7be8b0
@ -357,7 +357,7 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp
|
||||
--|--
|
||||
[**triangle/tri_circumcenter**(shape_pts)](https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_circumcenter.html) | return the circumcenter of a triangle.
|
||||
[**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", ...) | triangulation by [ear clipping](https://en.wikipedia.org/wiki/Polygon_triangulation#Ear_clipping_method).
|
||||
[**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") | return the [Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation) of the points.
|
||||
**triangle/tri_delaunay_indices**(d) | return triangle indices from a delaunay object.
|
||||
**triangle/tri_delaunay_shapes**(d) | return triangle shapes from a delaunay object.
|
||||
|
BIN
docs/images/lib3x-tri_ear_clipping-1.JPG
Normal file
BIN
docs/images/lib3x-tri_ear_clipping-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
59
docs/lib3x-tri_ear_clipping.md
Normal file
59
docs/lib3x-tri_ear_clipping.md
Normal file
@ -0,0 +1,59 @@
|
||||
# tri_ear_clipping
|
||||
|
||||
Given a 2D shape. This function performs a polygon triangulation based on [Ear clipping](https://en.wikipedia.org/wiki/Polygon_triangulation#Ear_clipping_method).
|
||||
|
||||
**Since:** 3.0
|
||||
|
||||
## Parameters
|
||||
|
||||
- `shape_pts` : The shape points.
|
||||
- `ret` : The type of returned data. Default to `"TRI_INDICES"` which returns the indices of the `shape_pts`. If `"TRI_SHAPES"` is given, return triangle shapes.
|
||||
- `epsilon` : An upper bound on the relative error due to rounding in floating point arithmetic. Default to 0.0001.
|
||||
|
||||
## Examples
|
||||
|
||||
use <triangle/tri_ear_clipping.scad>;
|
||||
|
||||
shape = [
|
||||
[0, 0],
|
||||
[10, 0],
|
||||
[12, 5],
|
||||
[5, 10],
|
||||
[10, 15],
|
||||
[0, 20],
|
||||
[-5, 18],
|
||||
[-18, 3],
|
||||
[-4, 10]
|
||||
];
|
||||
|
||||
all_indices = tri_ear_clipping(shape);
|
||||
|
||||
for(tri_indices = all_indices) {
|
||||
offset(-.1)
|
||||
polygon([for(i = tri_indices) shape[i]]);
|
||||
}
|
||||
|
||||

|
||||
|
||||
use <triangle/tri_ear_clipping.scad>;
|
||||
|
||||
shape = [
|
||||
[0, 0],
|
||||
[10, 0],
|
||||
[12, 5],
|
||||
[5, 10],
|
||||
[10, 15],
|
||||
[0, 20],
|
||||
[-5, 18],
|
||||
[-18, 3],
|
||||
[-4, 10]
|
||||
];
|
||||
|
||||
tris = tri_ear_clipping(shape, ret = "TRI_SHAPES");
|
||||
|
||||
for(tri = tris) {
|
||||
offset(-.1)
|
||||
polygon(tri);
|
||||
}
|
||||
|
||||

|
@ -1,10 +1,15 @@
|
||||
/**
|
||||
copy from triangulate.scad, would move into triangle category
|
||||
* tri_circumcenter.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2021
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-tri_ear_clipping.html
|
||||
*
|
||||
**/
|
||||
|
||||
use <_impl/_tri_ear_clipping_impl.scad>;
|
||||
|
||||
// ret: "TRI_SHAPES", "TRI_INDICES"
|
||||
function tri_ear_clipping(shape_pts, ret = "TRI_INDICES", epsilon = 0.0001) =
|
||||
let(tris = _tri_ear_clipping_impl(shape_pts, epsilon))
|
||||
ret == "TRI_INDICES" ? tris : [for(tri = tris) [for(idx = tri) shape_pts[idx]]];
|
Loading…
x
Reference in New Issue
Block a user