1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
This commit is contained in:
Justin Lin 2020-10-04 18:30:54 +08:00
parent 172f033ba4
commit 74edf0c591
3 changed files with 14 additions and 12 deletions

View File

@ -57,3 +57,13 @@ function _convex_hull_upper_chain(points, chain, m, t, i) =
t,
i - 1
);
function _convex_hull(points) =
let(
sorted = _convex_hull_sort_by_xy(points),
leng = len(sorted),
lwr_ch = _convex_hull_lower_chain(sorted, leng, [], 0, 0),
leng_lwr_ch = len(lwr_ch),
chain = _convex_hull_upper_chain(sorted, lwr_ch, leng_lwr_ch, leng_lwr_ch + 1, leng - 2)
)
[for(i = [0:len(chain) - 2]) chain[i]];

View File

@ -1,11 +1,3 @@
use <experimental/_impl/_convex_hull_impl.scad>;
use <../__comm__/_convex_hull_impl.scad>;
function convex_hull(points) =
let(
sorted = _convex_hull_sort_by_xy(points),
leng = len(sorted),
lwr_ch = _convex_hull_lower_chain(sorted, leng, [], 0, 0),
leng_lwr_ch = len(lwr_ch),
chain = _convex_hull_upper_chain(sorted, lwr_ch, leng_lwr_ch, leng_lwr_ch + 1, leng - 2)
)
[for(i = [0:len(chain) - 2]) chain[i]];
function convex_hull(points) = _convex_hull(points);

View File

@ -1,5 +1,5 @@
use <experimental/convex_hull.scad>;
use <../__comm__/_convex_hull_impl.scad>;
module polygon_hull(points) {
polygon(convex_hull(points);
polygon(_convex_hull(points));
}